/**
  * @param string $userAgent
  * @param bool $useConfig
  * @param bool|string $result
  * @param array $expressions
  * @dataProvider getThemeByRequestDataProvider
  */
 public function testGetThemeByRequest($userAgent, $useConfig, $result, $expressions = [])
 {
     $this->requestMock->expects($this->once())->method('getServer')->with($this->equalTo('HTTP_USER_AGENT'))->will($this->returnValue($userAgent));
     if ($useConfig) {
         $this->scopeConfigMock->expects($this->once())->method('getValue')->with($this->equalTo($this->exceptionConfigPath), $this->equalTo($this->scopeType))->will($this->returnValue(serialize($expressions)));
     }
     $this->assertSame($result, $this->designExceptions->getThemeByRequest($this->requestMock));
 }
Esempio n. 2
0
 /**
  * Analyze user-agent information to override custom design settings
  *
  * @param \Magento\Framework\App\RequestInterface $request
  * @return bool
  */
 protected function _applyUserAgentDesignException($request)
 {
     try {
         $theme = $this->_designExceptions->getThemeByRequest($request);
         if (false !== $theme) {
             $this->_getDesign()->setDesignTheme($theme);
             return true;
         }
     } catch (\Exception $e) {
         $this->_logger->critical($e);
     }
     return false;
 }