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->themeList->expects($this->any())->method('getThemeByFullPath')->will($this->returnValue($this->theme)); }
/** * @return void */ public function testGetStaticViewFileContext() { $themeMock = $this->getMock('Magento\\Framework\\View\\Design\\ThemeInterface', [], [], '', false); $this->designMock->expects($this->any())->method('getDesignParams')->willReturn(['themeModel' => $themeMock, 'area' => 'area', 'locale' => 'locale']); $this->themeProvider->expects($this->any())->method('getThemeByFullPath')->willReturnArgument(0); $this->httpMock->expects($this->any())->method('isSecure')->willReturn(false); $fallbackContextMock = $this->getMockBuilder('Magento\\Framework\\View\\Asset\\File\\FallbackContex')->disableOriginalConstructor()->getMock(); $this->fallbackFactoryMock->expects($this->once())->method('create')->with(['baseUrl' => '', 'areaType' => 'area', 'themePath' => '', 'localeCode' => 'locale', 'isSecure' => ''])->willReturn($fallbackContextMock); $this->assertEquals($fallbackContextMock, $this->repository->getStaticViewFileContext()); }
/** * @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->themeList->expects($this->once())->method('getThemeByFullPath')->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()); }