Пример #1
0
 public function testGetFrontNameWhenAreaCodeAndFrontNameAreSet()
 {
     $expected = 'testFrontName';
     $this->_model = new \Magento\Framework\App\AreaList($this->objectManagerMock, $this->_resolverFactory, ['testAreaCode' => ['frontName' => 'testFrontName']], $expected);
     $actual = $this->_model->getFrontName('testAreaCode');
     $this->assertEquals($expected, $actual);
 }
Пример #2
0
 /**
  * Get options in "key-value" format
  *
  * @return array
  */
 public function toArray()
 {
     $areListCodes = $this->areaList->getCodes();
     $areList = [];
     foreach ($areListCodes as $areListCode) {
         $areList[$areListCode] = sprintf('%s [%s]', $this->areaList->getFrontName($areListCode), $areListCode);
     }
     return $areList;
 }
Пример #3
0
 /**
  * Modify pathInfo: strip down the front name and query parameters.
  *
  * @param \Magento\Framework\App\AreaList $areaList
  * @param \Magento\Framework\Config\ScopeInterface $configScope
  * @param null|string|\Zend_Uri $uri
  */
 public function __construct(\Magento\Framework\App\AreaList $areaList, \Magento\Framework\Config\ScopeInterface $configScope, $uri = null)
 {
     parent::__construct($uri);
     $areaFrontName = $areaList->getFrontName($configScope->getCurrentScope());
     $this->_pathInfo = $this->_requestUri;
     /** Remove base url and area from path */
     $this->_pathInfo = preg_replace("#.*?/{$areaFrontName}/?#", '/', $this->_pathInfo);
     /** Remove GET parameters from path */
     $this->_pathInfo = preg_replace('#\\?.*#', '', $this->_pathInfo);
 }
Пример #4
0
 public function testGetFrontNameWhenAreaCodeAndFrontNameArentSet()
 {
     $model = new \Magento\Framework\App\AreaList($this->objectManagerMock, $this->_resolverFactory);
     $code = 'testAreaCode';
     $this->assertNull($model->getCodeByFrontName($code));
     $this->assertNull($model->getFrontName($code));
     $this->assertSame([], $model->getCodes());
     $this->assertNull($model->getDefaultRouter($code));
     $this->objectManagerMock->expects($this->once())->method('create')->with('Magento\\Framework\\App\\AreaInterface', ['areaCode' => $code])->willReturn('test');
     $this->assertSame('test', $model->getArea($code));
 }
Пример #5
0
 /**
  * Modify pathInfo: strip down the front name and query parameters.
  *
  * @param AreaList $areaList
  * @param ScopeInterface $configScope
  * @param CookieReaderInterface $cookieReader
  * @param null|string|\Zend_Uri $uri
  */
 public function __construct(CookieReaderInterface $cookieReader, AreaList $areaList, ScopeInterface $configScope, $uri = null)
 {
     parent::__construct($cookieReader, $uri);
     $pathInfo = $this->getRequestUri();
     /** Remove base url and area from path */
     $areaFrontName = $areaList->getFrontName($configScope->getCurrentScope());
     $pathInfo = preg_replace("#.*?/{$areaFrontName}/?#", '/', $pathInfo);
     /** Remove GET parameters from path */
     $pathInfo = preg_replace('#\\?.*#', '', $pathInfo);
     $this->setPathInfo($pathInfo);
 }
Пример #6
0
 public function testGetFrontNameWhenAreaCodeAndFrontNameArentSet()
 {
     $this->_model = new \Magento\Framework\App\AreaList($this->objectManagerMock, $this->_resolverFactory, array(), '');
     $actual = $this->_model->getFrontName('testAreaCode');
     $this->assertNull($actual);
 }