public function testGetCustomCssContent() { $expectedContent = 'New file content'; $customization = $this->getMock('Magento\\Framework\\View\\Design\\Theme\\Customization', array(), array(), '', false); $this->_theme->expects($this->any())->method('getCustomization')->will($this->returnValue($customization)); /** @var $cssFile \Magento\Framework\View\Design\Theme\Customization\File\Css */ $cssFile = $this->getMock('Magento\\Framework\\View\\Design\\Theme\\Customization\\File\\Css', array('getContent'), array(), '', false); $customization->expects($this->once())->method('getFilesByType')->with(\Magento\Theme\Model\Theme\Customization\File\CustomCss::TYPE)->will($this->returnValue(array($cssFile))); $cssFile->expects($this->once())->method('getContent')->will($this->returnValue('New file content')); $this->assertEquals($expectedContent, $this->_model->getCustomCssContent()); }
/** * @covers \Magento\DesignEditor\Block\Adminhtml\Editor\Tools\Code\Js::getFiles */ public function testGetJsFiles() { $customization = $this->getMock('Magento\\Framework\\View\\Design\\Theme\\Customization', array(), array(), '', false); $this->_theme->expects($this->any())->method('getCustomization')->will($this->returnValue($customization)); $customization->expects($this->once())->method('getFilesByType')->with(\Magento\Framework\View\Design\Theme\Customization\File\Js::TYPE)->will($this->returnValue(array())); $customization->expects($this->once())->method('generateFileInfo')->with(array())->will($this->returnValue(array('js' => 'files'))); $this->_helperMock->expects($this->once())->method('jsonEncode')->with(array('js' => 'files'))->will($this->returnValue('someData')); $this->assertEquals('someData', $this->_model->getFiles()); }
/** * @dataProvider themeDataProvider */ public function testGetVisibleTheme($isVirtual) { $this->_setEditableTheme(); $this->_theme->expects($this->atLeastOnce())->method('isVirtual')->will($this->returnValue($isVirtual)); if ($isVirtual) { $themeObject = $this->_setStagingTheme(); $this->assertEquals($themeObject, $this->_model->getVisibleTheme()); } else { $this->assertEquals($this->_theme, $this->_model->getVisibleTheme()); } }
protected function setUp() { $this->customizationPath = '/' . implode('/', array('var', 'theme')); $this->request = $this->getMock('\\Magento\\Framework\\App\\Request\\Http', array(), array(), '', false); $this->filesystem = $this->getMock('Magento\\Framework\\App\\Filesystem', array(), array(), '', false); $this->session = $this->getMock('Magento\\Backend\\Model\\Session', array(), array(), '', false); $this->contextHelper = $this->getMock('Magento\\Framework\\App\\Helper\\Context', array(), array(), '', false); $this->directoryWrite = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Write', array(), array(), '', false); $this->themeFactory = $this->getMock('Magento\\Framework\\View\\Design\\Theme\\FlyweightFactory', array(), array(), '', false); $this->theme = $this->getMock('Magento\\Core\\Model\\Theme', array(), array(), '', false); $this->customization = $this->getMock('Magento\\Framework\\View\\Design\\Theme\\Customization', array(), array(), '', false); $this->filesystem->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($this->directoryWrite)); $this->directoryWrite->expects($this->any())->method('create')->will($this->returnValue(true)); $this->contextHelper->expects($this->once())->method('getRequest')->will($this->returnValue($this->request)); $this->themeFactory->expects($this->any())->method('create')->will($this->returnValue($this->theme)); $this->theme->expects($this->any())->method('getCustomization')->will($this->returnValue($this->customization)); $this->request->expects($this->at(0))->method('getParam')->with(\Magento\Theme\Helper\Storage::PARAM_THEME_ID)->will($this->returnValue(6)); $this->request->expects($this->at(1))->method('getParam')->with(\Magento\Theme\Helper\Storage::PARAM_CONTENT_TYPE)->will($this->returnValue(\Magento\Theme\Model\Wysiwyg\Storage::TYPE_IMAGE)); $this->helper = new \Magento\Theme\Helper\Storage($this->contextHelper, $this->filesystem, $this->session, $this->themeFactory); }