Skip to content

Commit d93fc4f

Browse files
author
Magento CICD
authored
merge magento/2.3-develop into magento-borg/MAGETWO-91848-max-characters
2 parents 16dd29a + 5565a24 commit d93fc4f

18 files changed

+629
-5
lines changed

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

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
*/
66
namespace Magento\Catalog\Test\Unit\Ui\DataProvider\Product\Form\Modifier;
77

8-
use Magento\Catalog\Model\Product\Type;
8+
use Magento\Catalog\Api\Data\ProductAttributeInterface;
99
use Magento\Catalog\Ui\DataProvider\Product\Form\Modifier\General;
10+
use Magento\Eav\Api\AttributeRepositoryInterface;
11+
use Magento\Eav\Api\Data\AttributeInterface;
12+
use Magento\Framework\Stdlib\ArrayManager;
1013

1114
/**
1215
* Class GeneralTest
@@ -15,6 +18,35 @@
1518
*/
1619
class GeneralTest extends AbstractModifierTest
1720
{
21+
/**
22+
* @var AttributeRepositoryInterface|\PHPUnit_Framework_MockObject_MockObject
23+
*/
24+
private $attributeRepositoryMock;
25+
26+
/**
27+
* @var General
28+
*/
29+
private $generalModifier;
30+
31+
protected function setUp()
32+
{
33+
parent::setUp();
34+
35+
$this->attributeRepositoryMock = $this->getMockBuilder(AttributeRepositoryInterface::class)
36+
->getMockForAbstractClass();
37+
38+
$arrayManager = $this->objectManager->getObject(ArrayManager::class);
39+
40+
$this->generalModifier = $this->objectManager->getObject(
41+
General::class,
42+
[
43+
'attributeRepository' => $this->attributeRepositoryMock,
44+
'locator' => $this->locatorMock,
45+
'arrayManager' => $arrayManager,
46+
]
47+
);
48+
}
49+
1850
/**
1951
* {@inheritdoc}
2052
*/
@@ -40,4 +72,59 @@ public function testModifyMeta()
4072
]
4173
]));
4274
}
75+
76+
/**
77+
* @param array $data
78+
* @param int $defaultStatusValue
79+
* @param array $expectedResult
80+
* @throws \Magento\Framework\Exception\NoSuchEntityException
81+
* @dataProvider modifyDataDataProvider
82+
*/
83+
public function testModifyDataNewProduct(array $data, int $defaultStatusValue, array $expectedResult)
84+
{
85+
$attributeMock = $this->getMockBuilder(AttributeInterface::class)
86+
->getMockForAbstractClass();
87+
$attributeMock
88+
->method('getDefaultValue')
89+
->willReturn($defaultStatusValue);
90+
$this->attributeRepositoryMock
91+
->method('get')
92+
->with(
93+
ProductAttributeInterface::ENTITY_TYPE_CODE,
94+
ProductAttributeInterface::CODE_STATUS
95+
)
96+
->willReturn($attributeMock);
97+
$this->assertSame($expectedResult, $this->generalModifier->modifyData($data));
98+
}
99+
100+
/**
101+
* @return array
102+
*/
103+
public function modifyDataDataProvider(): array
104+
{
105+
return [
106+
'With default status value' => [
107+
'data' => [],
108+
'defaultStatusAttributeValue' => 5,
109+
'expectedResult' => [
110+
null => [
111+
General::DATA_SOURCE_DEFAULT => [
112+
ProductAttributeInterface::CODE_STATUS => 5,
113+
],
114+
],
115+
],
116+
],
117+
'Without default status value' => [
118+
'data' => [],
119+
'defaultStatusAttributeValue' => 0,
120+
'expectedResult' => [
121+
null => [
122+
General::DATA_SOURCE_DEFAULT => [
123+
ProductAttributeInterface::CODE_STATUS => 1,
124+
],
125+
],
126+
],
127+
],
128+
];
129+
}
43130
}

