コード例 #1
0
 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());
 }
コード例 #2
0
 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));
 }
コード例 #3
0
 /**
  * @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;
 }
コード例 #4
0
 /**
  * @return bool
  */
 public function isAvailable()
 {
     return $this->appStateHelper->isFrontendArea() && !$this->requestHelper->isCurrentIp($this->getWhiteIps()) && !$this->requestHelper->isCurrentUserAgent($this->getWhiteUa()) && $this->isActive();
 }
コード例 #5
0
 public function testIsFrontendAreaException()
 {
     $this->state->expects($this->atLeastOnce())->method('getAreaCode')->willThrowException(new LocalizedException(__('error')));
     $this->assertFalse($this->appState->isFrontendArea());
 }