Skip to content

Commit ab19a3d

Browse files
authored
Merge pull request #4860 from magento-chaika/Chaika-PR-2019-10-03
Chaika-PR-2019-10-03
2 parents 0714971 + 5c646c9 commit ab19a3d

File tree

17 files changed

+414
-52
lines changed

17 files changed

+414
-52
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
11+
<actionGroup name="DisableProductLabelActionGroup">
12+
<annotations>
13+
<description>Disable Product Label and Change Attribute Set.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="createAttributeSet"/>
17+
</arguments>
18+
19+
<checkOption selector="{{AdminProductFormSection.enableProductLabel}}" stepKey="disableProduct"/>
20+
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickSaveButton"/>
21+
<waitForPageLoad time="30" stepKey="waitForChangeAttrSet"/>
22+
<click selector="{{AdminProductFormSection.attributeSet}}" stepKey="startEditAttrSet"/>
23+
<fillField selector="{{AdminProductFormSection.attributeSetFilter}}" userInput="{{createAttributeSet.attribute_set_name}}" stepKey="searchForAttrSet"/>
24+
<click selector="{{AdminProductFormSection.attributeSetFilterResult}}" stepKey="selectAttrSet"/>
25+
<dontSeeCheckboxIsChecked selector="{{AdminProductFormSection.productStatus}}" stepKey="dontSeeCheckboxEnableProductIsChecked"/>
26+
</actionGroup>
27+
</actionGroups>
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
9+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
10+
<test name="AdminDisableProductOnChangingAttributeSetTest">
11+
<annotations>
12+
<features value="Catalog"/>
13+
<stories value="Disabled product is enabled when change attribute set"/>
14+
<title value="Verify product status while changing attribute set"/>
15+
<description value="Value set for enabled product has to be shown when attribute set is changed"/>
16+
<severity value="MAJOR"/>
17+
<testCaseId value="MC-19716"/>
18+
<group value="catalog"/>
19+
</annotations>
20+
<before>
21+
<createData entity="SimpleSubCategory" stepKey="createCategory"/>
22+
<createData entity="_defaultProduct" stepKey="createSimpleProduct">
23+
<requiredEntity createDataKey="createCategory"/>
24+
</createData>
25+
<createData entity="CatalogAttributeSet" stepKey="createAttributeSet"/>
26+
</before>
27+
<after>
28+
<deleteData createDataKey="createAttributeSet" stepKey="deleteAttributeSet"/>
29+
<deleteData createDataKey="createSimpleProduct" stepKey="deleteProduct"/>
30+
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
31+
<actionGroup ref="ClearProductsFilterActionGroup" stepKey="clearProductsFilter"/>
32+
<actionGroup ref="logout" stepKey="logout"/>
33+
</after>
34+
<actionGroup ref="LoginAsAdmin" stepKey="login"/>
35+
<amOnPage url="{{AdminProductAttributeSetEditPage.url}}/$$createAttributeSet.attribute_set_id$$/" stepKey="onAttributeSetEdit"/>
36+
<actionGroup ref="SaveAttributeSet" stepKey="SaveAttributeSet"/>
37+
<actionGroup ref="SearchForProductOnBackendActionGroup" stepKey="searchForSimpleProduct">
38+
<argument name="product" value="$$createSimpleProduct$$"/>
39+
</actionGroup>
40+
41+
<actionGroup ref="OpenEditProductOnBackendActionGroup" stepKey="openEditProduct1">
42+
<argument name="product" value="$$createSimpleProduct$$"/>
43+
</actionGroup>
44+
<actionGroup ref="DisableProductLabelActionGroup" stepKey="disableWhileChangingAttributeSet" >
45+
<argument name="createAttributeSet" value="$$createAttributeSet$$"/>
46+
</actionGroup>
47+
48+
</test>
49+
</tests>

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/GeneralTest.php

Lines changed: 109 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected function setUp()
3333
parent::setUp();
3434

3535
$this->attributeRepositoryMock = $this->getMockBuilder(AttributeRepositoryInterface::class)
36-
->getMockForAbstractClass();
36+
->getMockForAbstractClass();
3737

3838
$arrayManager = $this->objectManager->getObject(ArrayManager::class);
3939

@@ -52,35 +52,42 @@ protected function setUp()
5252
*/
5353
protected function createModel()
5454
{
55-
return $this->objectManager->getObject(General::class, [
55+
return $this->objectManager->getObject(
56+
General::class,
57+
[
5658
'locator' => $this->locatorMock,
5759
'arrayManager' => $this->arrayManagerMock,
58-
]);
60+
]
61+
);
5962
}
6063

