コード例 #1
0
ファイル: SimpleTest.php プロジェクト: Doability/magento2dev
 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
ファイル: Simple.php プロジェクト: Doability/magento2dev
 /**
  * {@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
ファイル: Simple.php プロジェクト: vasiljok/magento2
 /**
  * {@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');
 }