Skip to content

Commit 47bdc48

Browse files
authored
ENGCOM-9204: Add regions for Belarus #33922
2 parents cc11f1c + d1df382 commit 47bdc48

File tree

2 files changed

+101
-2
lines changed

2 files changed

+101
-2
lines changed
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
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 Regions for Belarus.
17+
*/
18+
class AddDataForBelarus 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+
* Add country-region data for Belarus.
44+
*
45+
* @return $this
46+
*/
47+
public function apply(): DataPatchInterface
48+
{
49+
/** @var DataInstaller $dataInstaller */
50+
$dataInstaller = $this->dataInstallerFactory->create();
51+
$dataInstaller->addCountryRegions(
52+
$this->moduleDataSetup->getConnection(),
53+
$this->getDataForBelarus()
54+
);
55+
56+
return $this;
57+
}
58+
59+
/**
60+
* Belarus regions data.
61+
*
62+
* @return array
63+
*/
64+
private function getDataForBelarus(): array
65+
{
66+
return [
67+
['BY', 'BY-BR', 'Bresckaja voblasć'],
68+
['BY', 'BY-HO', 'Homieĺskaja voblasć'],
69+
['BY', 'BY-HM', 'Horad Minsk'],
70+
['BY', 'BY-HR', 'Hrodzienskaja voblasć'],
71+
['BY', 'BY-MA', 'Mahilioŭskaja voblasć'],
72+
['BY', 'BY-MI', 'Minskaja voblasć'],
73+
['BY', 'BY-VI', 'Viciebskaja voblasć'],
74+
];
75+
}
76+
77+
/**
78+
* {@inheritdoc}
79+
*
80+
* @return string[]
81+
*/
82+
public static function getDependencies(): array
83+
{
84+
return [
85+
InitializeDirectoryData::class,
86+
];
87+
}
88+
89+
/**
90+
* {@inheritdoc}
91+
*
92+
* @return string[]
93+
*/
94+
public function getAliases(): array
95+
{
96+
return [];
97+
}
98+
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function testCountryHasRegions(string $countryId): void
6060
*
6161
* @return array
6262
*/
63-
public function getCountryIdDataProvider():array
63+
public function getCountryIdDataProvider(): array
6464
{
6565
return [
6666
['countryId' => 'US'],
@@ -88,7 +88,8 @@ public function getCountryIdDataProvider():array
8888
['countryId' => 'SE'],
8989
['countryId' => 'GR'],
9090
['countryId' => 'DK'],
91-
['countryId' => 'AL']
91+
['countryId' => 'AL'],
92+
['countryId' => 'BY'],
9293
];
9394
}
9495

0 commit comments

Comments
 (0)