public function testGetFilesMultiple() { $dirPath = '/Magento_Customer/css/'; $searchPath = 'css/*.test'; $this->componentRegistrar->expects($this->once())->method('getPath')->with(ComponentRegistrar::THEME, $this->themePath)->will($this->returnValue(self::FULL_THEME_PATH)); $fileMock = $this->getMockBuilder('Magento\\Framework\\View\\File')->disableOriginalConstructor()->getMock(); $this->themeDirectoryMock->expects($this->any())->method('getAbsolutePath')->willReturnMap([['fileA.test', $dirPath . 'fileA.test'], ['fileB.tst', $dirPath . 'fileB.tst'], ['fileC.test', $dirPath . 'fileC.test']]); // Verifies correct files are searched for $this->themeDirectoryMock->expects($this->once())->method('search')->with($searchPath)->willReturn(['fileA.test', 'fileC.test']); // Verifies Magento_Customer was correctly produced from directory path $this->fileFactoryMock->expects($this->any())->method('create')->with($this->isType('string'), null, $this->themeMock)->willReturn($fileMock); // Only two files should be in array, which were returned from search $this->assertEquals([$fileMock, $fileMock], $this->themeFileCollector->getFiles($this->themeMock, $searchPath)); }
public function testGetFilesMultiple() { $dirPath = '/Magento_Customer/css/'; $themePath = '/opt/magento2/app/design/frontend/Magento/blank'; $searchPath = 'css/*.test'; $this->themeMock->expects($this->any())->method('getFullPath')->will($this->returnValue($themePath)); $this->themesDirectoryMock->expects($this->any())->method('getAbsolutePath')->will($this->returnValueMap([['fileA.test', $dirPath . 'fileA.test'], ['fileB.tst', $dirPath . 'fileB.tst'], ['fileC.test', $dirPath . 'fileC.test']])); $fileMock = $this->getMockBuilder('Magento\\Framework\\View\\File')->disableOriginalConstructor()->getMock(); // Verifies correct files are searched for $this->themesDirectoryMock->expects($this->once())->method('search')->with($themePath . '/' . $searchPath)->will($this->returnValue(['fileA.test', 'fileC.test'])); // Verifies Magento_Customer was correctly produced from directory path $this->fileFactoryMock->expects($this->any())->method('create')->with($this->isType('string'), null, $this->equalTo($this->themeMock))->will($this->returnValue($fileMock)); $theme = new Theme($this->filesystemMock, $this->fileFactoryMock); // Only two files should be in array, which were returned from search $this->assertEquals([$fileMock, $fileMock], $theme->getFiles($this->themeMock, 'css/*.test')); }