Beispiel #1
0
 /**
  * @magentoAppIsolation enabled
  * @magentoDataFixture Magento/Store/_files/core_fixturestore.php
  */
 public function testGetProcessedTemplate()
 {
     \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\App\\AreaList')->getArea(\Magento\Framework\App\Area::AREA_FRONTEND)->load();
     $this->_setNotDefaultThemeForFixtureStore();
     $expectedViewUrl = 'static/frontend/Magento/luma/en_US/Magento_Theme/favicon.ico';
     $this->_model->setTemplateText('{{view url="Magento_Theme::favicon.ico"}}');
     $this->assertStringEndsNotWith($expectedViewUrl, $this->_model->getProcessedTemplate());
     $this->_model->setDesignConfig(['area' => 'frontend', 'store' => \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Store\\Model\\StoreManagerInterface')->getStore('fixturestore')->getId()]);
     $this->assertStringEndsWith($expectedViewUrl, $this->_model->getProcessedTemplate());
 }
 /**
  * Ensure that the template_styles variable contains styles from either <!--@styles @--> or the "Template Styles"
  * textarea in backend, depending on whether template was loaded from filesystem or DB.
  *
  * @magentoDataFixture Magento/Store/_files/core_fixturestore.php
  * @magentoComponentsDir Magento/Email/Model/_files/design
  * @magentoAppIsolation enabled
  * @magentoDbIsolation enabled
  * @dataProvider templateStylesVariableDataProvider
  *
  * @param string $area
  * @param string $expectedOutput
  * @param array $unexpectedOutputs
  * @param array $templateForDatabase
  */
 public function testTemplateStylesVariable($area, $expectedOutput, $unexpectedOutputs, $templateForDatabase = [])
 {
     if (count($templateForDatabase)) {
         $this->mockModel();
         $this->setUpThemeFallback($area);
         $template = $this->objectManager->create('Magento\\Email\\Model\\Template');
         $template->setData($templateForDatabase);
         $template->save();
         $templateId = $template->getId();
         $this->model->load($templateId);
     } else {
         // <!--@styles @--> parsing only via the loadDefault method. Since email template files won't contain
         // @styles comments by default, it is necessary to mock an object to return testable contents
         $themeDirectory = $this->getMockBuilder('Magento\\Framework\\Filesystem\\Directory\\ReadInterface')->disableOriginalConstructor()->setMethods(['readFile'])->getMockForAbstractClass();
         $themeDirectory->expects($this->once())->method('readFile')->will($this->returnValue('<!--@styles p { color: #111; } @--> {{var template_styles}}'));
         $filesystem = $this->getMockBuilder('\\Magento\\Framework\\Filesystem')->disableOriginalConstructor()->setMethods(['getDirectoryRead'])->getMock();
         $filesystem->expects($this->once())->method('getDirectoryRead')->with(DirectoryList::ROOT)->will($this->returnValue($themeDirectory));
         $this->mockModel($filesystem);
         $this->model->loadDefault('design_email_header_template');
     }
     $processedTemplate = $this->model->getProcessedTemplate();
     foreach ($unexpectedOutputs as $unexpectedOutput) {
         $this->assertNotContains($unexpectedOutput, $processedTemplate);
     }
     $this->assertContains($expectedOutput, $processedTemplate);
 }
 /**
  * Ensure that the template_styles variable contains styles from either <!--@styles @--> or the "Template Styles"
  * textarea in backend, depending on whether template was loaded from filesystem or DB.
  *
  * @magentoDataFixture Magento/Store/_files/core_fixturestore.php
  * @magentoDataFixture Magento/Email/Model/_files/design/themes.php
  * @magentoAppIsolation enabled
  * @dataProvider templateStylesVariableDataProvider
  *
  * @param string $area
  * @param string $expectedOutput
  * @param array $unexpectedOutputs
  * @param array $templateForDatabase
  */
 public function testTemplateStylesVariable($area, $expectedOutput, $unexpectedOutputs, $templateForDatabase = [])
 {
     $this->_mockModel($this->_getMockedFilesystem());
     $this->setUpThemeFallback($area);
     if (count($templateForDatabase)) {
         $template = $this->_objectManager->create('Magento\\Email\\Model\\Template');
         $template->setData($templateForDatabase);
         $template->save();
         $templateId = $template->getId();
         $this->_model->load($templateId);
     } else {
         // <!--@styles @--> parsing only happens when template is loaded from filesystem
         $this->_model->loadDefault('design_email_header_template');
     }
     $processedTemplate = $this->_model->getProcessedTemplate();
     foreach ($unexpectedOutputs as $unexpectedOutput) {
         $this->assertNotContains($unexpectedOutput, $processedTemplate);
     }
     $this->assertContains($expectedOutput, $processedTemplate);
 }
 /**
  * @magentoAppIsolation enabled
  * @magentoDataFixture Magento/Core/_files/design_change.php
  */
 public function testGetProcessedTemplateDesignChange()
 {
     \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\\Framework\\App\\AreaList')->getArea(\Magento\Framework\App\Area::AREA_FRONTEND)->load();
     $this->_model->setTemplateText('{{view url="Magento_Theme::favicon.ico"}}');
     $this->assertStringEndsWith('static/frontend/Magento/plushe/en_US/Magento_Theme/favicon.ico', $this->_model->getProcessedTemplate());
 }
Beispiel #5
0
 /**
  * @magentoAppIsolation enabled
  * @magentoDataFixture Mage/Core/_files/design_change.php
  */
 public function testGetProcessedTemplateDesignChange()
 {
     $this->_model->setTemplateText('{{view url="Mage_Page::favicon.ico"}}');
     $this->assertStringEndsWith('theme/frontend/default/modern/en_US/Mage_Page/favicon.ico', $this->_model->getProcessedTemplate());
 }