Skip to content

Commit ca26034

Browse files
committed
Merge remote-tracking branch 'git-33841/feature-ukraine-regions' into 33841_feature-ukraine-regions
2 parents f00af58 + 27eb991 commit ca26034

File tree

5 files changed

+131
-16
lines changed

5 files changed

+131
-16
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
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\Directory\Setup\Patch\Data;
9+
10+
use Magento\Directory\Setup\DataInstaller;
11+
use Magento\Directory\Setup\DataInstallerFactory;
12+
use Magento\Framework\Setup\ModuleDataSetupInterface;
13+
use Magento\Framework\Setup\Patch\DataPatchInterface;
14+
15+
/**
16+
* Add Ukraine Regions
17+
*/
18+
class AddDataForUkraine implements DataPatchInterface
19+
{
20+
/**
21+
* @var ModuleDataSetupInterface
22+
*/
23+
private $moduleDataSetup;
24+
25+
/**
26+
* @var DataInstallerFactory
27+
*/
28+
private $dataInstallerFactory;
29+
30+
/**
31+
* @param ModuleDataSetupInterface $moduleDataSetup
32+
* @param DataInstallerFactory $dataInstallerFactory
33+
*/
34+
public function __construct(
35+
ModuleDataSetupInterface $moduleDataSetup,
36+
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->getDataForUkraine()
52+
);
53+
54+
return $this;
55+
}
56+
57+
/**
58+
* Ukraine regions data.
59+
*
60+
* @return array
61+
*/
62+
private function getDataForUkraine(): array
63+
{
64+
return [
65+
['UA', 'UA-71', 'Cherkaska oblast'],
66+
['UA', 'UA-74', 'Chernihivska oblast'],
67+
['UA', 'UA-77', 'Chernivetska oblast'],
68+
['UA', 'UA-12', 'Dnipropetrovska oblast'],
69+
['UA', 'UA-14', 'Donetska oblast'],
70+
['UA', 'UA-26', 'Ivano-Frankivska oblast'],
71+
['UA', 'UA-63', 'Kharkivska oblast'],
72+
['UA', 'UA-65', 'Khersonska oblast'],
73+
['UA', 'UA-68', 'Khmelnytska oblast'],
74+
['UA', 'UA-35', 'Kirovohradska oblast'],
75+
['UA', 'UA-32', 'Kyivska oblast'],
76+
['UA', 'UA-09', 'Luhanska oblast'],
77+
['UA', 'UA-46', 'Lvivska oblast'],
78+
['UA', 'UA-48', 'Mykolaivska oblast'],
79+
['UA', 'UA-51', 'Odeska oblast'],
80+
['UA', 'UA-53', 'Poltavska oblast'],
81+
['UA', 'UA-56', 'Rivnenska oblast'],
82+
['UA', 'UA-59', 'Sumska oblast'],
83+
['UA', 'UA-61', 'Ternopilska oblast'],
84+
['UA', 'UA-05', 'Vinnytska oblast'],
85+
['UA', 'UA-07', 'Volynska oblast'],
86+
['UA', 'UA-21', 'Zakarpatska oblast'],
87+
['UA', 'UA-23', 'Zaporizka oblast'],
88+
['UA', 'UA-18', 'Zhytomyrska oblast'],
89+
['UA', 'UA-43', 'Avtonomna Respublika Krym'],
90+
['UA', 'UA-30', 'Kyiv'],
91+
['UA', 'UA-40', 'Sevastopol'],
92+
];
93+
}
94+
95+
/**
96+
* @inheritdoc
97+
*/
98+
public static function getDependencies()
99+
{
100+
return [
101+
InitializeDirectoryData::class,
102+
];
103+
}
104+
105+
/**
106+
* @inheritdoc
107+
*/
108+
public function getAliases()
109+
{
110+
return [];
111+
}
112+
}

