9 use \Magento\Framework\Css\PreProcessor\File\Collector\Library;
53 private $readFactoryMock;
60 private $componentRegistrarMock;
73 $this->fileListFactoryMock = $this->getMockBuilder(\
Magento\Framework\View\
File\FileList\Factory::class)
74 ->disableOriginalConstructor()->getMock();
75 $this->fileListMock = $this->getMockBuilder(\
Magento\Framework\View\
File\FileList::class)
76 ->disableOriginalConstructor()->getMock();
77 $this->fileListFactoryMock->expects($this->any())
79 ->with(\
Magento\Framework\Css\PreProcessor\
File\FileList\Collator::class)
80 ->will($this->returnValue($this->fileListMock));
81 $this->readFactoryMock = $this->getMockBuilder(\
Magento\Framework\
Filesystem\Directory\ReadFactory::class)
82 ->disableOriginalConstructor()->getMock();
83 $this->componentRegistrarMock = $this->getMockBuilder(
84 \
Magento\Framework\Component\ComponentRegistrarInterface::class
85 )->disableOriginalConstructor()->getMock();
86 $this->fileSystemMock = $this->getMockBuilder(\
Magento\Framework\Filesystem::class)
87 ->disableOriginalConstructor()
89 $this->libraryDirectoryMock = $this->getMockBuilder(
92 $this->fileSystemMock->expects($this->any())->method(
'getDirectoryRead')
94 $this->returnValueMap(
101 $this->fileFactoryMock = $this->getMockBuilder(\
Magento\Framework\View\
File\Factory::class)
102 ->disableOriginalConstructor()
104 $this->themeMock = $this->getMockBuilder(\
Magento\Framework\View\Design\ThemeInterface::class)->getMock();
106 $this->fileListFactoryMock,
107 $this->fileSystemMock,
108 $this->fileFactoryMock,
109 $this->readFactoryMock,
110 $this->componentRegistrarMock
116 $this->libraryDirectoryMock->expects($this->any())->method(
'search')->will($this->returnValue([]));
117 $this->themeMock->expects($this->any())->method(
'getInheritedThemes')->will($this->returnValue([]));
120 $this->readFactoryMock->expects($this->never())
122 $this->componentRegistrarMock->expects($this->never())
125 $this->library->getFiles($this->themeMock,
'*');
139 $this->fileListMock->expects($this->any())->method(
'getAll')->will($this->returnValue([
'returnedFile']));
141 $this->libraryDirectoryMock->expects($this->any())->method(
'search')->will($this->returnValue($libraryFiles));
142 $this->libraryDirectoryMock->expects($this->any())->method(
'getAbsolutePath')->will($this->returnCallback(
144 return '/opt/Magento/lib/' . $file;
147 $themePath =
'/var/Magento/ATheme';
149 $readerMock = $this->getMockBuilder(\
Magento\Framework\
Filesystem\Directory\ReadInterface::class)->getMock();
150 $this->readFactoryMock->expects($this->once())
152 ->will($this->returnValue($readerMock));
153 $this->componentRegistrarMock->expects($this->once())
156 ->will($this->returnValue([
'/path/to/theme']));
157 $readerMock->expects($this->once())
159 ->will($this->returnValue($themeFiles));
160 $inheritedThemeMock = $this->getMockBuilder(\
Magento\Framework\View\Design\ThemeInterface::class)->getMock();
161 $inheritedThemeMock->expects($this->any())->method(
'getFullPath')->will($this->returnValue($themePath));
162 $this->themeMock->expects($this->any())->method(
'getInheritedThemes')
163 ->will($this->returnValue([$inheritedThemeMock]));
164 $this->assertEquals([
'returnedFile'], $this->library->getFiles($this->themeMock, $subPath));
175 'all files' => [[
'file1'], [
'file2']],
176 'no library' => [[], [
'file1',
'file2']],
testGetFiles($libraryFiles, $themeFiles)