public function testGetAsset() { $asset = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Asset\\LocalInterface'); $this->fileManager->expects($this->once())->method('createRequireJsAsset')->will($this->returnValue($asset)); $object = new Config($this->context, $this->config, $this->fileManager); $this->assertSame($asset, $object->getAsset()); $this->assertSame($asset, $object->getAsset(), 'Asset is supposed to be cached in-memory'); }
public function testSetLayout() { $filePath = 'require_js_fie_path'; $asset = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Asset\\LocalInterface'); $asset->expects($this->atLeastOnce())->method('getFilePath')->willReturn($filePath); $this->fileManager->expects($this->once())->method('createRequireJsAsset')->will($this->returnValue($asset)); $layout = $this->getMock('Magento\\Framework\\View\\LayoutInterface'); $assetCollection = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\GroupedCollection')->disableOriginalConstructor()->getMock(); $assetCollection->expects($this->once())->method('add')->with($filePath, $asset); $this->pageConfig->expects($this->atLeastOnce())->method('getAssetCollection')->willReturn($assetCollection); $object = new Config($this->context, $this->config, $this->fileManager, $this->pageConfig); $object->setLayout($layout); }
public function testSetLayout() { $this->bundleConfig->expects($this->once())->method('isBundlingJsFiles')->willReturn(true); $filePath = 'require_js_fie_path'; $asset = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Asset\\LocalInterface'); $asset->expects($this->atLeastOnce())->method('getFilePath')->willReturn($filePath); $requireJsAsset = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Asset\\LocalInterface'); $requireJsAsset->expects($this->atLeastOnce())->method('getFilePath')->willReturn('/path/to/require/require.js'); $this->fileManager->expects($this->once())->method('createRequireJsConfigAsset')->will($this->returnValue($requireJsAsset)); $this->fileManager->expects($this->once())->method('createStaticJsAsset')->will($this->returnValue($requireJsAsset)); $this->fileManager->expects($this->once())->method('createBundleJsPool')->will($this->returnValue([$asset])); $layout = $this->getMock('Magento\\Framework\\View\\LayoutInterface'); $assetCollection = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\GroupedCollection')->disableOriginalConstructor()->getMock(); $this->pageConfig->expects($this->atLeastOnce())->method('getAssetCollection')->willReturn($assetCollection); $assetCollection->expects($this->atLeastOnce())->method('insert')->willReturn(true); $object = new Config($this->context, $this->config, $this->fileManager, $this->pageConfig, $this->bundleConfig); $object->setLayout($layout); }