Skip to content

Commit 0414bb2

Browse files
authored
Merge branch '2.4-develop' into comm_voted_v2
2 parents e630216 + ab61383 commit 0414bb2

File tree

10 files changed

+237
-6
lines changed

10 files changed

+237
-6
lines changed

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

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
declare(strict_types=1);
7+
68
namespace Magento\Customer\Model\Config\Backend\Show;
79

10+
use Magento\Config\App\Config\Source\ModularConfigSource;
811
use Magento\Eav\Model\Entity\Attribute\AbstractAttribute;
912
use Magento\Framework\App\Config\ScopeConfigInterface;
13+
use Magento\Framework\App\ObjectManager;
1014

1115
/**
1216
* Customer Show Customer Model
1317
*
1418
* @author Magento Core Team <core@magentocommerce.com>
19+
* @SuppressWarnings(PHPMD.UnusedPrivateField)
1520
*/
1621
class Customer extends \Magento\Framework\App\Config\Value
1722
{
@@ -32,6 +37,11 @@ class Customer extends \Magento\Framework\App\Config\Value
3237
*/
3338
private $telephoneShowDefaultValue = 'req';
3439

40+
/**
41+
* @var ModularConfigSource
42+
*/
43+
private $configSource;
44+
3545
/**
3646
* @var array
3747
*/
@@ -52,6 +62,8 @@ class Customer extends \Magento\Framework\App\Config\Value
5262
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
5363
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
5464
* @param array $data
65+
* @param ModularConfigSource|null $configSource
66+
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
5567
*/
5668
public function __construct(
5769
\Magento\Framework\Model\Context $context,
@@ -62,11 +74,13 @@ public function __construct(
6274
\Magento\Eav\Model\Config $eavConfig,
6375
\Magento\Framework\Model\ResourceModel\AbstractResource $resource = null,
6476
\Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null,
65-
array $data = []
77+
array $data = [],
78+
ModularConfigSource $configSource = null
6679
) {
6780
$this->_eavConfig = $eavConfig;
6881
parent::__construct($context, $registry, $config, $cacheTypeList, $resource, $resourceCollection, $data);
6982
$this->storeManager = $storeManager;
83+
$this->configSource = $configSource ?: ObjectManager::getInstance()->get(ModularConfigSource::class);
7084
}
7185

7286
/**
@@ -140,7 +154,8 @@ public function afterDelete()
140154
$attributeObject->save();
141155
}
142156
} elseif ($this->getScope() == ScopeConfigInterface::SCOPE_TYPE_DEFAULT) {
143-
$valueConfig = $this->getValueConfig($this->telephoneShowDefaultValue);
157+
$defaultValue = $this->configSource->get(ScopeConfigInterface::SCOPE_TYPE_DEFAULT . '/' . $this->getPath());
158+
$valueConfig = $this->getValueConfig($defaultValue === [] ? '' : $defaultValue);
144159
foreach ($this->_getAttributeObjects() as $attributeObject) {
145160
$attributeObject->setData('is_required', $valueConfig['is_required']);
146161
$attributeObject->setData('is_visible', $valueConfig['is_visible']);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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="AdminCustomerShowCompanyActionGroup">
12+
<annotations>
13+
<description>Goes to the customer configuration. Set "Show Company" with provided value.</description>
14+
</annotations>
15+
<arguments>
16+
<argument name="value" type="string" defaultValue="{{ShowCompany.optional}}"/>
17+
</arguments>
18+
<amOnPage url="{{AdminCustomerConfigPage.url('#customer_address-link')}}" stepKey="openCustomerConfigPage"/>
19+
<waitForPageLoad stepKey="waitCustomerConfigPage"/>
20+
<scrollTo selector="{{AdminCustomerConfigSection.showCompany}}" x="0" y="-100" stepKey="scrollToShowCompany"/>
21+
<uncheckOption selector="{{AdminCustomerConfigSection.showCompanyInherit}}" stepKey="uncheckUseSystem"/>
22+
<selectOption selector="{{AdminCustomerConfigSection.showCompany}}" userInput="{{value}}" stepKey="fillShowCompany"/>
23+
<click selector="{{AdminMainActionsSection.save}}" stepKey="clickSave"/>
24+
<seeElement selector="{{AdminMessagesSection.success}}" stepKey="seeSuccessMessage"/>
25+
</actionGroup>
26+
</actionGroups>

app/code/Magento/Customer/Test/Mftf/Data/AddressData.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,24 @@
248248
<data key="default_shipping">true</data>
249249
<data key="default_billing">true</data>
250250
</entity>
251+
<entity name="addressNoCompany" type="address">
252+
<data key="company"/>
253+
<data key="firstname">Fn</data>
254+
<data key="lastname">Ln</data>
255+
<array key="street">
256+
<item>7700 West Parmer Lane</item>
257+
</array>
258+
<data key="city">Austin</data>
259+
<data key="state">Texas</data>
260+
<data key="country_id">US</data>
261+
<data key="country">United States</data>
262+
<data key="postcode">78729</data>
263+
<data key="telephone">512-345-6789</data>
264+
<data key="vat_id">47458714</data>
265+
<data key="default_billing">Yes</data>
266+
<data key="default_shipping">Yes</data>
267+
<requiredEntity type="region">RegionTX</requiredEntity>
268+
</entity>
251269
<entity name="updateCustomerUKAddress" type="address">
252270
<data key="firstname">John</data>
253271
<data key="lastname">Doe</data>

app/code/Magento/Customer/Test/Mftf/Data/AdminCustomerConfigData.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@
1818
<data key="optional">Optional</data>
1919
<data key="required">Required</data>
2020
</entity>
21+
<entity name="ShowCompany">
22+
<data key="no">No</data>
23+
<data key="optional">Optional</data>
24+
<data key="required">Required</data>
25+
</entity>
2126
<entity name="CustomerConfigurationSectionNameAndAddressOptions">
2227
<data key="id">customer_address-head</data>
2328
<data key="title">Name and Address Options</data>

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,7 @@
1515
<element name="showDateOfBirthInherit" type="select" selector="#customer_address_dob_show_inherit"/>
1616
<element name="showTelephone" type="select" selector="#customer_address_telephone_show"/>
1717
<element name="showTelephoneInherit" type="checkbox" selector="#customer_address_telephone_show_inherit"/>
18+
<element name="showCompany" type="select" selector="#customer_address_company_show"/>
19+
<element name="showCompanyInherit" type="select" selector="#customer_address_company_show_inherit"/>
1820
</section>
1921
</sections>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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_company_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 Company" to Required and save in default config scope -->
54+
<actionGroup ref="AdminCustomerShowCompanyActionGroup" stepKey="setShowCompanyRequiredDefaultScope">
55+
<argument name="value" value="{{ShowCompany.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 addresses tab -->
63+
<actionGroup ref="AdminOpenAddressesTabFromCustomerEditPageActionGroup" stepKey="openAddressesTab"/>
64+
<!-- Click "Add New Address" -->
65+
<actionGroup ref="AdminClickAddNewAddressButtonOnCustomerAddressesTabActionGroup" stepKey="clickAddNewAddressButton"/>
66+
<!-- Fill address -->
67+
<actionGroup ref="AdminFillAndSaveCustomerAddressInformationActionGroup" stepKey="fillAndSaveCustomerAddressInformationActionGroup">
68+
<argument name="address" value="US_Address_TX"/>
69+
</actionGroup>
70+
<!-- Assert that the address is successfully added -->
71+
<actionGroup stepKey="saveAndContinue" ref="AdminCustomerSaveAndContinue"/>
72+
73+
<!-- Navigate to customer configuration page -->
74+
<actionGroup ref="AdminNavigateToCustomerConfigurationActionGroup" stepKey="gotoCustomerConfigurationAgain"/>
75+
<!-- Expand "Name and Address Option" section -->
76+
<actionGroup ref="AdminExpandConfigSectionActionGroup" stepKey="expandConfigSectionDefaultScopeAgain">
77+
<argument name="sectionName" value="{{CustomerConfigurationSectionNameAndAddressOptions.title}}"/>
78+
</actionGroup>
79+
<!-- Set "Show Company" to Required and save in default config scope -->
80+
<actionGroup ref="AdminCheckUseSystemValueActionGroup" stepKey="checkCompanyUseSystemValue">
81+
<argument name="rowId" value="row_customer_address_company_show"/>
82+
</actionGroup>
83+
84+
<click selector="{{StoreConfigSection.Save}}" stepKey="saveConfig"/>
85+
<!-- Open the customer edit page -->
86+
<actionGroup ref="AdminOpenCustomerEditPageActionGroup" stepKey="goToCustomerEditPageAgain">
87+
<argument name="customerId" value="$createCustomer.id$"/>
88+
</actionGroup>
89+
<!-- Switch the addresses tab -->
90+
<actionGroup ref="AdminOpenAddressesTabFromCustomerEditPageActionGroup" stepKey="openAddressesTabAgain"/>
91+
<!-- Click "Add New Address" -->
92+
<actionGroup ref="AdminClickAddNewAddressButtonOnCustomerAddressesTabActionGroup" stepKey="clickAddNewAddressButtonAgain"/>
93+
<!-- Fill address -->
94+
<actionGroup ref="AdminFillAndSaveCustomerAddressInformationActionGroup" stepKey="fillAndSaveCustomerAddressInformationActionGroupAgain">
95+
<argument name="address" value="addressNoCompany"/>
96+
</actionGroup>
97+
<!-- Assert that the address is successfully added -->
98+
<actionGroup stepKey="saveAndContinueAgain" ref="AdminCustomerSaveAndContinue"/>
99+
</test>
100+
</tests>

app/code/Magento/Shipping/Test/Mftf/Section/AdminShippingSettingsConfigSection.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,10 @@
1616
<element name="dropdownState" type="checkbox" selector="#row_shipping_origin_region_id select"/>
1717
<element name="systemValuePostcode" type="checkbox" selector="#row_shipping_origin_postcode input[type='checkbox']"/>
1818
<element name="PostcodeValue" type="input" selector="#row_shipping_origin_postcode input[type='text']"/>
19+
<element name="systemValueShippingPolicy" type="checkbox" selector="#row_shipping_shipping_policy_enable_shipping_policy input[type='checkbox']"/>
20+
<element name="shippingPolicyParameters" type="block" selector="#shipping_shipping_policy-head" timeout="30"/>
21+
<element name="shippingPolicyParametersOpened" type="block" selector="#shipping_shipping_policy-head.open" timeout="30"/>
22+
<element name="shippingPolicy" type="block" selector="#row_shipping_shipping_policy_shipping_policy_content"/>
23+
<element name="dropdownShippingPolicy" type="select" selector="#row_shipping_shipping_policy_enable_shipping_policy select"/>
1924
</section>
2025
</sections>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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="AdminCheckShippingPolicyParamsInDifferentScopesTest">
12+
<annotations>
13+
<features value="Shipping"/>
14+
<stories value="Shipping Policy Parameters"/>
15+
<title value="Displaying of Shipping Policy Parameters in different scopes"/>
16+
<description value="Displaying of Shipping Policy Parameters in different scopes"/>
17+
<severity value="AVERAGE"/>
18+
<testCaseId value="AC-7003"/>
19+
<group value="shipping"/>
20+
</annotations>
21+
<before>
22+
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
23+
</before>
24+
<after>
25+
<actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/>
26+
</after>
27+
28+
<amOnPage url="{{AdminShippingSettingsPage.url}}" stepKey="goToAdminShippingPage"/>
29+
<waitForPageLoad stepKey="waitForShippingConfigLoad"/>
30+
<conditionalClick selector="{{AdminShippingSettingsConfigSection.shippingPolicyParameters}}" dependentSelector="{{AdminShippingSettingsConfigSection.shippingPolicyParametersOpened}}" visible="false" stepKey="openShippingPolicySettings"/>
31+
<uncheckOption selector="{{AdminShippingSettingsConfigSection.systemValueShippingPolicy}}" stepKey="disableUseDefaultCondition"/>
32+
<selectOption selector="{{AdminShippingSettingsConfigSection.dropdownShippingPolicy}}" userInput="Yes" stepKey="SelectApplyCustomShippingPolicy"/>
33+
34+
<!-- Save the settings -->
35+
<scrollToTopOfPage stepKey="scrollToTop"/>
36+
<click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="saveChanges"/>
37+
38+
<!--Switch to Store view 1-->
39+
<actionGroup ref="SwitchToTheNewStoreViewActionGroup" stepKey="SwitchNewStoreView">
40+
<argument name="storeViewName" value="{{_defaultStore.name}}"/>
41+
</actionGroup>
42+
<seeElement selector="{{AdminShippingSettingsConfigSection.shippingPolicy}}" stepKey="seeShippingPolicy"/>
43+
44+
<!--Switch to Store view 1-->
45+
<actionGroup ref="SwitchToTheNewStoreViewActionGroup" stepKey="SwitchtoDefaultConfig">
46+
<argument name="storeViewName" value="Default Config"/>
47+
</actionGroup>
48+
49+
<selectOption selector="{{AdminShippingSettingsConfigSection.dropdownShippingPolicy}}" userInput="No" stepKey="SelectApplyCustomShippingPolicy1"/>
50+
51+
<checkOption selector="{{AdminShippingSettingsConfigSection.systemValueShippingPolicy}}" stepKey="enableUseDefaultCondition"/>
52+
<!-- Save the settings -->
53+
<scrollToTopOfPage stepKey="scrollToTop1"/>
54+
<click selector="{{AdminCategoryMainActionsSection.SaveButton}}" stepKey="saveChanges1"/>
55+
56+
<!--Switch to Store view 1-->
57+
<actionGroup ref="SwitchToTheNewStoreViewActionGroup" stepKey="SwitchNewStoreView2">
58+
<argument name="storeViewName" value="{{_defaultStore.name}}"/>
59+
</actionGroup>
60+
<seeElement selector="{{AdminShippingSettingsConfigSection.shippingPolicy}}" stepKey="seeShippingPolicy2"/>
61+
62+
</test>
63+
</tests>

app/code/Magento/Shipping/etc/adminhtml/system.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@
4242
</field>
4343
<field id="shipping_policy_content" translate="label" type="textarea" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1">
4444
<label>Shipping Policy</label>
45-
<depends>
46-
<field id="enable_shipping_policy">1</field>
47-
</depends>
4845
</field>
4946
</group>
5047
</section>

dev/tests/unit/phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
<!-- Optional arguments block; omit it if you want to use default values -->
5858
<arguments>
5959
<!-- Path to config file (default is config/allure.config.php) -->
60-
<string>allure/allure.config.php</string>
60+
<directory>allure/allure.config.php</directory>
6161
</arguments>
6262
</extension>
6363
</extensions>

0 commit comments

Comments
 (0)