Пример #1
0
 /**
  * @magentoDataFixture Magento/Framework/Less/_files/themes.php
  * @magentoAppIsolation enabled
  * @magentoAppArea frontend
  * @param string $path
  * @param string $themeName
  * @param string[] $expectedFiles
  * @dataProvider getFilesDataProvider
  */
 public function testGetFiles($path, $themeName, array $expectedFiles)
 {
     /** @var \Magento\Framework\View\Design\Theme\FlyweightFactory $themeFactory */
     $themeFactory = $this->objectManager->get('Magento\\Framework\\View\\Design\\Theme\\FlyweightFactory');
     $theme = $themeFactory->create($themeName);
     $files = $this->model->getFiles($theme, $path);
     $actualFiles = [];
     foreach ($files as $file) {
         $actualFiles[] = $file->getFilename();
     }
     $this->assertEquals($expectedFiles, $actualFiles);
     /** @var $file \Magento\Framework\View\File */
     foreach ($files as $file) {
         if (!in_array($file->getFilename(), $expectedFiles)) {
             $this->fail(sprintf('File "%s" is not expected but found', $file->getFilename()));
         }
     }
 }
Пример #2
0
 /**
  *
  * @dataProvider getFilesDataProvider
  *
  * @param $libraryFiles array Files in lib directory
  * @param $baseFiles array Files in base directory
  * @param $themeFiles array Files in theme
  * *
  * @return void
  */
 public function testGetFiles($libraryFiles, $baseFiles, $themeFiles)
 {
     $this->fileListMock->expects($this->at(0))->method('add')->with($this->equalTo($libraryFiles));
     $this->fileListMock->expects($this->at(1))->method('add')->with($this->equalTo($baseFiles));
     $this->fileListMock->expects($this->any())->method('getAll')->will($this->returnValue(['returnedFile']));
     $subPath = '*';
     $this->libraryFilesMock->expects($this->atLeastOnce())->method('getFiles')->with($this->themeMock, $subPath)->will($this->returnValue($libraryFiles));
     $this->baseFilesMock->expects($this->atLeastOnce())->method('getFiles')->with($this->themeMock, $subPath)->will($this->returnValue($baseFiles));
     $this->overriddenBaseFilesMock->expects($this->any())->method('getFiles')->will($this->returnValue($themeFiles));
     $aggregated = new Aggregated($this->fileListFactoryMock, $this->libraryFilesMock, $this->baseFilesMock, $this->overriddenBaseFilesMock, $this->loggerMock);
     $inheritedThemeMock = $this->getMockBuilder('\\Magento\\Framework\\View\\Design\\ThemeInterface')->getMock();
     $this->themeMock->expects($this->any())->method('getInheritedThemes')->will($this->returnValue([$inheritedThemeMock]));
     $this->assertEquals(['returnedFile'], $aggregated->getFiles($this->themeMock, $subPath));
 }