9 use \Magento\Framework\View\Design\FileResolution\Fallback\Resolver\Alternative;
31 $this->directory = $this->createMock(\
Magento\Framework\
Filesystem\Directory\Read::class);
32 $readFactory = $this->createMock(\
Magento\Framework\
Filesystem\Directory\ReadFactory::class);
33 $readFactory->expects($this->any())
35 ->will($this->returnValue($this->directory));
36 $this->rule = $this->createMock(\
Magento\Framework\View\Design\Fallback\Rule\RuleInterface::class);
37 $rulePool = $this->createMock(\
Magento\Framework\View\Design\Fallback\RulePool::class);
38 $rulePool->expects($this->any())
41 ->will($this->returnValue($this->rule));
42 $this->
object =
new Alternative($readFactory, $rulePool, [
'css' => [
'less']]);
52 $this->expectException(
'\InvalidArgumentException');
53 $this->expectExceptionMessage(
"\$alternativeExtensions must be an array with format:" 54 .
" array('ext1' => array('ext1', 'ext2'), 'ext3' => array(...)]");
56 $readFactory = $this->createMock(\
Magento\Framework\
Filesystem\Directory\ReadFactory::class);
57 $rulePool = $this->createMock(\
Magento\Framework\View\Design\Fallback\RulePool::class);
58 new Alternative($readFactory, $rulePool, $alternativeExtensions);
67 'numerical keys' => [[
'css',
'less']],
68 'non-array values' => [[
'css' =>
'less']],
74 $requestedFile =
'file.css';
75 $expected =
'some/dir/file.less';
77 $theme = $this->getMockForAbstractClass(\
Magento\Framework\View\Design\ThemeInterface::class);
78 $theme->expects($this->any())
79 ->method(
'getFullPath')
80 ->will($this->returnValue(
'magento_theme'));
81 $this->rule->expects($this->atLeastOnce())
82 ->method(
'getPatternDirs')
83 ->will($this->returnValue([
'some/dir']));
89 $this->directory->expects($this->any())
91 ->will($this->returnValueMap($fileExistsMap));
93 $actual = $this->
object->resolve(
'type', $requestedFile,
'frontend',
$theme,
'en_US',
'Magento_Module');
94 $this->assertSame($expected, $actual);
testConstructorException(array $alternativeExtensions)
constructorExceptionDataProvider()