6164
public function testModifyMeta()
6265
{
6366
$this->arrayManagerMock->expects($this->any())
6467
->method('merge')
6568
->willReturnArgument(2);
66-
$this->assertNotEmpty($this->getModel()->modifyMeta([
67-
'first_panel_code' => [
69+
$this->assertNotEmpty(
70+
$this->getModel()->modifyMeta(
71+
[
72+
'first_panel_code' => [
6873
'arguments' => [
6974
'data' => [
7075
'config' => [
7176
'label' => 'Test label',
7277
]
7378
],
7479
]
75-
]
76-
]));
80+
]
81+
]
82+
)
83+
);
7784
}
7885

7986
/**
80-
* @param array $data
81-
* @param int $defaultStatusValue
82-
* @param array $expectedResult
83-
* @throws \Magento\Framework\Exception\NoSuchEntityException
87+
* @param array $data
88+
* @param int $defaultStatusValue
89+
* @param array $expectedResult
90+
* @throws \Magento\Framework\Exception\NoSuchEntityException
8491
* @dataProvider modifyDataDataProvider
8592
*/
8693
public function testModifyDataNewProduct(array $data, int $defaultStatusValue, array $expectedResult)
@@ -100,6 +107,97 @@ public function testModifyDataNewProduct(array $data, int $defaultStatusValue, a
100107
$this->assertSame($expectedResult, $this->generalModifier->modifyData($data));
101108
}
102109

110+
/**
111+
* Verify the product attribute status set owhen editing existing product
112+
*
113+
* @param array $data
114+
* @param string $modelId
115+
* @param int $defaultStatus
116+
* @param int $statusAttributeValue
117+
* @param array $expectedResult
118+
* @throws \Magento\Framework\Exception\NoSuchEntityException
119+
* @dataProvider modifyDataOfExistingProductDataProvider
120+
*/
121+
public function testModifyDataOfExistingProduct(
122+
array $data,
123+
string $modelId,
124+
int $defaultStatus,
125+
int $statusAttributeValue,
126+
array $expectedResult
127+
) {
128+
$attributeMock = $this->getMockForAbstractClass(AttributeInterface::class);
129+
$attributeMock->expects($this->any())
130+
->method('getDefaultValue')
131+
->willReturn($defaultStatus);
132+
$this->attributeRepositoryMock->expects($this->any())
133+
->method('get')
134+
->with(
135+
ProductAttributeInterface::ENTITY_TYPE_CODE,
136+
ProductAttributeInterface::CODE_STATUS
137+
)
138+
->willReturn($attributeMock);
139+
$this->productMock->expects($this->any())
140+
->method('getId')
141+
->willReturn($modelId);
142+
$this->productMock->expects($this->any())
143+
->method('getStatus')
144+
->willReturn($statusAttributeValue);
145+
$this->assertSame($expectedResult, current($this->generalModifier->modifyData($data)));
146+
}
147+
148+
/**
149+
* @return array
150+
*/
151+
public function modifyDataOfExistingProductDataProvider(): array
152+
{
153+
return [
154+
'With enable status value' => [
155+
'data' => [],
156+
'modelId' => '1',
157+
'defaultStatus' => 1,
158+
'statusAttributeValue' => 1,
159+
'expectedResult' => [
160+
General::DATA_SOURCE_DEFAULT => [
161+
ProductAttributeInterface::CODE_STATUS => 1,
162+
],
163+
],
164+
],
165+
'Without disable status value' => [
166+
'data' => [],
167+
'modelId' => '1',
168+
'defaultStatus' => 1,
169+
'statusAttributeValue' => 2,
170+
'expectedResult' => [
171+
General::DATA_SOURCE_DEFAULT => [
172+
ProductAttributeInterface::CODE_STATUS => 2,
173+
],
174+
],
175+
],
176+
'With enable status value with empty modelId' => [
177+
'data' => [],
178+
'modelId' => '',
179+
'defaultStatus' => 1,
180+
'statusAttributeValue' => 1,
181+
'expectedResult' => [
182+
General::DATA_SOURCE_DEFAULT => [
183+
ProductAttributeInterface::CODE_STATUS => 1,
184+
],
185+
],
186+
],
187+
'Without disable status value with empty modelId' => [
188+
'data' => [],
189+
'modelId' => '',
190+
'defaultStatus' => 2,
191+
'statusAttributeValue' => 2,
192+
'expectedResult' => [
193+
General::DATA_SOURCE_DEFAULT => [
194+
ProductAttributeInterface::CODE_STATUS => 2,
195+
],
196+
],
197+
],
198+
];
199+
}
200+
103201
/**
104202
* @return array
105203
*/

0 commit comments

Comments
 (0)