public function testIsAvailable() { $this->appStateHelper->expects($this->once())->method('isFrontendArea')->willReturn(true); $this->scopeConfig->expects($this->any())->method('getStoreValue')->willReturnMap([['tobai_geo_store_switcher/general/white_ips', '127.0.0.1, 10.0.0.1'], ['tobai_geo_store_switcher/general/white_ua', '/^mozilla/i']]); $this->requestHelper->expects($this->once())->method('isCurrentIp')->with(['127.0.0.1', '10.0.0.1'])->willReturn(false); $this->requestHelper->expects($this->once())->method('isCurrentUserAgent')->with('/^mozilla/i')->willReturn(false); $this->scopeConfig->expects($this->once())->method('getFrontendStoreOrBackendValue')->with('tobai_geo_store_switcher/general/active')->willReturn(true); $this->assertTrue($this->configGeneral->isAvailable()); }
public function testGetFrontendWebsiteOrBackendValueBackendStoreScope() { $path = 'test-path'; $this->appStateHelper->expects($this->once())->method('isFrontendArea')->willReturn(false); $this->scopeDefiner->expects($this->atLeastOnce())->method('getScope')->willReturn(ScopeInterface::SCOPE_STORE); $this->scopeDefiner->expects($this->never())->method('getScopeValue'); $this->appScopeConfig->expects($this->never())->method('getValue'); $this->assertEmpty($this->scopeConfig->getFrontendWebsiteOrBackendValue($path)); }
/** * @param string $path * @return string */ public function getFrontendWebsiteOrBackendValue($path) { $value = ''; if ($this->appStateHelper->isFrontendArea()) { $value = $this->getWebsiteValue($path); } else { if ($this->scopeDefiner->getScope() != ScopeInterface::SCOPE_STORE) { $value = $this->appScopeConfig->getValue($path, $this->scopeDefiner->getScope(), $this->scopeDefiner->getScopeValue()); } } return $value; }
/** * @return bool */ public function isAvailable() { return $this->appStateHelper->isFrontendArea() && !$this->requestHelper->isCurrentIp($this->getWhiteIps()) && !$this->requestHelper->isCurrentUserAgent($this->getWhiteUa()) && $this->isActive(); }
public function testIsFrontendAreaException() { $this->state->expects($this->atLeastOnce())->method('getAreaCode')->willThrowException(new LocalizedException(__('error'))); $this->assertFalse($this->appState->isFrontendArea()); }