Skip to content

Commit a838379

Browse files
AC-6748::Customer attribute and customer address attribute alway require when select 'Use Default' in config-fixed
1 parent b3134de commit a838379

File tree

2 files changed

+93
-2
lines changed

2 files changed

+93
-2
lines changed

app/code/Magento/Customer/Model/Config/Backend/Show/Customer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ public function afterDelete()
154154
$attributeObject->save();
155155
}
156156
} elseif ($this->getScope() == ScopeConfigInterface::SCOPE_TYPE_DEFAULT) {
157-
$defaulValue = $this->configSource->get(ScopeConfigInterface::SCOPE_TYPE_DEFAULT . '/' . $this->getPath());
158-
$valueConfig = $this->getValueConfig($defaulValue === [] ? '' : $defaulValue);
157+
$defaultValue = $this->configSource->get(ScopeConfigInterface::SCOPE_TYPE_DEFAULT . '/' . $this->getPath());
158+
$valueConfig = $this->getValueConfig($defaultValue === [] ? '' : $defaultValue);
159159
foreach ($this->_getAttributeObjects() as $attributeObject) {
160160
$attributeObject->setData('is_required', $valueConfig['is_required']);
161161
$attributeObject->setData('is_visible', $valueConfig['is_visible']);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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="AdminCustomerAttributeChangeUpdateFromRequiredToNoDefaultScopeTest">
12+
<annotations>
13+
<features value="Customer"/>
14+
<stories value="Customer attribute change from required to no"/>
15+
<title value="Admin should be able to save customer after changing attributes from required to no"/>
16+
<description value="Admin should be able to save customer after changing attributes from required to no in default scope"/>
17+
<severity value="CRITICAL"/>
18+
<testCaseId value="AC-6748"/>
19+
<group value="customer"/>
20+
</annotations>
21+
<before>
22+
<!-- Login to admin -->
23+
<actionGroup ref="AdminLoginActionGroup" stepKey="LoginAsAdmin"/>
24+
<!-- Create a customer -->
25+
<createData entity="Simple_US_Customer" stepKey="createCustomer"/>
26+
</before>
27+
<after>
28+
<!-- Navigate to customer configuration page -->
29+
<actionGroup ref="AdminNavigateToCustomerConfigurationActionGroup" stepKey="gotoCustomerConfiguration"/>
30+
<!-- Expand "Name and Address Option" section -->
31+
<actionGroup ref="AdminExpandConfigSectionActionGroup" stepKey="expandConfigSectionDefaultScope">
32+
<argument name="sectionName" value="{{CustomerConfigurationSectionNameAndAddressOptions.title}}"/>
33+
</actionGroup>
34+
35+
<!-- Set "Show Date of Birth" to Required and save in default config scope -->
36+
<actionGroup ref="AdminCheckUseSystemValueActionGroup" stepKey="checkUseSystemValue">
37+
<argument name="rowId" value="row_customer_address_dob_show"/>
38+
</actionGroup>
39+
<click selector="{{StoreConfigSection.Save}}" stepKey="saveConfig"/>
40+
41+
<!-- Delete customer -->
42+
<deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/>
43+
44+
<!-- Logout from admin -->
45+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
46+
</after>
47+
<!-- Navigate to customer configuration page -->
48+
<actionGroup ref="AdminNavigateToCustomerConfigurationActionGroup" stepKey="gotoCustomerConfiguration"/>
49+
<!-- Expand "Name and Address Option" section -->
50+
<actionGroup ref="AdminExpandConfigSectionActionGroup" stepKey="expandConfigSectionDefaultScope">
51+
<argument name="sectionName" value="{{CustomerConfigurationSectionNameAndAddressOptions.title}}"/>
52+
</actionGroup>
53+
<!-- Set "Show Date of Birth" to Required and save in default config scope -->
54+
<actionGroup ref="AdminCustomerShowDateOfBirthActionGroup" stepKey="setShowDateOfBirthRequiredDefaultScope">
55+
<argument name="value" value="{{ShowDateOfBirth.required}}"/>
56+
</actionGroup>
57+
58+
<!-- Open the customer edit page -->
59+
<actionGroup ref="AdminOpenCustomerEditPageActionGroup" stepKey="goToCustomerEditPage">
60+
<argument name="customerId" value="$createCustomer.id$"/>
61+
</actionGroup>
62+
<!-- Switch the information tab -->
63+
<actionGroup ref="AdminOpenAccountInformationTabFromCustomerEditPageActionGroup" stepKey="openInformationTab"/>
64+
<!-- Fill the dob -->
65+
<fillField userInput="{{CustomerEntityOne.dob}}" selector="{{AdminCustomerAccountInformationSection.dateOfBirth}}" stepKey="fillDateOfBirth"/>
66+
<!-- Assert that the address is successfully added -->
67+
<actionGroup stepKey="saveAndContinue" ref="AdminCustomerSaveAndContinue"/>
68+
69+
<!-- Navigate to customer configuration page -->
70+
<actionGroup ref="AdminNavigateToCustomerConfigurationActionGroup" stepKey="gotoCustomerConfigurationAgain"/>
71+
<!-- Expand "Name and Address Option" section -->
72+
<actionGroup ref="AdminExpandConfigSectionActionGroup" stepKey="expandConfigSectionDefaultScopeAgain">
73+
<argument name="sectionName" value="{{CustomerConfigurationSectionNameAndAddressOptions.title}}"/>
74+
</actionGroup>
75+
<!-- Set "Show Date of Birth" to Required and save in default config scope -->
76+
<actionGroup ref="AdminCheckUseSystemValueActionGroup" stepKey="checkUseSystemValue">
77+
<argument name="rowId" value="row_customer_address_dob_show"/>
78+
</actionGroup>
79+
<click selector="{{StoreConfigSection.Save}}" stepKey="saveConfig"/>
80+
<!-- Open the customer edit page -->
81+
<actionGroup ref="AdminOpenCustomerEditPageActionGroup" stepKey="goToCustomerEditPageAgain">
82+
<argument name="customerId" value="$createCustomer.id$"/>
83+
</actionGroup>
84+
<!-- Switch the information tab -->
85+
<actionGroup ref="AdminOpenAccountInformationTabFromCustomerEditPageActionGroup" stepKey="openInformationTabAgain"/>
86+
<!-- Fill the dob -->
87+
<fillField userInput="" selector="{{AdminCustomerAccountInformationSection.dateOfBirth}}" stepKey="fillDateOfBirthAgain"/>
88+
<!-- Assert that the address is successfully added -->
89+
<actionGroup stepKey="saveAndContinueAgain" ref="AdminCustomerSaveAndContinue"/>
90+
</test>
91+
</tests>

0 commit comments

Comments
 (0)