예제 #1
0
 protected function setUp()
 {
     $this->directoryMock = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\Read::class)->disableOriginalConstructor()->getMock();
     $this->ruleMock = $this->getMockBuilder(\Magento\Framework\View\Design\Fallback\Rule\RuleInterface::class)->getMockForAbstractClass();
     $this->rulePoolMock = $this->getMockBuilder(\Magento\Framework\View\Design\Fallback\RulePool::class)->disableOriginalConstructor()->getMock();
     $this->readFactoryMock = $this->getMockBuilder(\Magento\Framework\Filesystem\Directory\ReadFactory::class)->disableOriginalConstructor()->getMock();
     $this->directoryListMock = $this->getMockBuilder(DirectoryList::class)->disableOriginalConstructor()->getMock();
     $this->rulePoolMock->expects($this->any())->method('getRule')->with('type')->willReturn($this->ruleMock);
     $this->object = (new ObjectManager($this))->getObject(Simple::class, ['readFactory' => $this->readFactoryMock, 'rulePool' => $this->rulePoolMock]);
     (new ObjectManager($this))->setBackwardCompatibleProperty($this->object, 'directoryList', $this->directoryListMock);
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function resolve($type, $file, $area = null, ThemeInterface $theme = null, $locale = null, $module = null)
 {
     $params = ['area' => $area, 'theme' => $theme, 'locale' => $locale];
     foreach ($params as $key => $param) {
         if ($param === null) {
             unset($params[$key]);
         }
     }
     if (!empty($module)) {
         $params['module_name'] = $module;
     }
     $path = $this->resolveFile($this->rulePool->getRule($type), $file, $params);
     return $path;
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function resolve($type, $file, $area = null, ThemeInterface $theme = null, $locale = null, $module = null)
 {
     self::assertFilePathFormat($file);
     $themePath = $theme ? $theme->getThemePath() : '';
     $path = $this->cache->getFromCache($type, $file, $area, $themePath, $locale, $module);
     if (false !== $path) {
         $path = $path ? $this->rootDirectory->getAbsolutePath($path) : false;
     } else {
         $params = ['area' => $area, 'theme' => $theme, 'locale' => $locale];
         foreach ($params as $key => $param) {
             if ($param === null) {
                 unset($params[$key]);
             }
         }
         if (!empty($module)) {
             list($params['namespace'], $params['module']) = explode('_', $module, 2);
         }
         $path = $this->resolveFile($this->rulePool->getRule($type), $file, $params);
         $cachedValue = $path ? $this->rootDirectory->getRelativePath($path) : '';
         $this->cache->saveToCache($cachedValue, $type, $file, $area, $themePath, $locale, $module);
     }
     return $path;
 }
예제 #4
0
 /**
  * @param string $type
  * @param array $overriddenParams
  * @param array $expectedResult
  *
  * @dataProvider getPatternDirsDataProvider
  */
 public function testGetPatternDirs($type, array $overriddenParams, array $expectedResult)
 {
     $actualResult = $this->model->getRule($type)->getPatternDirs($overriddenParams + $this->defaultParams);
     $this->assertEquals($expectedResult, $actualResult);
 }
예제 #5
0
 /**
  * @expectedException \InvalidArgumentException
  * @expectedException Fallback rule 'unsupported_type' is not supported
  */
 public function testGetRuleUnsupportedType()
 {
     $this->model->getRule('unsupported_type');
 }