/** * @return bool|int */ public function getStoreId() { if (!$this->isInitialized) { $countryCode = (string) $this->country->getCountryCode(); try { $this->storeId = $this->rule->getStoreId($countryCode); $this->storeId = $this->permanentRule->updateStoreId($this->storeId, $countryCode); } catch (\Exception $e) { $this->logger->critical($e); } $this->isInitialized = true; } return $this->storeId; }
public function testGetStoreIdWithPermanentRuleException() { $countryCode = 'UA'; $storeId = 2; $ex = new \Exception('Permanent Rule Exception'); $this->country->expects($this->once())->method('getCountryCode')->willReturn($countryCode); $this->rule->expects($this->once())->method('getStoreId')->with($countryCode)->willReturn($storeId); $this->permanentRule->expects($this->once())->method('updateStoreId')->with($storeId, $countryCode)->willThrowException($ex); $this->logger->expects($this->once())->method('critical')->with($ex); $this->assertFalse($this->switcher->isInitialized()); $this->assertEquals($storeId, $this->switcher->getStoreId()); $this->assertTrue($this->switcher->isInitialized()); }