public function testGetPatternDirs() { $expectedResult = ['path1', 'path2']; $module = 'Some_Module'; $modulePath = '/module/path'; $this->componentRegistrar->expects($this->once())->method('getPath')->with(ComponentRegistrar::MODULE, $module)->will($this->returnValue($modulePath)); $this->rule->expects($this->once())->method('getPatternDirs')->with(['module_name' => $module, 'module_dir' => $modulePath])->will($this->returnValue($expectedResult)); $this->assertEquals($expectedResult, $this->model->getPatternDirs(['module_name' => $module])); }
public function testResolve() { $requestedFile = 'file.css'; $expected = 'some/dir/file.less'; $theme = $this->getMockForAbstractClass('Magento\\Framework\\View\\Design\\ThemeInterface'); $theme->expects($this->any())->method('getFullPath')->will($this->returnValue('magento_theme')); $this->rule->expects($this->atLeastOnce())->method('getPatternDirs')->will($this->returnValue(['some/dir'])); $fileExistsMap = [['file.css', false], ['file.less', true]]; $this->directory->expects($this->any())->method('isExist')->will($this->returnValueMap($fileExistsMap)); $actual = $this->object->resolve('type', $requestedFile, 'frontend', $theme, 'en_US', 'Magento_Module'); $this->assertSame($expected, $actual); }
public function testGetPatternDirs() { $parentTheme = $this->getMockForAbstractClass('Magento\\Framework\\View\\Design\\ThemeInterface'); $parentTheme->expects($this->any())->method('getFullPath')->will($this->returnValue('package/parent_theme')); $theme = $this->getMockForAbstractClass('Magento\\Framework\\View\\Design\\ThemeInterface'); $theme->expects($this->any())->method('getFullPath')->will($this->returnValue('package/current_theme')); $theme->expects($this->any())->method('getParentTheme')->will($this->returnValue($parentTheme)); $this->componentRegistrar->expects($this->any())->method('getPath')->will($this->returnValueMap([[ComponentRegistrar::THEME, 'package/parent_theme', '/path/to/parent/theme'], [ComponentRegistrar::THEME, 'package/current_theme', '/path/to/current/theme']])); $ruleDirsMap = [[['theme_dir' => '/path/to/current/theme'], ['package/current_theme/path/one', 'package/current_theme/path/two']], [['theme_dir' => '/path/to/parent/theme'], ['package/parent_theme/path/one', 'package/parent_theme/path/two']]]; $this->rule->expects($this->any())->method('getPatternDirs')->will($this->returnValueMap($ruleDirsMap)); $expectedResult = ['package/current_theme/path/one', 'package/current_theme/path/two', 'package/parent_theme/path/one', 'package/parent_theme/path/two']; $this->assertEquals($expectedResult, $this->model->getPatternDirs(['theme' => $theme])); }
public function testResolveNonexistentFile() { $this->readFactoryMock->expects($this->any())->method('create')->willReturn($this->directoryMock); $this->ruleMock->expects($this->once())->method('getPatternDirs')->willReturn(['some/dir']); $this->directoryMock->expects($this->once())->method('isExist')->willReturn(false); $this->assertFalse($this->object->resolve('type', 'file.ext', 'frontend', $this->getMockForTheme('magento_theme'), 'en_US', 'Magento_Module')); }
public function testResolveFromCache() { $expectedPath = '/some/dir/file.ext'; $this->cache->expects($this->once())->method('getFromCache')->with('type', 'file.ext', 'frontend', 'magento_theme', 'en_US', 'Magento_Module')->will($this->returnValue($expectedPath)); $this->directory->expects($this->once())->method('getAbsolutePath')->with($expectedPath)->will($this->returnValue($expectedPath)); $this->rule->expects($this->never())->method('getPatternDirs'); $this->cache->expects($this->never())->method('saveToCache'); $actualPath = $this->object->resolve('type', 'file.ext', 'frontend', $this->getMockForTheme('magento_theme'), 'en_US', 'Magento_Module'); $this->assertSame($expectedPath, $actualPath); }