Ejemplo n.º 1
0
 protected function setUp()
 {
     $this->_urlBuilder = $this->getMock('Magento\\Backend\\Model\\Url', [], [], '', false);
     $this->_themeContext = $this->getMock('Magento\\DesignEditor\\Model\\Theme\\Context', [], [], '', false);
     $this->_theme = $this->getMock('Magento\\Theme\\Model\\Theme', ['getId', 'getCustomization', '__wakeup'], [], '', false);
     $this->_theme->expects($this->any())->method('getId')->will($this->returnValue(self::TEST_THEME_ID));
     $this->_themeContext->expects($this->any())->method('getEditableTheme')->will($this->returnValue($this->_theme));
     $this->_themeContext->expects($this->any())->method('getStagingTheme')->will($this->returnValue($this->_theme));
     $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this);
     $this->_model = $objectManagerHelper->getObject('Magento\\DesignEditor\\Block\\Adminhtml\\Editor\\Tools\\Code\\Custom', ['config' => $this->getMock('Magento\\Framework\\App\\Config\\ScopeConfigInterface'), 'formFactory' => $this->getMock('Magento\\Framework\\Data\\FormFactory', [], [], '', false), 'urlBuilder' => $this->_urlBuilder, 'themeContext' => $this->_themeContext]);
 }
Ejemplo n.º 2
0
 /**
  * Create a form element with necessary controls
  *
  * @return \Magento\DesignEditor\Block\Adminhtml\Editor\Tools\QuickStyles\Header
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 protected function _prepareForm()
 {
     if (!$this->_formId || !$this->_tab) {
         throw new \Magento\Framework\Exception\LocalizedException(__('We found an invalid block of class "%1". Please define the required properties.', get_class($this)));
     }
     $form = $this->_formBuilder->create(['id' => $this->_formId, 'action' => '#', 'method' => 'post', 'tab' => $this->_tab, 'theme' => $this->_themeContext->getStagingTheme(), 'parent_theme' => $this->_themeContext->getEditableTheme()->getParentTheme()]);
     $form->setUseContainer(true);
     $this->setForm($form);
     parent::_prepareForm();
     return $this;
 }
Ejemplo n.º 3
0
 public function testCopyChanges()
 {
     $this->_setEditableTheme();
     $themeObject = $this->_setStagingTheme();
     $this->_copyService->expects($this->atLeastOnce())->method('copy')->with($this->equalTo($themeObject), $this->equalTo($this->_theme))->will($this->returnSelf());
     $this->assertEquals($this->_model, $this->_model->copyChanges());
 }
Ejemplo n.º 4
0
 /**
  * Create a form element with necessary controls
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     /** @var Form $form */
     $form = $this->_formFactory->create(['data' => ['action' => '#', 'method' => 'post']]);
     $form->setId('product_image_sizing_form');
     $this->setForm($form);
     $form->setUseContainer(true);
     $form->setFieldNameSuffix('imagesizing');
     $form->addType('button_button', 'Magento\\DesignEditor\\Block\\Adminhtml\\Editor\\Form\\Element\\Button');
     $isFilePresent = true;
     try {
         /** @var $controlsConfig Configuration */
         $controlsConfig = $this->_controlFactory->create(\Magento\DesignEditor\Model\Editor\Tools\Controls\Factory::TYPE_IMAGE_SIZING, $this->_themeContext->getStagingTheme());
     } catch (\Magento\Framework\Exception $e) {
         $isFilePresent = false;
     }
     if ($isFilePresent) {
         $this->_initFormElements($controlsConfig, $form);
     } else {
         $hintMessage = __('Sorry, but you cannot resize images for this theme.');
         $form->addField('imagesize-tab-error', 'note', ['after_element_html' => '<p class="error-notice">' . $hintMessage . '</p>']);
     }
     return parent::_prepareForm();
 }
Ejemplo n.º 5
0
 /**
  * Get stores list
  *
  * @return \Magento\Store\Model\Store|null
  */
 public function getStoresList()
 {
     $stores = $this->_customization->getStoresByThemes();
     return isset($stores[$this->_themeContext->getEditableTheme()->getId()]) ? $stores[$this->_themeContext->getEditableTheme()->getId()] : null;
 }
Ejemplo n.º 6
0
 /**
  * Get save url
  *
  * @return string
  */
 public function getSaveUrl()
 {
     return $this->getUrl('adminhtml/system_design_editor_tools/saveQuickStyles', array('theme_id' => $this->_themeContext->getEditableTheme()->getId()));
 }
Ejemplo n.º 7
0
 /**
  * Check themes by change time (compare staging and physical theme)
  *
  * @return bool
  */
 protected function _isAbleRevertToDefault()
 {
     return $this->_hasThemeChanged($this->_themeContext->getStagingTheme(), $this->_themeContext->getEditableTheme()->getParentTheme());
 }
 /**
  * Get URL of remove image action
  *
  * @return string
  */
 public function getImageRemoveUrl()
 {
     return $this->getUrl('adminhtml/system_design_editor_tools/removeQuickStyleImage', ['theme_id' => $this->_themeContext->getEditableTheme()->getId()]);
 }
Ejemplo n.º 9
0
 /**
  * Get custom js files
  *
  * @return \Magento\Core\Model\Resource\Theme\File\Collection
  */
 public function getFiles()
 {
     $customization = $this->_themeContext->getStagingTheme()->getCustomization();
     $jsFiles = $customization->getFilesByType(\Magento\Framework\View\Design\Theme\Customization\File\Js::TYPE);
     return $this->_coreHelper->jsonEncode($customization->generateFileInfo($jsFiles));
 }
Ejemplo n.º 10
0
 /**
  * Get custom CSS file name
  *
  * @return string|null
  */
 public function getCustomFileName()
 {
     $customCss = $this->_getCustomCss($this->_themeContext->getStagingTheme());
     return $customCss ? $customCss->getFileName() : null;
 }