23 private $themeDirectory;
38 private $readDirFactory;
43 private $componentRegistrar;
47 $this->themeDirectory = $this->createPartialMock(
49 [
'getAbsolutePath',
'search']
51 $this->pathPatternHelperMock = $this->getMockBuilder(\
Magento\Framework\View\Helper\PathPattern::class)
52 ->disableOriginalConstructor()
54 $this->fileFactory = $this->createMock(\
Magento\Framework\View\
File\Factory::class);
55 $this->readDirFactory = $this->createMock(\
Magento\Framework\
Filesystem\Directory\ReadFactory::class);
56 $this->readDirFactory->expects($this->any())
58 ->will($this->returnValue($this->themeDirectory));
59 $this->componentRegistrar = $this->getMockForAbstractClass(
60 \
Magento\Framework\Component\ComponentRegistrarInterface::class
62 $this->model = new \Magento\Framework\View\File\Collector\ThemeModular(
64 $this->readDirFactory,
65 $this->componentRegistrar,
66 $this->pathPatternHelperMock,
73 $this->componentRegistrar->expects($this->once())
75 ->will($this->returnValue(
''));
76 $theme = $this->getMockForAbstractClass(\
Magento\Framework\View\Design\ThemeInterface::class);
77 $theme->expects($this->once())
78 ->method(
'getFullPath')
79 ->will($this->returnValue(
'area/Vendor/theme'));
80 $this->assertSame([], $this->model->getFiles(
$theme,
''));
92 $theme = $this->getMockForAbstractClass(\
Magento\Framework\View\Design\ThemeInterface::class);
93 $themePath =
'area/theme/path';
94 $theme->expects($this->once())->method(
'getFullPath')->willReturn($themePath);
96 $handlePath =
'design/area/theme/path/%s/subdir/%s';
98 foreach (
$files as $file) {
99 $returnKeys[] = sprintf($handlePath, $file[
'module'], $file[
'handle']);
102 $this->componentRegistrar->expects($this->once())
105 ->will($this->returnValue(
'/full/theme/path'));
106 $this->pathPatternHelperMock->expects($this->any())
107 ->method(
'translatePatternFromGlob')
110 $this->themeDirectory->expects($this->once())
112 ->willReturn($returnKeys);
113 $this->themeDirectory->expects($this->any())
114 ->method(
'getAbsolutePath')
115 ->willReturnArgument(0);
118 foreach (
$files as $key => $file) {
119 $checkResult[$key] = new \Magento\Framework\View\File($file[
'handle'], $file[
'module'],
$theme);
120 $checkResult[$key] = $this->createMock(\
Magento\Framework\View\File::class);
122 ->expects($this->at($key))
124 ->with(sprintf($handlePath, $file[
'module'], $file[
'handle']), $file[
'module'],
$theme)
125 ->willReturn($checkResult[$key]);
127 $this->assertSame($checkResult, $this->model->getFiles(
$theme, $filePath));
138 [
'handle' =>
'1.xml',
'module' =>
'Module_One'],
139 [
'handle' =>
'2.xml',
'module' =>
'Module_One'],
140 [
'handle' =>
'3.xml',
'module' =>
'Module_Two'],
147 [
'handle' =>
'preset/4',
'module' =>
'Module_Fourth'],
testGetFiles($files, $filePath, $pathPattern)
foreach($appDirs as $dir) $files