dev/tests/api-functional/testsuite/Magento/GraphQl/Customer/CreateCustomerAddressTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,8 @@ public function testCreateCustomerAddressWithRedundantStreetLine()
466466
public function testCreateCustomerAddressWithOptionalZipCode()
467467
{
468468
$newAddress = [
469-
'country_code' => 'UA',
469+
'country_code' => 'VA',
470+
'postcode' => '00120',
470471
'street' => ['Line 1 Street', 'Line 2'],
471472
'company' => 'Company name',
472473
'telephone' => '123456789',
@@ -487,6 +488,7 @@ public function testCreateCustomerAddressWithOptionalZipCode()
487488
mutation {
488489
createCustomerAddress(input: {
489490
country_code: {$newAddress['country_code']}
491+
postcode: "{$newAddress['postcode']}"
490492
street: ["{$newAddress['street'][0]}","{$newAddress['street'][1]}"]
491493
company: "{$newAddress['company']}"
492494
telephone: "{$newAddress['telephone']}"

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetBillingAddressOnCartTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,13 +1211,13 @@ public function testSetBillingAddressesWithNotRequiredRegion()
12111211
cart_id: "$maskedQuoteId"
12121212
billing_address: {
12131213
address: {
1214-
firstname: "Vasyl"
1214+
firstname: "John"
12151215
lastname: "Doe"
1216-
street: ["1 Svobody"]
1217-
city: "Lviv"
1218-
region: "Lviv"
1219-
postcode: "00000"
1220-
country_code: "UA"
1216+
street: ["Via della Posta"]
1217+
city: "Vatican City"
1218+
region: "Vatican City"
1219+
postcode: "00120"
1220+
country_code: "VA"
12211221
telephone: "555-555-55-55"
12221222
}
12231223
}
@@ -1239,8 +1239,8 @@ public function testSetBillingAddressesWithNotRequiredRegion()
12391239
$response = $this->graphQlMutation($query, [], '', $this->getHeaderMap());
12401240
self::assertArrayHasKey('cart', $response['setBillingAddressOnCart']);
12411241
$cartResponse = $response['setBillingAddressOnCart']['cart'];
1242-
self::assertEquals('UA', $cartResponse['billing_address']['country']['code']);
1243-
self::assertEquals('Lviv', $cartResponse['billing_address']['region']['label']);
1242+
self::assertEquals('VA', $cartResponse['billing_address']['country']['code']);
1243+
self::assertEquals('Vatican City', $cartResponse['billing_address']['region']['label']);
12441244
}
12451245

12461246
/**

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/SetShippingAddressOnCartTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -947,11 +947,11 @@ public function testSetShippingAddressesWithNotRequiredRegion()
947947
address: {
948948
firstname: "Vasyl"
949949
lastname: "Doe"
950-
street: ["1 Svobody"]
951-
city: "Lviv"
952-
region: "Lviv"
953-
postcode: "00000"
954-
country_code: "UA"
950+
street: ["Via della Posta"]
951+
city: "Vatican City"
952+
region: "Vatican City"
953+
postcode: "00120"
954+
country_code: "VA"
955955
telephone: "555-555-55-55"
956956
}
957957
}
@@ -974,8 +974,8 @@ public function testSetShippingAddressesWithNotRequiredRegion()
974974
$response = $this->graphQlMutation($query, [], '', $this->getHeaderMap());
975975
self::assertArrayHasKey('cart', $response['setShippingAddressesOnCart']);
976976
$cartResponse = $response['setShippingAddressesOnCart']['cart'];
977-
self::assertEquals('UA', $cartResponse['shipping_addresses'][0]['country']['code']);
978-
self::assertEquals('Lviv', $cartResponse['shipping_addresses'][0]['region']['label']);
977+
self::assertEquals('VA', $cartResponse['shipping_addresses'][0]['country']['code']);
978+
self::assertEquals('Vatican City', $cartResponse['shipping_addresses'][0]['region']['label']);
979979
}
980980

981981
/**

dev/tests/integration/testsuite/Magento/Directory/Model/RegionTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ public function getCountryIdDataProvider(): array
9090
['countryId' => 'DK'],
9191
['countryId' => 'AL'],
9292
['countryId' => 'BY'],
93+
['countryId' => 'UA'],
9394
];
9495
}
9596

0 commit comments

Comments
 (0)