Skip to content

Commit 3751fb1

Browse files
committed
Merge remote-tracking branch 'origin/MC-17259' into 2.3-develop-pr96
2 parents a5e5c77 + 46bded0 commit 3751fb1

File tree

42 files changed

+579
-120
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+579
-120
lines changed

app/code/Magento/Catalog/Model/Product/Image/ParamsBuilder.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,12 @@ private function getWatermark(string $type, int $scopeId = null): array
130130
);
131131

132132
if ($file) {
133-
$size = $this->scopeConfig->getValue(
134-
"design/watermark/{$type}_size",
135-
ScopeInterface::SCOPE_STORE,
136-
$scopeId
133+
$size = explode(
134+
'x',
135+
$this->scopeConfig->getValue(
136+
"design/watermark/{$type}_size",
137+
ScopeInterface::SCOPE_STORE
138+
)
137139
);
138140
$opacity = $this->scopeConfig->getValue(
139141
"design/watermark/{$type}_imageOpacity",
@@ -145,8 +147,8 @@ private function getWatermark(string $type, int $scopeId = null): array
145147
ScopeInterface::SCOPE_STORE,
146148
$scopeId
147149
);
148-
$width = !empty($size['width']) ? $size['width'] : null;
149-
$height = !empty($size['height']) ? $size['height'] : null;
150+
$width = !empty($size['0']) ? $size['0'] : null;
151+
$height = !empty($size['1']) ? $size['1'] : null;
150152

151153
return [
152154
'watermark_file' => $file,
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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="AdminUpdateCustomerGenderInCustomersGridActionGroup">
12+
<annotations>
13+
<description>Update customer gender attribute value on customers grid page</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="customerEmail" defaultValue="{{Simple_US_Customer.email}}" type="string"/>
17+
<argument name="genderValue" defaultValue="{{Gender.empty}}" type="string"/>
18+
</arguments>
19+
20+
<click selector="{{AdminDataGridTableSection.rowTemplate(customerEmail)}}" stepKey="clickCustomersGridRow"/>
21+
<waitForElementVisible selector="{{AdminCustomerGridInlineEditorSection.customerGenderEditor}}" stepKey="waitForGenderElementAppears"/>
22+
<selectOption userInput="{{genderValue}}" selector="{{AdminCustomerGridInlineEditorSection.customerGenderEditor}}" stepKey="selectGenderValue"/>
23+
<click selector="{{AdminCustomerGridInlineEditorSection.saveInGrid}}" stepKey="saveCustomer"/>
24+
</actionGroup>
25+
</actionGroups>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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="AssertAdminCustomerGenderInCustomersGridActionGroup">
12+
<annotations>
13+
<description>Assert customer "Gender" attribute value on customer grid page</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="customerEmail" defaultValue="{{Simple_US_Customer.email}}" type="string"/>
17+
<argument name="expectedGenderValue" defaultValue="{{Gender.empty}}" type="string"/>
18+
</arguments>
19+
20+
<see userInput="{{expectedGenderValue}}" selector="{{AdminCustomerGridSection.customerGenderByEmail(customerEmail)}}" stepKey="assertGenderValue"/>
21+
</actionGroup>
22+
</actionGroups>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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="AssertAdminCustomerGenderOnCustomerFormActionGroup">
12+
<annotations>
13+
<description>Validates that the provided Customer Gender is selected on the Admin Customer edit page.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="customerGender" defaultValue="{{Gender.empty}}" type="string"/>
17+
</arguments>
18+
19+
<conditionalClick selector="{{AdminCustomerAccountInformationSection.accountInformationTab}}" dependentSelector="{{AdminCustomerAccountInformationSection.gender}}" visible="false" stepKey="clickOnAccountInfoTab"/>
20+
<waitForPageLoad stepKey="waitForPageLoad"/>
21+
<seeOptionIsSelected userInput="{{customerGender}}" selector="{{AdminCustomerAccountInformationSection.gender}}" stepKey="verifyNeededCustomerGenderSelected"/>
22+
</actionGroup>
23+
</actionGroups>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd">
11+
<entity name="Gender" type="gender">
12+
<data key="empty"/>
13+
<data key="male">Male</data>
14+
<data key="female">Female</data>
15+
<data key="not_specified">Not Specified</data>
16+
</entity>
17+
</entities>

app/code/Magento/Customer/Test/Mftf/Page/AdminCustomerPage.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
<section name="AdminCustomerMessagesSection"/>
1414
<section name="AdminCustomerGridSection"/>
1515
<section name="AdminCustomerFiltersSection"/>
16+
<section name="AdminCustomerGridInlineEditorSection"/>
1617
</page>
1718
</pages>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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+
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
11+
<section name="AdminCustomerGridInlineEditorSection">
12+
<element name="customerGenderEditor" type="select" selector="tr.data-grid-editable-row:not([style*='display: none']) [name='gender']"/>
13+
<element name="saveInGrid" type="button" selector="tr.data-grid-editable-row-actions button.action-primary" timeout="30"/>
14+
</section>
15+
</sections>

app/code/Magento/Customer/Test/Mftf/Section/AdminCustomerGridSection.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,7 @@
1616
<element name="customerCheckboxByEmail" type="checkbox" selector="//tr[@class='data-row' and //div[text()='{{customerEmail}}']]//input[@type='checkbox']" parameterized="true" timeout="30"/>
1717
<element name="customerEditLinkByEmail" type="text" selector="//tr[@class='data-row' and //div[text()='{{customerEmail}}']]//a[@class='action-menu-item']" parameterized="true" timeout="30"/>
1818
<element name="customerGroupByEmail" type="text" selector="//tr[@class='data-row' and //div[text()='{{customerEmail}}']]//div[text()='{{customerGroup}}']" parameterized="true"/>
19+
<element name="customerGenderByEmail" type="text" selector="//tr[@class='data-row']//div[text()='{{customerEmail}}']/ancestor::tr/td[count(//div[@data-role='grid-wrapper']//tr//th[contains(., 'Gender')]/preceding-sibling::th) +1]" parameterized="true"/>
1920
</section>
2021
</sections>
22+
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
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="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminChangeCustomerGenderInCustomersGridTest">
12+
<annotations>
13+
<features value="Customer"/>
14+
<stories value="Update Customer"/>
15+
<title value="Gender attribute blank value is saved in direct edits from customer grid"/>
16+
<description value="Check that gender attribute blank value can be saved on customers grid"/>
17+
<severity value="MAJOR"/>
18+
<testCaseId value="MC-22025"/>
19+
<useCaseId value="MC-17259"/>
20+
<group value="customer"/>
21+
</annotations>
22+
<before>
23+
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
24+
<actionGroup ref="LoginAsAdmin" stepKey="login"/>
25+
</before>
26+
<after>
27+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
28+
<!-- Reset customer grid filter -->
29+
<amOnPage url="{{AdminCustomerPage.url}}" stepKey="goToCustomersGridPage"/>
30+
<waitForPageLoad stepKey="waitForCustomersGrid"/>
31+
<actionGroup ref="AdminResetFilterInCustomerGrid" stepKey="resetFilter"/>
32+
33+
<actionGroup ref="logout" stepKey="logout"/>
34+
</after>
35+
<!-- Open customers grid page, filter by created customer-->
36+
<actionGroup ref="AdminFilterCustomerByEmail" stepKey="filterCustomerGridByEmail">
37+
<argument name="email" value="$createCustomer.email$"/>
38+
</actionGroup>
39+
<!-- Check customer is in grid-->
40+
<actionGroup ref="AdminAssertCustomerInCustomersGrid" stepKey="assertCustomerInCustomersGrid">
41+
<argument name="text" value="$createCustomer.email$"/>
42+
<argument name="row" value="1"/>
43+
</actionGroup>
44+
<!--Check customer Gender value in grid-->
45+
<actionGroup ref="AssertAdminCustomerGenderInCustomersGridActionGroup" stepKey="assertCustomerGenderInCustomersGrid">
46+
<argument name="customerEmail" value="$createCustomer.email$"/>
47+
</actionGroup>
48+
<!--Update customer Gender to Male-->
49+
<actionGroup ref="AdminUpdateCustomerGenderInCustomersGridActionGroup" stepKey="updateCustomerGenderWithMaleValueInCustomersGrid">
50+
<argument name="customerEmail" value="$createCustomer.email$"/>
51+
<argument name="genderValue" value="{{Gender.male}}"/>
52+
</actionGroup>
53+
<!--Check customer Gender value in grid-->
54+
<actionGroup ref="AssertAdminCustomerGenderInCustomersGridActionGroup" stepKey="assertCustomerGenderMaleInCustomersGrid">
55+
<argument name="customerEmail" value="$createCustomer.email$"/>
56+
<argument name="expectedGenderValue" value="{{Gender.male}}"/>
57+
</actionGroup>
58+
<!--Open customer edit page and check Gender value-->
59+
<actionGroup ref="AdminOpenCustomerEditPageActionGroup" stepKey="openCustomerEditPageWithMaleGender">
60+
<argument name="customerId" value="$createCustomer.id$"/>
61+
</actionGroup>
62+
<actionGroup ref="AssertAdminCustomerGenderOnCustomerFormActionGroup" stepKey="assertCustomerGenderValueIsMaleOnCustomerForm">
63+
<argument name="customerGender" value="{{Gender.male}}"/>
64+
</actionGroup>
65+
<!--Filter customers grid by email-->
66+
<actionGroup ref="AdminFilterCustomerByEmail" stepKey="filterCustomerByEmailToUpdateWithEmptyGender">
67+
<argument name="email" value="$createCustomer.email$"/>
68+
</actionGroup>
69+
<!--Update customer Gender to empty value-->
70+
<actionGroup ref="AdminUpdateCustomerGenderInCustomersGridActionGroup" stepKey="updateCustomerGenderWithEmptyValueInCustomersGrid">
71+
<argument name="customerEmail" value="$createCustomer.email$"/>
72+
</actionGroup>
73+
<!--Check customer Gender value in grid-->
74+
<actionGroup ref="AssertAdminCustomerGenderInCustomersGridActionGroup" stepKey="assertCustomerGenderEmptyInCustomersGrid">
75+
<argument name="customerEmail" value="$createCustomer.email$"/>
76+
</actionGroup>
77+
<!--Open customer edit page and check Gender value-->
78+
<actionGroup ref="AdminOpenCustomerEditPageActionGroup" stepKey="openCustomerEditPageWithEmptyGender">
79+
<argument name="customerId" value="$createCustomer.id$"/>
80+
</actionGroup>
81+
<actionGroup ref="AssertAdminCustomerGenderOnCustomerFormActionGroup" stepKey="assertCustomerGenderValueIsEmptyOnCustomerForm"/>
82+
</test>
83+
</tests>

app/code/Magento/CustomerGraphQl/Model/Customer/Address/CreateCustomerAddress.php

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
use Magento\Customer\Api\AddressRepositoryInterface;
1111
use Magento\Customer\Api\Data\AddressInterface;
1212
use Magento\Customer\Api\Data\AddressInterfaceFactory;
13+
use Magento\Directory\Helper\Data as DirectoryData;
14+
use Magento\Framework\Api\DataObjectHelper;
1315
use Magento\Framework\Exception\LocalizedException;
1416
use Magento\Framework\GraphQl\Exception\GraphQlInputException;
15-
use Magento\Framework\Api\DataObjectHelper;
1617

1718
/**
1819
* Create customer address
@@ -38,23 +39,30 @@ class CreateCustomerAddress
3839
* @var DataObjectHelper
3940
*/
4041
private $dataObjectHelper;
42+
/**
43+
* @var DirectoryData
44+
*/
45+
private $directoryData;
4146

4247
/**
4348
* @param GetAllowedAddressAttributes $getAllowedAddressAttributes
4449
* @param AddressInterfaceFactory $addressFactory
4550
* @param AddressRepositoryInterface $addressRepository
4651
* @param DataObjectHelper $dataObjectHelper
52+
* @param DirectoryData $directoryData
4753
*/
4854
public function __construct(
4955
GetAllowedAddressAttributes $getAllowedAddressAttributes,
5056
AddressInterfaceFactory $addressFactory,
5157
AddressRepositoryInterface $addressRepository,
52-
DataObjectHelper $dataObjectHelper
58+
DataObjectHelper $dataObjectHelper,
59+
DirectoryData $directoryData
5360
) {
5461
$this->getAllowedAddressAttributes = $getAllowedAddressAttributes;
5562
$this->addressFactory = $addressFactory;
5663
$this->addressRepository = $addressRepository;
5764
$this->dataObjectHelper = $dataObjectHelper;
65+
$this->directoryData = $directoryData;
5866
}
5967

6068
/**
@@ -102,6 +110,13 @@ public function validateData(array $addressData): void
102110
$attributes = $this->getAllowedAddressAttributes->execute();
103111
$errorInput = [];
104112

113+
//Add error for empty postcode with country with no optional ZIP
114+
if (!$this->directoryData->isZipCodeOptional($addressData['country_id'])
115+
&& (!isset($addressData['postcode']) || empty($addressData['postcode']))
116+
) {
117+
$errorInput[] = 'postcode';
118+
}
119+
105120
foreach ($attributes as $attributeName => $attributeInfo) {
106121
if ($attributeInfo->getIsRequired()
107122
&& (!isset($addressData[$attributeName]) || empty($addressData[$attributeName]))

0 commit comments

Comments
 (0)