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()); }
/** * @param $uaRegex * @param $currentUserAgent * @param $isCurrentUserAgent * @dataProvider isCurrentUserAgentDataProvider */ public function testIsCurrentUserAgent($uaRegex, $currentUserAgent, $isCurrentUserAgent) { $this->httpHeader->expects($this->any())->method('getHttpUserAgent')->willReturn($currentUserAgent); $this->assertEquals($isCurrentUserAgent, $this->request->isCurrentUserAgent($uaRegex)); }
/** * @return bool */ public function isAvailable() { return $this->appStateHelper->isFrontendArea() && !$this->requestHelper->isCurrentIp($this->getWhiteIps()) && !$this->requestHelper->isCurrentUserAgent($this->getWhiteUa()) && $this->isActive(); }