Skip to content

Commit a9d69c4

Browse files
authored
ENGCOM-4242: [ForwardPort] #18896 Add Mexico Regions #21180
2 parents 769604a + 482dda5 commit a9d69c4

File tree

4 files changed

+162
-12
lines changed

4 files changed

+162
-12
lines changed

app/code/Magento/Directory/Setup/Patch/Data/AddDataForIndia.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
use Magento\Framework\Setup\Patch\PatchVersionInterface;
1414

1515
/**
16-
* Class AddDataForIndia
17-
* @package Magento\Directory\Setup\Patch\Data
16+
* Add Regions for India.
1817
*/
1918
class AddDataForIndia implements DataPatchInterface, PatchVersionInterface
2019
{
@@ -29,7 +28,7 @@ class AddDataForIndia implements DataPatchInterface, PatchVersionInterface
2928
private $dataInstallerFactory;
3029

3130
/**
32-
* AddDataForCroatia constructor.
31+
* AddDataForIndia constructor.
3332
*
3433
* @param ModuleDataSetupInterface $moduleDataSetup
3534
* @param \Magento\Directory\Setup\DataInstallerFactory $dataInstallerFactory
@@ -43,7 +42,7 @@ public function __construct(
4342
}
4443

4544
/**
46-
* {@inheritdoc}
45+
* @inheritdoc
4746
*/
4847
public function apply()
4948
{
@@ -103,7 +102,7 @@ private function getDataForIndia()
103102
}
104103

105104
/**
106-
* {@inheritdoc}
105+
* @inheritdoc
107106
*/
108107
public static function getDependencies()
109108
{
@@ -113,15 +112,15 @@ public static function getDependencies()
113112
}
114113

115114
/**
116-
* {@inheritdoc}
115+
* @inheritdoc
117116
*/
118117
public static function getVersion()
119118
{
120119
return '2.0.2';
121120
}
122121

123122
/**
124-
* {@inheritdoc}
123+
* @inheritdoc
125124
*/
126125
public function getAliases()
127126
{
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
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+
use Magento\Framework\Setup\Patch\PatchVersionInterface;
15+
16+
/**
17+
* Adds Mexican States
18+
*/
19+
class AddDataForMexico implements DataPatchInterface, PatchVersionInterface
20+
{
21+
/**
22+
* @var ModuleDataSetupInterface
23+
*/
24+
private $moduleDataSetup;
25+
26+
/**
27+
* @var \Magento\Directory\Setup\DataInstallerFactory
28+
*/
29+
private $dataInstallerFactory;
30+
31+
/**
32+
* @param ModuleDataSetupInterface $moduleDataSetup
33+
* @param \Magento\Directory\Setup\DataInstallerFactory $dataInstallerFactory
34+
*/
35+
public function __construct(
36+
ModuleDataSetupInterface $moduleDataSetup,
37+
\Magento\Directory\Setup\DataInstallerFactory $dataInstallerFactory
38+
) {
39+
$this->moduleDataSetup = $moduleDataSetup;
40+
$this->dataInstallerFactory = $dataInstallerFactory;
41+
}
42+
43+
/**
44+
* @inheritdoc
45+
*/
46+
public function apply()
47+
{
48+
/** @var DataInstaller $dataInstaller */
49+
$dataInstaller = $this->dataInstallerFactory->create();
50+
$dataInstaller->addCountryRegions(
51+
$this->moduleDataSetup->getConnection(),
52+
$this->getDataForMexico()
53+
);
54+
}
55+
56+
/**
57+
* Mexican states data.
58+
*
59+
* @return array
60+
*/
61+
private function getDataForMexico()
62+
{
63+
return [
64+
['MX', 'AGU', 'Aguascalientes'],
65+
['MX', 'BCN', 'Baja California'],
66+
['MX', 'BCS', 'Baja California Sur'],
67+
['MX', 'CAM', 'Campeche'],
68+
['MX', 'CHP', 'Chiapas'],
69+
['MX', 'CHH', 'Chihuahua'],
70+
['MX', 'CMX', 'Ciudad de México'],
71+
['MX', 'COA', 'Coahuila'],
72+
['MX', 'COL', 'Colima'],
73+
['MX', 'DUR', 'Durango'],
74+
['MX', 'MEX', 'Estado de México'],
75+
['MX', 'GUA', 'Guanajuato'],
76+
['MX', 'GRO', 'Guerrero'],
77+
['MX', 'HID', 'Hidalgo'],
78+
['MX', 'JAL', 'Jalisco'],
79+
['MX', 'MIC', 'Michoacán'],
80+
['MX', 'MOR', 'Morelos'],
81+
['MX', 'NAY', 'Nayarit'],
82+
['MX', 'NLE', 'Nuevo León'],
83+
['MX', 'OAX', 'Oaxaca'],
84+
['MX', 'PUE', 'Puebla'],
85+
['MX', 'QUE', 'Querétaro'],
86+
['MX', 'ROO', 'Quintana Roo'],
87+
['MX', 'SLP', 'San Luis Potosí'],
88+
['MX', 'SIN', 'Sinaloa'],
89+
['MX', 'SON', 'Sonora'],
90+
['MX', 'TAB', 'Tabasco'],
91+
['MX', 'TAM', 'Tamaulipas'],
92+
['MX', 'TLA', 'Tlaxcala'],
93+
['MX', 'VER', 'Veracruz'],
94+
['MX', 'YUC', 'Yucatán'],
95+
['MX', 'ZAC', 'Zacatecas']
96+
];
97+
}
98+
99+
/**
100+
* @inheritdoc
101+
*/
102+
public static function getDependencies()
103+
{
104+
return [
105+
InitializeDirectoryData::class,
106+
AddDataForAustralia::class,
107+
AddDataForCroatia::class,
108+
AddDataForIndia::class,
109+
];
110+
}
111+
112+
/**
113+
* @inheritdoc
114+
*/
115+
public static function getVersion()
116+
{
117+
return '2.0.4';
118+
}
119+
120+
/**
121+
* @inheritdoc
122+
*/
123+
public function getAliases()
124+
{
125+
return [];
126+
}
127+
}

dev/tests/functional/lib/Magento/Mtf/Client/Element/ConditionsElement.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ protected function addSingleCondition($condition, ElementInterface $context)
265265
$this->addCondition($condition['type'], $context);
266266
$createdCondition = $context->find($this->created, Locator::SELECTOR_XPATH);
267267
$this->waitForCondition($createdCondition);
268-
$this->fillCondition($condition['rules'], $createdCondition);
268+
$this->fillCondition($condition['rules'], $createdCondition, $condition['type']);
269269
}
270270

271271
/**
@@ -306,13 +306,14 @@ protected function addCondition($type, ElementInterface $context)
306306
*
307307
* @param array $rules
308308
* @param ElementInterface $element
309+
* @param string|null $type
309310
* @return void
310311
* @throws \Exception
311312
*
312313
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
313314
* @SuppressWarnings(PHPMD.NPathComplexity)
314315
*/
315-
protected function fillCondition(array $rules, ElementInterface $element)
316+
protected function fillCondition(array $rules, ElementInterface $element, $type = null)
316317
{
317318
$this->resetKeyParam();
318319
foreach ($rules as $rule) {
@@ -333,7 +334,7 @@ protected function fillCondition(array $rules, ElementInterface $element)
333334

334335
if ($this->fillGrid($rule, $param)) {
335336
$isSet = true;
336-
} elseif ($this->fillSelect($rule, $param)) {
337+
} elseif ($this->fillSelect($rule, $param, $type)) {
337338
$isSet = true;
338339
} elseif ($this->fillText($rule, $param)) {
339340
$isSet = true;
@@ -390,11 +391,15 @@ protected function fillGrid($rule, ElementInterface $param)
390391
*
391392
* @param string $rule
392393
* @param ElementInterface $param
394+
* @param string|null $type
393395
* @return bool
394396
*/
395-
protected function fillSelect($rule, ElementInterface $param)
397+
protected function fillSelect($rule, ElementInterface $param, $type = null)
396398
{
397-
$value = $param->find('select', Locator::SELECTOR_TAG_NAME, 'select');
399+
//Avoid confusion between regions like: "Baja California" and "California".
400+
$value = strpos($type, 'State/Province') === false
401+
? $param->find('select', Locator::SELECTOR_TAG_NAME, 'select')
402+
: $param->find('select', Locator::SELECTOR_TAG_NAME, 'selectstate');
398403
if ($value->isVisible()) {
399404
$value->setValue($rule);
400405
$this->click();
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Mtf\Client\Element;
9+
10+
/**
11+
* @inheritdoc
12+
*/
13+
class SelectstateElement extends SelectElement
14+
{
15+
/**
16+
* @inheritdoc
17+
*/
18+
protected $optionByValue = './/option[normalize-space(.)=%s]';
19+
}

0 commit comments

Comments
 (0)