app/code/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/General.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
use Magento\Catalog\Api\Data\ProductAttributeInterface;
99
use Magento\Catalog\Model\Locator\LocatorInterface;
10+
use Magento\Eav\Api\AttributeRepositoryInterface;
1011
use Magento\Ui\Component\Form;
1112
use Magento\Framework\Stdlib\ArrayManager;
1213

@@ -35,21 +36,31 @@ class General extends AbstractModifier
3536
*/
3637
private $localeCurrency;
3738

39+
/**
40+
* @var AttributeRepositoryInterface
41+
*/
42+
private $attributeRepository;
43+
3844
/**
3945
* @param LocatorInterface $locator
4046
* @param ArrayManager $arrayManager
47+
* @param AttributeRepositoryInterface|null $attributeRepository
4148
*/
4249
public function __construct(
4350
LocatorInterface $locator,
44-
ArrayManager $arrayManager
51+
ArrayManager $arrayManager,
52+
AttributeRepositoryInterface $attributeRepository = null
4553
) {
4654
$this->locator = $locator;
4755
$this->arrayManager = $arrayManager;
56+
$this->attributeRepository = $attributeRepository
57+
?: \Magento\Framework\App\ObjectManager::getInstance()->get(AttributeRepositoryInterface::class);
4858
}
4959

