public function testAddAsset() { $dirRead = $this->getMockBuilder('Magento\\Framework\\Filesystem\\Directory\\ReadInterface')->disableOriginalConstructor()->getMock(); $context = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\File\\FallbackContext')->disableOriginalConstructor()->getMock(); $configView = $this->getMockBuilder('Magento\\Framework\\Config\\View')->disableOriginalConstructor()->getMock(); $this->filesystem->expects($this->once())->method('getDirectoryRead')->with(\Magento\Framework\App\Filesystem\DirectoryList::APP)->willReturn($dirRead); $this->asset->expects($this->atLeastOnce())->method('getSourceFile')->willReturn('/path/to/source/file.min.js'); $this->asset->expects($this->atLeastOnce())->method('getContentType')->willReturn('js'); $this->asset->expects($this->once())->method('getPath')->willReturn('/path/to/file.js'); $this->asset->expects($this->atLeastOnce())->method('getContext')->willReturn($context); $this->bundleConfig->expects($this->atLeastOnce())->method('getConfig')->with($context)->willReturn($configView); $configView->expects($this->once())->method('getExcludedFiles')->willReturn([]); $configView->expects($this->once())->method('getExcludedDir')->willReturn([]); $this->bundle->expects($this->once())->method('addAsset')->with($this->asset); $this->assertTrue($this->manager->addAsset($this->asset)); }
public function testAddAsset() { $context = $this->getMockBuilder('Magento\Framework\View\Asset\File\FallbackContext') ->disableOriginalConstructor() ->getMock(); $configView = $this->getMockBuilder('Magento\Framework\Config\View') ->disableOriginalConstructor() ->getMock(); $this->asset->expects($this->atLeastOnce()) ->method('getContentType') ->willReturn('js'); $this->asset->expects($this->once()) ->method('getSourceFile') ->willReturn('/source/file'); $this->asset->expects($this->atLeastOnce()) ->method('getFilePath') ->willReturn('file/path.js'); $this->assetConfig->expects($this->once()) ->method('isAssetMinification') ->willReturn(false); $this->asset->expects($this->atLeastOnce()) ->method('getContext') ->willReturn($context); $this->bundleConfig ->expects($this->atLeastOnce()) ->method('getConfig') ->with($context) ->willReturn($configView); $configView->expects($this->once()) ->method('getExcludedFiles') ->willReturn([]); $configView->expects($this->once()) ->method('getExcludedDir') ->willReturn([]); $this->bundle->expects($this->once()) ->method('addAsset') ->with($this->asset); $this->assertTrue($this->manager->addAsset($this->asset)); }