Esempio n. 1
0
 /**
  * @test
  * @return void
  */
 public function testBeforeSaveDelete()
 {
     $fileServiceName = 'service_name';
     $customization = $this->getMockBuilder('Magento\\Framework\\View\\Design\\Theme\\Customization\\FileInterface')->getMock();
     $this->fileServiceFactory->expects($this->once())->method('create')->with($fileServiceName)->willReturn($customization);
     $customization->expects($this->once())->method('prepareFile')->with($this->model)->willReturnSelf();
     $customization->expects($this->once())->method('save')->with($this->model)->willReturnSelf();
     $customization->expects($this->once())->method('delete')->with($this->model)->willReturnSelf();
     $this->model->setData('file_type', $fileServiceName);
     $this->model->beforeSave();
     $this->model->beforeDelete();
 }
Esempio n. 2
0
 /**
  * Create a form element with necessary controls
  *
  * @return $this
  */
 protected function _prepareForm()
 {
     /** @var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create();
     $this->setForm($form);
     $this->_addThemeCssFieldset();
     $customFiles = $this->_getCurrentTheme()->getCustomization()->getFilesByType(\Magento\Theme\Model\Theme\Customization\File\CustomCss::TYPE);
     $this->_customCssFile = reset($customFiles);
     $this->_addCustomCssFieldset();
     $formData['custom_css_content'] = $this->_customCssFile ? $this->_customCssFile->getContent() : null;
     /** @var $session \Magento\Backend\Model\Session */
     $session = $this->_objectManager->get('Magento\\Backend\\Model\\Session');
     $cssFileContent = $session->getThemeCustomCssData();
     if ($cssFileContent) {
         $formData['custom_css_content'] = $cssFileContent;
         $session->unsThemeCustomCssData();
     }
     $form->addValues($formData);
     parent::_prepareForm();
     return $this;
 }
Esempio n. 3
0
 /**
  * Test crud operations for theme files model using valid data
  */
 public function testCrud()
 {
     $this->_model->setData($this->_data);
     $crud = new \Magento\TestFramework\Entity($this->_model, ['file_path' => 'rename.css']);
     $crud->testCrud();
 }