public function testGetFileIfMinificationIsDisabled()
 {
     $this->assetConfig->expects($this->once())->method('isMinifyHtml')->willReturn(false);
     $theme = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Design\\ThemeInterface');
     $expected = 'some/file.ext';
     $this->resolver->expects($this->once())->method('resolve')->with(RulePool::TYPE_TEMPLATE_FILE, 'file.ext', 'frontend', $theme, null, 'Magento_Module')->will($this->returnValue($expected));
     $this->state->expects($this->never())->method('getMode');
     $actual = $this->object->getFile('frontend', $theme, 'file.ext', 'Magento_Module');
     $this->assertSame($expected, $actual);
 }
Exemplo n.º 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');
     $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);
 }
Exemplo n.º 3
0
 public function testGetAssetsInvalidAdapter()
 {
     $this->setExpectedException('\\Magento\\Framework\\Exception', 'Invalid adapter: \'stdClass\'. Expected: \\Magento\\Framework\\Code\\Minifier\\AdapterInterface');
     $asset = $this->getMockForAbstractClass('Magento\\Framework\\View\\Asset\\LocalInterface');
     $asset->expects($this->once())->method('getContentType')->will($this->returnValue('js'));
     $this->_config->expects($this->once())->method('isAssetMinification')->with('js')->will($this->returnValue(true));
     $this->_config->expects($this->once())->method('getAssetMinificationAdapter')->with('js')->will($this->returnValue('StdClass'));
     $obj = new \StdClass();
     $this->_objectManager->expects($this->once())->method('get')->with('StdClass')->will($this->returnValue($obj));
     $this->_model->getAssets([$asset]);
 }
Exemplo n.º 4
0
    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));
    }