From f0c7eeaa69f2cea198fb62889e8ad28d8d7e0872 Mon Sep 17 00:00:00 2001 From: Dmitry Furs Date: Thu, 26 Aug 2021 17:51:32 +0300 Subject: [PATCH 1/3] Add regions for Belarus --- .../Setup/Patch/Data/AddDataForBelarus.php | 90 +++++++++++++++++++ .../Magento/Directory/Model/RegionTest.php | 5 +- 2 files changed, 93 insertions(+), 2 deletions(-) create mode 100644 app/code/Magento/Directory/Setup/Patch/Data/AddDataForBelarus.php diff --git a/app/code/Magento/Directory/Setup/Patch/Data/AddDataForBelarus.php b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForBelarus.php new file mode 100644 index 0000000000000..d2e46d921e9d8 --- /dev/null +++ b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForBelarus.php @@ -0,0 +1,90 @@ +moduleDataSetup = $moduleDataSetup; + $this->dataInstallerFactory = $dataInstallerFactory; + } + + /** + * @inheritdoc + */ + public function apply() + { + /** @var DataInstaller $dataInstaller */ + $dataInstaller = $this->dataInstallerFactory->create(); + $dataInstaller->addCountryRegions( + $this->moduleDataSetup->getConnection(), + $this->getDataForBelarus() + ); + } + + /** + * Belarus regions data. + * + * @return array + */ + private function getDataForBelarus(): array + { + return [ + ['BY', 'BY-BR', 'Bresckaja voblasć'], + ['BY', 'BY-HO', 'Homieĺskaja voblasć'], + ['BY', 'BY-HM', 'Horad Minsk'], + ['BY', 'BY-HR', 'Hrodzienskaja voblasć'], + ['BY', 'BY-MA', 'Mahilioŭskaja voblasć'], + ['BY', 'BY-MI', 'Minskaja voblasć'], + ['BY', 'BY-VI', 'Viciebskaja voblasć'], + ]; + } + + /** + * @inheritdoc + */ + public static function getDependencies() + { + return [ + InitializeDirectoryData::class, + ]; + } + + /** + * @inheritdoc + */ + public function getAliases() + { + return []; + } +} diff --git a/dev/tests/integration/testsuite/Magento/Directory/Model/RegionTest.php b/dev/tests/integration/testsuite/Magento/Directory/Model/RegionTest.php index d90131948d9bb..dc29c63dedbc8 100644 --- a/dev/tests/integration/testsuite/Magento/Directory/Model/RegionTest.php +++ b/dev/tests/integration/testsuite/Magento/Directory/Model/RegionTest.php @@ -44,7 +44,7 @@ public function testCountryHasRegions($countryId) * * @return array */ - public function getCountryIdDataProvider():array + public function getCountryIdDataProvider(): array { return [ ['countryId' => 'US'], @@ -72,7 +72,8 @@ public function getCountryIdDataProvider():array ['countryId' => 'SE'], ['countryId' => 'GR'], ['countryId' => 'DK'], - ['countryId' => 'AL'] + ['countryId' => 'AL'], + ['countryId' => 'BY'], ]; } } From 9d4178068a8ca1aafda737b67a68cdfcfb1ce889 Mon Sep 17 00:00:00 2001 From: Dmitry Furs Date: Fri, 27 Aug 2021 13:50:03 +0300 Subject: [PATCH 2/3] Add regions for Belarus --- .../Setup/Patch/Data/AddDataForBelarus.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/Directory/Setup/Patch/Data/AddDataForBelarus.php b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForBelarus.php index d2e46d921e9d8..b89df2573ff48 100644 --- a/app/code/Magento/Directory/Setup/Patch/Data/AddDataForBelarus.php +++ b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForBelarus.php @@ -40,9 +40,11 @@ public function __construct( } /** - * @inheritdoc + * Add country-region data for Belarus. + * + * @return $this */ - public function apply() + public function apply(): DataPatchInterface { /** @var DataInstaller $dataInstaller */ $dataInstaller = $this->dataInstallerFactory->create(); @@ -50,6 +52,8 @@ public function apply() $this->moduleDataSetup->getConnection(), $this->getDataForBelarus() ); + + return $this; } /** @@ -71,9 +75,9 @@ private function getDataForBelarus(): array } /** - * @inheritdoc + * {@inheritdoc} */ - public static function getDependencies() + public static function getDependencies(): array { return [ InitializeDirectoryData::class, @@ -81,9 +85,9 @@ public static function getDependencies() } /** - * @inheritdoc + * {@inheritdoc} */ - public function getAliases() + public function getAliases(): array { return []; } From 9233d61fa5e23cc9a4f3c7d341d4be2dcf3bcaf7 Mon Sep 17 00:00:00 2001 From: Dmitry Furs Date: Fri, 27 Aug 2021 14:20:40 +0300 Subject: [PATCH 3/3] Add regions for Belarus --- .../Magento/Directory/Setup/Patch/Data/AddDataForBelarus.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/code/Magento/Directory/Setup/Patch/Data/AddDataForBelarus.php b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForBelarus.php index b89df2573ff48..58cf48b71d613 100644 --- a/app/code/Magento/Directory/Setup/Patch/Data/AddDataForBelarus.php +++ b/app/code/Magento/Directory/Setup/Patch/Data/AddDataForBelarus.php @@ -76,6 +76,8 @@ private function getDataForBelarus(): array /** * {@inheritdoc} + * + * @return string[] */ public static function getDependencies(): array { @@ -86,6 +88,8 @@ public static function getDependencies(): array /** * {@inheritdoc} + * + * @return string[] */ public function getAliases(): array {