From bd14578eac61df2a52042f63cbf4bbdd6bb21a52 Mon Sep 17 00:00:00 2001 From: "al.kravchuk" Date: Tue, 10 Jul 2018 16:07:02 +0300 Subject: [PATCH 1/2] magento/magento2#?: 'Allowed Countries' - get countries for scope 'default'. - fix 'if' for scope with id 0. --- app/code/Magento/Directory/Model/AllowedCountries.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Directory/Model/AllowedCountries.php b/app/code/Magento/Directory/Model/AllowedCountries.php index 46fa04ba22651..db83e4e8920c5 100644 --- a/app/code/Magento/Directory/Model/AllowedCountries.php +++ b/app/code/Magento/Directory/Model/AllowedCountries.php @@ -55,7 +55,7 @@ public function getAllowedCountries( $scope = ScopeInterface::SCOPE_WEBSITE, $scopeCode = null ) { - if (empty($scopeCode)) { + if ($scopeCode === null) { $scopeCode = $this->getDefaultScopeCode($scope); } From 65c67dd91a88ed812d59eed2790449cff25e5a8d Mon Sep 17 00:00:00 2001 From: "al.kravchuk" Date: Tue, 10 Jul 2018 16:52:54 +0300 Subject: [PATCH 2/2] magento/magento2#?: 'Allowed Countries' - get countries for scope 'default'. - add tests --- .../Test/Unit/Model/AllowedCountriesTest.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/code/Magento/Directory/Test/Unit/Model/AllowedCountriesTest.php b/app/code/Magento/Directory/Test/Unit/Model/AllowedCountriesTest.php index 5931e5a839341..97a49aa50dc10 100644 --- a/app/code/Magento/Directory/Test/Unit/Model/AllowedCountriesTest.php +++ b/app/code/Magento/Directory/Test/Unit/Model/AllowedCountriesTest.php @@ -70,4 +70,20 @@ public function testGetAllowedCountries() $this->allowedCountriesReader->getAllowedCountries(ScopeInterface::SCOPE_WEBSITE, true) ); } + + public function testGetAllowedCountriesDefaultScope() + { + $this->storeManagerMock->expects($this->never()) + ->method('getStore'); + + $this->scopeConfigMock->expects($this->once()) + ->method('getValue') + ->with(AllowedCountries::ALLOWED_COUNTRIES_PATH, ScopeInterface::SCOPE_STORE, 0) + ->willReturn('AM'); + + $this->assertEquals( + ['AM' => 'AM'], + $this->allowedCountriesReader->getAllowedCountries(ScopeInterface::SCOPE_STORE, 0) + ); + } }