public function testGetStoreId() { $countryCode = 'UA'; $configDefaultStore = 2; $this->generalConfig->expects($this->once())->method('getDefaultStore')->willReturn($configDefaultStore); $this->assertEquals($configDefaultStore, $this->defaultStore->getStoreId($countryCode)); }
public function testGetStoreIdNotInList() { $countryCode = 'UA'; $countryList = ['US', 'UK']; $this->generalConfig->expects($this->once())->method('getCountryList')->willReturn($countryList); $this->generalConfig->expects($this->never())->method('getCountryStore'); $this->assertFalse($this->country->getStoreId($countryCode)); }
public function testGetStoreIdNoGroup() { $countryCode = 'UA'; $groupCount = 2; $group1 = 1; $groupCountryList1 = ['US', 'UK']; $group2 = 2; $groupCountryList2 = ['DE', 'FR']; $this->generalConfig->expects($this->once())->method('getGroupCount')->willReturn($groupCount); $this->generalConfig->expects($this->exactly(2))->method('getGroupCountryList')->willReturnMap([[$group1, $groupCountryList1], [$group2, $groupCountryList2]]); $this->generalConfig->expects($this->never())->method('getGroupStore'); $this->assertFalse($this->groupCountry->getStoreId($countryCode)); }
protected function setGeneralConfigIsAvailable($isAvailable) { if (null === $isAvailable) { $this->generalConfig->expects($this->never())->method('isAvailable'); } else { $this->generalConfig->expects($this->once())->method('isAvailable')->willReturn($isAvailable); } return $this->generalConfig; }
public function testAfterGetDefaultStoreNotInWebsite() { $storeId = 1; $websiteStoreIds = [1, 3]; $geoStoreId = 2; $this->generalConfig->expects($this->once())->method('isAvailable')->willReturn(true); $this->storeSwitcher->expects($this->once())->method('isInitialized')->willReturn(true); $this->storeSwitcher->expects($this->once())->method('getStoreId')->willReturn($geoStoreId); $website = $this->getMockBuilder('Magento\\Store\\Model\\Website')->disableOriginalConstructor()->getMock(); $website->expects($this->once())->method('getStoreIds')->willReturn($websiteStoreIds); $store = $this->getMockBuilder('Magento\\Store\\Model\\Store')->disableOriginalConstructor()->getMock(); $store->expects($this->once())->method('getId')->willReturn($storeId); $this->assertSame($store, $this->geoWebsite->afterGetDefaultStore($website, $store)); }
public function testUpdateStoreIdNotFoundCountryStore() { $countryCode = 'UA'; $storeId = 2; $websiteStoreCodes = ['us', 'uk']; $websiteId = 11; $this->generalConfig->expects($this->once())->method('isMappingSore')->willReturn(true); $store = $this->getMockBuilder('Magento\\Store\\Api\\Data\\StoreInterface')->disableOriginalConstructor()->getMock(); $store->expects($this->once())->method('getWebsiteId')->willReturn($websiteId); $this->storeRepository->expects($this->once())->method('getById')->willReturn($store); $this->storeRepository->expects($this->never())->method('get'); $website = $this->getMockBuilder('Magento\\Store\\Model\\Website')->disableOriginalConstructor()->getMock(); $website->expects($this->once())->method('getStoreCodes')->willReturn($websiteStoreCodes); $this->websiteRepository->expects($this->once())->method('getById')->with($websiteId)->willReturn($website); $this->websiteRepository->expects($this->never())->method('getDefault'); $this->assertEquals($storeId, $this->countryStoreMapping->updateStoreId($storeId, $countryCode)); }
/** * @param int|bool $storeId * @param string $identifierValue * @param string $geoIdentifierValue * @dataProvider afterGetValueDataProvider */ public function testAfterGetValue($storeId, $identifierValue, $geoIdentifierValue) { $this->generalConfig->expects($this->once())->method('isAvailable')->willReturn(true); $this->storeSwitcher->expects($this->atLeastOnce())->method('getStoreId')->willReturn($storeId); /** @var \Magento\Framework\App\PageCache\Identifier $identifier */ $identifier = $this->getMockBuilder('Magento\\Framework\\App\\PageCache\\Identifier')->disableOriginalConstructor()->getMock(); $this->assertEquals($geoIdentifierValue, $this->geoIdentifier->afterGetValue($identifier, $identifierValue)); }