Example #1
0
    public function testToHtml()
    {
        $this->context->expects($this->once())->method('getEventManager')->will($this->returnValue($this->getMockForAbstractClass('\\Magento\\Framework\\Event\\ManagerInterface')));
        $this->context->expects($this->once())->method('getScopeConfig')->will($this->returnValue($this->getMockForAbstractClass('\\Magento\\Framework\\App\\Config\\ScopeConfigInterface')));
        $this->config->expects($this->once())->method('getBaseConfig')->will($this->returnValue('the config data'));
        $object = new Config($this->context, $this->config, $this->fileManager, $this->pageConfig, $this->bundleConfig);
        $html = $object->toHtml();
        $expectedFormat = <<<expected
<script type="text/javascript">
the config data</script>
expected;
        $this->assertStringMatchesFormat($expectedFormat, $html);
    }
Example #2
0
 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');
     $minResolverAsset = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Asset\\LocalInterface');
     $minResolverAsset->expects($this->atLeastOnce())->method('getFilePath')->willReturn('/path/to/require/require-min-resolver.js');
     $this->fileManager->expects($this->once())->method('createRequireJsConfigAsset')->will($this->returnValue($requireJsAsset));
     $this->fileManager->expects($this->once())->method('createRequireJsMixinsAsset')->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]));
     $this->fileManager->expects($this->once())->method('createMinResolverAsset')->will($this->returnValue($minResolverAsset));
     $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);
     $this->minificationMock = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\Minification')->disableOriginalConstructor()->getMock();
     $this->minificationMock->expects($this->any())->method('isEnabled')->with('js')->willReturn(true);
     $object = new Config($this->context, $this->config, $this->fileManager, $this->pageConfig, $this->bundleConfig, $this->minificationMock);
     $object->setLayout($layout);
 }