/** * @magentoComponentsDir Magento/Email/Model/_files/design * @magentoAppIsolation enabled * @magentoDbIsolation enabled * @dataProvider layoutDirectiveDataProvider * * @param string $area * @param string $directiveParams * @param string $expectedOutput */ public function testLayoutDirective($area, $directiveParams, $expectedOutput) { /** @var \Magento\Theme\Model\Theme\Registration $registration */ $registration = $this->objectManager->get('Magento\\Theme\\Model\\Theme\\Registration'); $registration->register(); $this->model = $this->objectManager->create('Magento\\Email\\Model\\Template\\Filter'); \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea($area); /** @var $layout \Magento\Framework\View\LayoutInterface */ $layout = $this->objectManager->create('Magento\\Framework\\View\\Layout'); $this->objectManager->addSharedInstance($layout, 'Magento\\Framework\\View\\Layout'); $this->objectManager->get('Magento\\Framework\\View\\DesignInterface')->setDesignTheme('Magento_EmailTest/default'); $actualOutput = $this->model->layoutDirective(['{{layout ' . $directiveParams . '}}', 'layout', ' ' . $directiveParams]); $this->assertEquals($expectedOutput, trim($actualOutput)); }
/** * @magentoDataFixture Magento/Email/Model/_files/themes.php * @magentoAppIsolation enabled * @dataProvider layoutDirectiveDataProvider * * @param string $area * @param string $directiveParams * @param string $expectedOutput */ public function testLayoutDirective($area, $directiveParams, $expectedOutput) { \Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize(array(\Magento\Framework\App\Filesystem::PARAM_APP_DIRS => array(\Magento\Framework\App\Filesystem::THEMES_DIR => array('path' => dirname(__DIR__) . '/_files/design')))); $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Email\\Model\\Template\\Filter'); $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); $themes = array('frontend' => 'test_default', 'adminhtml' => 'test_default'); $design = $objectManager->create('Magento\\Core\\Model\\View\\Design', array('themes' => $themes)); $objectManager->addSharedInstance($design, 'Magento\\Core\\Model\\View\\Design'); \Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea($area); $collection = $objectManager->create('Magento\\Core\\Model\\Resource\\Theme\\Collection'); $themeId = $collection->getThemeByFullPath('frontend/test_default')->getId(); $objectManager->get('Magento\\Framework\\App\\Config\\MutableScopeConfigInterface')->setValue(\Magento\Framework\View\DesignInterface::XML_PATH_THEME_ID, $themeId, \Magento\Store\Model\ScopeInterface::SCOPE_STORE); /** @var $layout \Magento\Framework\View\LayoutInterface */ $layout = $objectManager->create('Magento\\Framework\\View\\Layout'); $objectManager->addSharedInstance($layout, 'Magento\\Framework\\View\\Layout'); $objectManager->get('Magento\\Framework\\View\\DesignInterface')->setDesignTheme('test_default'); $actualOutput = $this->_model->layoutDirective(array('{{layout ' . $directiveParams . '}}', 'layout', ' ' . $directiveParams)); $this->assertEquals($expectedOutput, trim($actualOutput)); }