5060
/**
5161
* {@inheritdoc}
5262
* @since 101.0.0
63+
* @throws \Magento\Framework\Exception\NoSuchEntityException
5364
*/
5465
public function modifyData(array $data)
5566
{
@@ -58,7 +69,12 @@ public function modifyData(array $data)
5869
$modelId = $this->locator->getProduct()->getId();
5970

6071
if (!isset($data[$modelId][static::DATA_SOURCE_DEFAULT][ProductAttributeInterface::CODE_STATUS])) {
61-
$data[$modelId][static::DATA_SOURCE_DEFAULT][ProductAttributeInterface::CODE_STATUS] = '1';
72+
$attributeStatus = $this->attributeRepository->get(
73+
ProductAttributeInterface::ENTITY_TYPE_CODE,
74+
ProductAttributeInterface::CODE_STATUS
75+
);
76+
$data[$modelId][static::DATA_SOURCE_DEFAULT][ProductAttributeInterface::CODE_STATUS] =
77+
$attributeStatus->getDefaultValue() ?: 1;
6278
}
6379

6480
return $data;

dev/tests/acceptance/tests/functional/Magento/FunctionalTest/Catalog/Section/AdminProductFormSection.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
<section name="AdminProductFormSection">
1111
<element name="productName" type="input" selector=".admin__field[data-index=name] input"/>
1212
<element name="productSku" type="input" selector=".admin__field[data-index=sku] input"/>
13+
<element name="productStatus" type="checkbox" selector="input[name='product[status]']"/>
14+
<element name="enableProductLabel" type="checkbox" selector="input[name='product[status]']+label"/>
15+
<element name="productStatusUseDefault" type="checkbox" selector="input[name='use_default[status]']"/>
1316
<element name="productPrice" type="input" selector=".admin__field[data-index=price] input"/>
1417
<element name="advancedPricingLink" type="button" selector="button[data-index='advanced_pricing_button']"/>
1518
<element name="categoriesDropdown" type="multiselect" selector="div[data-index='category_ids']"/>
@@ -31,6 +34,11 @@
3134
<element name="visibility" type="select" selector="//select[@name='product[visibility]']"/>
3235
<element name="visibilityUseDefault" type="checkbox" selector="//input[@name='use_default[visibility]']"/>
3336
</section>
37+
<section name="ProductInWebsitesSection">
38+
<element name="sectionHeader" type="button" selector="div[data-index='websites']" timeout="30"/>
39+
<!--<element name="websites" type="checkbox" selector="input[name='product[website_ids][{{var1}}]']" parameterized="true"/>-->
40+
<element name="website" type="checkbox" selector="//label[contains(text(), '{{var1}}')]/parent::div//input[@type='checkbox']" parameterized="true"/>
41+
</section>
3442
<section name="ProductDesignSection">
3543
<element name="DesignTab" type="button" selector="//strong[@class='admin__collapsible-title']//span[text()='Design']"/>
3644
<element name="LayoutDropdown" type="select" selector="select[name='product[page_layout]']"/>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
11+
<test name="AdminProductStatusAttributeDisabledByDefaultTest">
12+
<annotations>
13+
<title value="Verify the default option value for product Status attribute is set correctly during product creation"/>
14+
<description value="The default option value for product Status attribute is set correctly during product creation"/>
15+
<severity value="MAJOR"/>
16+
<testCaseId value="MAGETWO-92424"/>
17+
<group value="Catalog"/>
18+
</annotations>
19+
<before>
20+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
21+
22+
</before>
23+
<after>
24+
<amOnPage url="{{AdminProductAttributeGridPage.url}}" stepKey="navigateToProductAttribute"/>
25+
<waitForPageLoad stepKey="wait1"/>
26+
<click selector="{{AdminProductAttributeGridSection.ResetFilter}}" stepKey="resetFiltersOnGrid1"/>
27+
<fillField selector="{{AdminProductAttributeGridSection.GridFilterFrontEndLabel}}" userInput="Enable Product" stepKey="setAttributeLabel1"/>
28+
<click selector="{{AdminProductAttributeGridSection.Search}}" stepKey="searchForAttributeFromTheGrid1"/>
29+
<click selector="{{AdminProductAttributeGridSection.FirstRow}}" stepKey="clickOnAttributeRow1"/>
30+
<waitForPageLoad stepKey="wait2"/>
31+
<click selector="{{AdminNewAttributePanel.isDefault('1')}}" stepKey="resetOptionForStatusAttribute"/>
32+
<click selector="{{AttributePropertiesSection.Save}}" stepKey="saveAttribute1"/>
33+
<waitForPageLoad stepKey="waitForSaveAttribute1"/>
34+
<actionGroup ref="ClearCacheActionGroup" stepKey="clearCache1"/>
35+
36+
<actionGroup ref="logout" stepKey="logoutOfAdmin"/>
37+
</after>
38+
<amOnPage url="{{AdminProductAttributeGridPage.url}}" stepKey="navigateToProductAttribute"/>
39+
<waitForPageLoad stepKey="wait1"/>
40+
<click selector="{{AdminProductAttributeGridSection.ResetFilter}}" stepKey="resetFiltersOnGrid"/>
41+
<fillField selector="{{AdminProductAttributeGridSection.GridFilterFrontEndLabel}}" userInput="Enable Product" stepKey="setAttributeLabel"/>
42+
<click selector="{{AdminProductAttributeGridSection.Search}}" stepKey="searchForAttributeFromTheGrid"/>
43+
<click selector="{{AdminProductAttributeGridSection.FirstRow}}" stepKey="clickOnAttributeRow"/>
44+
<waitForPageLoad stepKey="wait2"/>
45+
<click selector="{{AdminNewAttributePanel.isDefault('2')}}" stepKey="chooseDisabledOptionForStatus"/>
46+
<click selector="{{AttributePropertiesSection.Save}}" stepKey="saveAttribute"/>
47+
<waitForPageLoad stepKey="waitForAttributeToSave"/>
48+
<actionGroup ref="ClearCacheActionGroup" stepKey="clearCache"/>
49+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToProductIndex"/>
50+
<waitForPageLoad time="30" stepKey="waitForProductGridPageToLoad"/>
51+
<click selector="{{AdminProductGridActionSection.addProductToggle}}" stepKey="clickOnAddProductDropdown"/>
52+
<click selector="{{AdminProductGridActionSection.addSimpleProduct}}" stepKey="clickOnAddSimpleProduct"/>
53+
<waitForPageLoad stepKey="waitForProductEditToLoad"/>
54+
<dontSeeCheckboxIsChecked selector="{{AdminProductFormSection.productStatus}}" stepKey="dontSeeCheckboxEnableProductIsChecked"/>
55+
56+
</test>
57+
</tests>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="../../../../../../vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Test/etc/testSchema.xsd">
11+
<test name="SaveProductWithCustomOptionsAdditionalWebsiteTest">
12+
<annotations>
13+
<features value="Save a product with Custom Options and assign to a different website"/>
14+
<stories value="Purchase a product with Custom Options of different types"/>
15+
<title value="You should be able to save a product with custom options assigned to a different website"/>
16+
<description value="Custom Options should not be split when saving the product after assigning to a different website"/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="MAGETWO-91436"/>
19+
<group value="product"/>
20+
</annotations>
21+
22+
<after>
23+
<actionGroup ref="ResetWebUrlOptions" stepKey="resetUrlOption"/>
24+
<actionGroup ref="AdminDeleteWebsiteActionGroup" stepKey="deleteWebsite"/>
25+
26+
<amOnPage url="admin/admin/auth/logout/" stepKey="amOnLogoutPage"/>
27+
</after>
28+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
29+
<actionGroup ref="EnableWebUrlOptions" stepKey="addStoreCodeToUrls"/>
30+
<actionGroup ref="AdminCreateWebsiteActionGroup" stepKey="addnewWebsite"/>
31+
<actionGroup ref="AdminCreateNewStoreGroupActionGroup" stepKey="addNewStoreGroup"/>
32+
33+
<!--Create Store view -->
34+
<amOnPage url="{{AdminSystemStorePage.url}}" stepKey="amOnAdminSystemStorePage"/>
35+
<click selector="{{AdminStoresMainActionsSection.createStoreViewButton}}" stepKey="createStoreViewButton"/>
36+
<waitForPageLoad stepKey="waitForProductPageLoad"/>
37+
<selectOption userInput="Second Store" selector="{{AdminNewStoreSection.storeGrpDropdown}}" stepKey="selectStoreGroup"/>
38+
<fillField userInput="Second Store View" selector="{{AdminNewStoreSection.storeNameTextField}}" stepKey="fillStoreViewName"/>
39+
<fillField userInput="second_store_view" selector="{{AdminNewStoreSection.storeCodeTextField}}" stepKey="fillStoreViewCode"/>
40+
<selectOption userInput="1" selector="{{AdminNewStoreSection.statusDropdown}}" stepKey="enableStoreViewStatus"/>
41+
<click selector="{{AdminStoresMainActionsSection.saveButton}}" stepKey="clickStoreViewSaveButton"/>
42+
<waitForElementVisible selector="{{AdminNewStoreSection.acceptNewStoreViewCreation}}" stepKey="waitForAcceptNewStoreViewCreationModal" />
43+
<conditionalClick selector="{{AdminNewStoreSection.acceptNewStoreViewCreation}}" dependentSelector="{{AdminNewStoreSection.acceptNewStoreViewCreation}}" visible="true" stepKey="AcceptNewStoreViewCreation"/>
44+
<waitForElementVisible selector="{{AdminStoresGridSection.storeFilterTextField}}" stepKey="waitForPageReolad"/>
45+
<see userInput="You saved the store view." stepKey="seeSaveMessage" />
46+
47+
<!--Create a Simple Product with Custom Options -->
48+
<amOnPage url="{{AdminProductIndexPage.url}}" stepKey="navigateToCatalogProductGrid"/>
49+
<click selector="{{AdminProductGridActionSection.addProductToggle}}" stepKey="clickAddProductDropdown"/>
50+
<click selector="{{AdminProductGridActionSection.addSimpleProduct}}" stepKey="clickAddSimpleProduct"/>
51+
<fillField userInput="{{_defaultProduct.name}}" selector="{{AdminProductFormSection.productName}}" stepKey="fillName"/>
52+
<fillField userInput="{{_defaultProduct.sku}}" selector="{{AdminProductFormSection.productSku}}" stepKey="fillSKU"/>
53+
<fillField userInput="{{_defaultProduct.price}}" selector="{{AdminProductFormSection.productPrice}}" stepKey="fillPrice"/>
54+
<fillField userInput="{{_defaultProduct.quantity}}" selector="{{AdminProductFormSection.productQuantity}}" stepKey="fillQuantity"/>
55+
56+
<!--<click selector="{{AdminProductCustomizableOptionsSection.customezableOptions}}" stepKey="openCustomOptionsSection"/>-->
57+
<conditionalClick selector="{{AdminProductCustomizableOptionsSection.customezableOptions}}" dependentSelector="{{AdminProductCustomizableOptionsSection.checkIfCustomizableOptionsTabOpen}}" visible="true" stepKey="clickIfContentTabCloses2"/>
58+
<click selector="{{AdminProductCustomizableOptionsSection.addOptionBtn}}" stepKey="clickAddOption"/>
59+
<waitForPageLoad stepKey="waitAfterAddOption"/>
60+
<fillField selector="input[name='product[options][0][title]']" userInput="Radio Option" stepKey="fillOptionTitle"/>
61+
<click selector=".admin__dynamic-rows[data-index='options'] .action-select" stepKey="openOptionTypeDropDown"/>
62+
<click selector=".admin__dynamic-rows[data-index='options'] .action-menu._active li:nth-of-type(3) li:nth-of-type(2)" stepKey="selectRadioButtonType"/>
63+
64+
<!--Add Option Values -->
65+
<click selector="{{AdminProductCustomizableOptionsSection.clickAddValue('Radio Option')}}" stepKey="clickAddValue1"/>
66+
<fillField selector="{{AdminProductCustomizableOptionsSection.fillOptionValueTitle('Radio Option', '0')}}" userInput="option 1" stepKey="fillOptionValueTitle1"/>
67+
<fillField selector="{{AdminProductCustomizableOptionsSection.fillOptionValuePrice('Radio Option', '0')}}" userInput="5" stepKey="fillOptionValuePrice1"/>
68+
69+
<click selector="{{AdminProductCustomizableOptionsSection.clickAddValue('Radio Option')}}" stepKey="clickAddValue2"/>
70+
<fillField selector="{{AdminProductCustomizableOptionsSection.fillOptionValueTitle('Radio Option', '1')}}" userInput="option 2" stepKey="fillOptionValueTitle2"/>
71+
<fillField selector="{{AdminProductCustomizableOptionsSection.fillOptionValuePrice('Radio Option', '1')}}" userInput="6" stepKey="fillOptionValuePrice2"/>
72+
73+
<click selector="{{AdminProductCustomizableOptionsSection.clickAddValue('Radio Option')}}" stepKey="clickAddValue3"/>
74+
<fillField selector="{{AdminProductCustomizableOptionsSection.fillOptionValueTitle('Radio Option', '2')}}" userInput="option 3" stepKey="fillOptionValueTitle3"/>
75+
<fillField selector="{{AdminProductCustomizableOptionsSection.fillOptionValuePrice('Radio Option', '2')}}" userInput="7" stepKey="fillOptionValuePrice3"/>
76+
77+
<!--Save the product with custom options -->
78+
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickSaveButton"/>
79+
<waitForLoadingMaskToDisappear stepKey="waitProductPageSave"/>
80+
<seeElement selector="{{AdminProductMessagesSection.successMessage}}" stepKey="seeProductSavedMessage"/>
81+
82+
<!-- Add this product to second website -->
83+
<click selector="{{ProductInWebsitesSection.sectionHeader}}" stepKey="openProductInWebsitesSection1"/>
84+
<click selector="{{ProductInWebsitesSection.website('Second Website')}}" stepKey="selectSecondWebsite"/>
85+
<click selector="{{AdminProductFormActionSection.saveButton}}" stepKey="clickSave"/>
86+
<waitForLoadingMaskToDisappear stepKey="waitForProductPagetoSaveAgain"/>
87+
<seeElement selector="{{AdminProductMessagesSection.successMessage}}" stepKey="seeSaveProductMessageAgain"/>
88+
89+
<click selector="{{AdminProductCustomizableOptionsSection.customezableOptions}}" stepKey="openCustomOptionsSection2"/>
90+
<seeNumberOfElements selector=".admin__dynamic-rows[data-index='values'] tr.data-row" userInput="3" stepKey="see4RowsOfOptions"/>
91+
92+
</test>
93+
</tests>

0 commit comments

Comments
 (0)