shareConfig = $this->getMockBuilder(Share::class) ->disableOriginalConstructor() ->getMock(); $this->storeManager = $this->createMock(StoreManagerInterface::class); $this->plugin = new AllowedCountries($this->shareConfig, $this->storeManager); } public function testGetAllowedCountriesWithGlobalScope() { $expectedFilter = 1; $expectedScope = ScopeInterface::SCOPE_WEBSITES; $this->shareConfig->expects($this->once()) ->method('isGlobalScope') ->willReturn(true); $originalAllowedCountriesMock = $this->getMockBuilder(\Magento\Directory\Model\AllowedCountries::class) ->disableOriginalConstructor() ->getMock(); $websiteMock = $this->createMock(WebsiteInterface::class); $websiteMock->expects($this->once()) ->method('getId') ->willReturn($expectedFilter); $this->storeManager->expects($this->once()) ->method('getWebsites') ->willReturn([$websiteMock]); $this->assertEquals( [$expectedScope, [$expectedFilter]], $this->plugin->beforeGetAllowedCountries($originalAllowedCountriesMock) ); } }