public function testGetCacheKeyInfo() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $context = $objectManager->get('Magento\\Framework\\App\\Http\\Context'); $context->setValue(\Magento\Customer\Helper\Data::CONTEXT_AUTH, false, false); $block = $objectManager->get('Magento\\Framework\\View\\LayoutInterface')->createBlock('Magento\\Theme\\Block\\Html\\Footer'); $storeId = $objectManager->get('Magento\\Store\\Model\\StoreManagerInterface')->getStore()->getId(); $this->assertEquals(array('PAGE_FOOTER', $storeId, 0, $this->_theme->getId(), null), $block->getCacheKeyInfo()); }
protected function setUp() { $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $this->_model = $objectManager->create('Magento\\Core\\Model\\Theme\\File'); /** @var $themeModel \Magento\Framework\View\Design\ThemeInterface */ $themeModel = $objectManager->create('Magento\\Framework\\View\\Design\\ThemeInterface'); $this->_theme = $themeModel->getCollection()->getFirstItem(); $this->_data = array('file_path' => 'main.css', 'file_type' => 'css', 'content' => 'content files', 'order' => 0, 'theme' => $this->_theme, 'theme_id' => $this->_theme->getId()); }
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()); }
/** * Set theme which will be editable in store designer * * @param int $themeId * @return $this * @throws CoreException */ public function setEditableThemeById($themeId) { $this->_theme = $this->_themeFactory->create(); if (!$this->_theme->load($themeId)->getId()) { throw new CoreException(__('We can\'t find theme "%1".', $themeId)); } if ($this->_theme->getType() === \Magento\Framework\View\Design\ThemeInterface::TYPE_STAGING) { throw new CoreException(__('Wrong theme type set as editable')); } return $this; }
/** * Save customized DOM of view configuration * * @param \DOMDocument $config * @return $this */ protected function _saveViewConfiguration(\DOMDocument $config) { $targetPath = $this->_theme->getCustomization()->getCustomViewConfigPath(); $directory = $this->_filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem::ROOT_DIR); $directory->writeFile($directory->getRelativePath($targetPath), $config->saveXML()); return $this; }
/** * @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); }
/** * @covers \Magento\Framework\View\Design\Theme\Image::getPreviewImageUrl */ public function testGetDefaultPreviewImageUrl() { $this->_themeMock->setData($this->_getThemeSampleData()); $this->_themeMock->setData('preview_image', null); $this->assertEquals('http://localhost/media_path/test_default_preview.png', $this->_model->getPreviewImageUrl()); }
/** * @param mixed $originalCode * @param string $expectedCode * @dataProvider getCodeDataProvider */ public function testGetCode($originalCode, $expectedCode) { $this->_model->setCode($originalCode); $this->assertSame($expectedCode, $this->_model->getCode()); }
/** * Retrieve cache identifier taking into account current area/package/theme/store * * @param string $suffix * @return string */ protected function _getCacheId($suffix = '') { return "LAYOUT_{$this->_theme->getArea()}_STORE{$this->_store->getId()}_{$this->_theme->getId()}{$suffix}"; }
/** * Use this method only with database isolation * * @return \Magento\Core\Model\Theme */ protected function _getTestTheme() { $theme = $this->_theme->getCollection()->getThemeByFullPath(implode(\Magento\Framework\View\Design\ThemeInterface::PATH_SEPARATOR, array('frontend', 'test_test_theme'))); $this->assertNotEmpty($theme->getId()); return $theme; }