private function mockDesign() { $params = array('area' => 'area', 'themeModel' => $this->theme, 'locale' => 'locale'); $this->design->expects($this->atLeastOnce())->method('getDesignParams')->will($this->returnValue($params)); $this->design->expects($this->any())->method('getConfigurationDesignTheme')->with('area')->will($this->returnValue($this->theme)); $this->design->expects($this->any())->method('getThemePath')->with($this->theme)->will($this->returnValue('theme')); $this->themeProvider->expects($this->any())->method('getThemeModel')->will($this->returnValue($this->theme)); }
/** * @param string $originalContent * @param string $foundPath * @param string $resolvedPath * @param array $foundFiles * @param string $expectedContent * * @dataProvider processDataProvider */ public function testProcess($originalContent, $foundPath, $resolvedPath, $foundFiles, $expectedContent) { $chain = new \Magento\Framework\View\Asset\PreProcessor\Chain($this->asset, $originalContent, 'css'); $relatedAsset = $this->getMock('\\Magento\\Framework\\View\\Asset\\File', [], [], '', false); $relatedAsset->expects($this->once())->method('getFilePath')->will($this->returnValue($resolvedPath)); $context = $this->getMock('\\Magento\\Framework\\View\\Asset\\File\\FallbackContext', [], [], '', false); $this->assetRepo->expects($this->once())->method('createRelated')->with($foundPath, $this->asset)->will($this->returnValue($relatedAsset)); $relatedAsset->expects($this->once())->method('getContext')->will($this->returnValue($context)); $theme = $this->getMockForAbstractClass('\\Magento\\Framework\\View\\Design\\ThemeInterface'); $this->themeProvider->expects($this->once())->method('getThemeModel')->will($this->returnValue($theme)); $files = []; foreach ($foundFiles as $file) { $fileObject = $this->getMock('Magento\\Framework\\View\\File', [], [], '', false); $fileObject->expects($this->any())->method('getModule')->will($this->returnValue($file['module'])); $fileObject->expects($this->any())->method('getFilename')->will($this->returnValue($file['filename'])); $files[] = $fileObject; } $this->fileSource->expects($this->once())->method('getFiles')->with($theme, $resolvedPath)->will($this->returnValue($files)); $this->object->process($chain); $this->assertEquals($expectedContent, $chain->getContent()); $this->assertEquals('css', $chain->getContentType()); }