Skip to content

Commit c12029b

Browse files
committed
Merge remote-tracking branch 'magento-mpi/MC-19870' into MPI-PR
2 parents 31c17dc + b300c94 commit c12029b

File tree

3 files changed

+183
-0
lines changed

3 files changed

+183
-0
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,21 @@
254254
<data key="state">Côtes-d'Armor</data>
255255
<data key="postcode">12345</data>
256256
</entity>
257+
<entity name="updateCustomerChinaAddress" type="address">
258+
<data key="firstname">Xian</data>
259+
<data key="lastname">Shai</data>
260+
<data key="company">Hunan Fenmian</data>
261+
<data key="telephone">+86 851 8410 4337</data>
262+
<array key="street">
263+
<item>Nanyuan Rd, Wudang</item>
264+
<item>Hunan Fenmian</item>
265+
</array>
266+
<data key="country_id">CN</data>
267+
<data key="country">China</data>
268+
<data key="city">Guiyang</data>
269+
<data key="state">Guizhou Sheng</data>
270+
<data key="postcode">550002</data>
271+
</entity>
257272
<entity name="updateCustomerNoXSSInjection" type="address">
258273
<data key="firstname">Jany</data>
259274
<data key="lastname">Doe</data>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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="StorefrontUpdateCustomerAddressChinaTest">
12+
<annotations>
13+
<stories value="Update Regions list for China country"/>
14+
<title value="Update customer address on storefront with china address"/>
15+
<description value="Update customer address on storefront with china address and verify you can select a region"/>
16+
<testCaseId value="MC-20234"/>
17+
<severity value="AVERAGE"/>
18+
<group value="customer"/>
19+
</annotations>
20+
21+
<before>
22+
<actionGroup ref = "LoginAsAdmin" stepKey="loginAsAdmin"/>
23+
<actionGroup ref="SignUpNewUserFromStorefrontActionGroup" stepKey="SignUpNewUser">
24+
<argument name="Customer" value="CustomerEntityOne"/>
25+
</actionGroup>
26+
</before>
27+
<after>
28+
<actionGroup ref="DeleteCustomerByEmailActionGroup" stepKey="deleteNewUser">
29+
<argument name="email" value="{{CustomerEntityOne.email}}"/>
30+
</actionGroup>
31+
<actionGroup ref="logout" stepKey="logout"/>
32+
</after>
33+
34+
<!--Update customer address in storefront-->
35+
<actionGroup ref="EnterCustomerAddressInfo" stepKey="enterAddress">
36+
<argument name="Address" value="updateCustomerChinaAddress"/>
37+
</actionGroup>
38+
<!--Verify customer address save success message-->
39+
<see selector="{{AdminCustomerMessagesSection.successMessage}}" userInput="You saved the address." stepKey="seeAssertCustomerAddressSuccessSaveMessage"/>
40+
41+
<!--Verify customer default billing address-->
42+
<actionGroup ref="VerifyCustomerBillingAddressWithState" stepKey="verifyBillingAddress">
43+
<argument name="address" value="updateCustomerChinaAddress"/>
44+
</actionGroup>
45+
46+
<!--Verify customer default shipping address-->
47+
<actionGroup ref="VerifyCustomerShippingAddressWithState" stepKey="verifyShippingAddress">
48+
<argument name="address" value="updateCustomerChinaAddress"/>
49+
</actionGroup>
50+
</test>
51+
</tests>
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Directory\Setup\Patch\Data;
10+
11+
use Magento\Directory\Setup\DataInstaller;
12+
use Magento\Framework\Setup\ModuleDataSetupInterface;
13+
use Magento\Framework\Setup\Patch\DataPatchInterface;
14+
15+
/**
16+
* Add China States
17+
*/
18+
class AddDataForChina implements DataPatchInterface
19+
{
20+
/**
21+
* @var ModuleDataSetupInterface
22+
*/
23+
private $moduleDataSetup;
24+
25+
/**
26+
* @var \Magento\Directory\Setup\DataInstallerFactory
27+
*/
28+
private $dataInstallerFactory;
29+
30+
/**
31+
* @param ModuleDataSetupInterface $moduleDataSetup
32+
* @param \Magento\Directory\Setup\DataInstallerFactory $dataInstallerFactory
33+
*/
34+
public function __construct(
35+
ModuleDataSetupInterface $moduleDataSetup,
36+
\Magento\Directory\Setup\DataInstallerFactory $dataInstallerFactory
37+
) {
38+
$this->moduleDataSetup = $moduleDataSetup;
39+
$this->dataInstallerFactory = $dataInstallerFactory;
40+
}
41+
42+
/**
43+
* @inheritdoc
44+
*/
45+
public function apply()
46+
{
47+
/** @var DataInstaller $dataInstaller */
48+
$dataInstaller = $this->dataInstallerFactory->create();
49+
$dataInstaller->addCountryRegions(
50+
$this->moduleDataSetup->getConnection(),
51+
$this->getDataForChina()
52+
);
53+
}
54+
55+
/**
56+
* China states data.
57+
*
58+
* @return array
59+
*/
60+
private function getDataForChina()
61+
{
62+
return [
63+
['CN', 'CN-AH', 'Anhui Sheng'],
64+
['CN', 'CN-BJ', 'Beijing Shi'],
65+
['CN', 'CN-CQ', 'Chongqing Shi'],
66+
['CN', 'CN-FJ', 'Fujian Sheng'],
67+
['CN', 'CN-GS', 'Gansu Sheng'],
68+
['CN', 'CN-GD', 'Guangdong Sheng'],
69+
['CN', 'CN-GX', 'Guangxi Zhuangzu Zizhiqu'],
70+
['CN', 'CN-GZ', 'Guizhou Sheng'],
71+
['CN', 'CN-HI', 'Hainan Sheng'],
72+
['CN', 'CN-HE', 'Hebei Sheng'],
73+
['CN', 'CN-HL', 'Heilongjiang Sheng'],
74+
['CN', 'CN-HA', 'Henan Sheng'],
75+
['CN', 'CN-HK', 'Hong Kong SAR'],
76+
['CN', 'CN-HB', 'Hubei Sheng'],
77+
['CN', 'CN-HN', 'Hunan Sheng'],
78+
['CN', 'CN-JS', 'Jiangsu Sheng'],
79+
['CN', 'CN-JX', 'Jiangxi Sheng'],
80+
['CN', 'CN-JL', 'Jilin Sheng'],
81+
['CN', 'CN-LN', 'Liaoning Sheng'],
82+
['CN', 'CN-MO', 'Macao SAR'],
83+
['CN', 'CN-NM', 'Nei Mongol Zizhiqu'],
84+
['CN', 'CN-NX', 'Ningxia Huizi Zizhiqu'],
85+
['CN', 'CN-QH', 'Qinghai Sheng'],
86+
['CN', 'CN-SN', 'Shaanxi Sheng'],
87+
['CN', 'CN-SD', 'Shandong Sheng'],
88+
['CN', 'CN-SH', 'Shanghai Shi'],
89+
['CN', 'CN-SX', 'Shanxi Sheng'],
90+
['CN', 'CN-SC', 'Sichuan Sheng'],
91+
['CN', 'CN-TW', 'Taiwan Sheng'],
92+
['CN', 'CN-TJ', 'Tianjin Shi'],
93+
['CN', 'CN-XJ', 'Xinjiang Uygur Zizhiqu'],
94+
['CN', 'CN-XZ', 'Xizang Zizhiqu'],
95+
['CN', 'CN-YN', 'Yunnan Sheng'],
96+
['CN', 'CN-ZJ', 'Zhejiang Sheng'],
97+
];
98+
}
99+
100+
/**
101+
* @inheritdoc
102+
*/
103+
public static function getDependencies()
104+
{
105+
return [
106+
InitializeDirectoryData::class,
107+
];
108+
}
109+
110+
/**
111+
* @inheritdoc
112+
*/
113+
public function getAliases()
114+
{
115+
return [];
116+
}
117+
}

0 commit comments

Comments
 (0)