Beispiel #1
0
 public function testGetDefaultRouter()
 {
     $areas = ['area1' => ['router' => 'value1'], 'area2' => 'value2'];
     $this->_model = new \Magento\Framework\App\AreaList($this->objectManagerMock, $this->_resolverFactory, $areas, '');
     $this->assertEquals($this->_model->getDefaultRouter('area1'), $areas['area1']['router']);
     $this->assertNull($this->_model->getDefaultRouter('area2'));
 }
Beispiel #2
0
 /**
  * Fetch routes from configs by area code and router id
  *
  * @param string $scope
  * @return array
  */
 protected function _getRoutes($scope = null)
 {
     $scope = $scope ?: $this->_configScope->getCurrentScope();
     if (isset($this->_routes[$scope])) {
         return $this->_routes[$scope];
     }
     $cacheId = $scope . '::' . $this->_cacheId;
     $cachedRoutes = unserialize($this->_cache->load($cacheId));
     if (is_array($cachedRoutes)) {
         $this->_routes[$scope] = $cachedRoutes;
         return $cachedRoutes;
     }
     $routers = $this->_reader->read($scope);
     $routes = $routers[$this->_areaList->getDefaultRouter($scope)]['routes'];
     $this->_cache->save(serialize($routes), $cacheId);
     $this->_routes[$scope] = $routes;
     return $routes;
 }
Beispiel #3
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));
 }