ltsecurityinc安防产品在线商城代码
This commit is contained in:
@@ -0,0 +1,483 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Email\Model\Template;
|
||||
|
||||
use Magento\Framework\App\Area;
|
||||
use Magento\Framework\App\State;
|
||||
use Magento\Framework\App\TemplateTypesInterface;
|
||||
use Magento\Framework\Phrase;
|
||||
use Magento\Framework\View\Asset\ContentProcessorInterface;
|
||||
use Magento\Setup\Module\I18n\Locale;
|
||||
use Magento\Theme\Block\Html\Footer;
|
||||
|
||||
/**
|
||||
* @magentoAppIsolation enabled
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
*/
|
||||
class FilterTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var \Magento\Email\Model\Template\Filter
|
||||
*/
|
||||
protected $model;
|
||||
|
||||
/**
|
||||
* @var \Magento\TestFramework\ObjectManager
|
||||
*/
|
||||
protected $objectManager;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
|
||||
$this->model = $this->objectManager->create(
|
||||
\Magento\Email\Model\Template\Filter::class
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Isolation level has been raised in order to flush themes configuration in-memory cache
|
||||
*
|
||||
* @magentoAppArea frontend
|
||||
*/
|
||||
public function testViewDirective()
|
||||
{
|
||||
$url = $this->model->viewDirective(
|
||||
['{{view url="Magento_Theme::favicon.ico"}}', 'view', ' url="Magento_Theme::favicon.ico"']
|
||||
);
|
||||
$this->assertStringEndsWith('favicon.ico', $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Isolation level has been raised in order to flush themes configuration in-memory cache
|
||||
*
|
||||
* @magentoAppArea frontend
|
||||
*/
|
||||
public function testBlockDirective()
|
||||
{
|
||||
$class = Footer::class;
|
||||
$data = [
|
||||
"{{block class='$class' name='test.block' template='Magento_Theme::html/footer.phtml'}}",
|
||||
'block',
|
||||
" class='$class' name='test.block' template='Magento_Theme::html/footer.phtml'",
|
||||
];
|
||||
$html = $this->model->blockDirective($data);
|
||||
$this->assertStringContainsString('<div class="footer-container">', $html);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoConfigFixture current_store web/unsecure/base_link_url http://example.com/
|
||||
* @magentoConfigFixture admin_store web/unsecure/base_link_url http://example.com/
|
||||
*/
|
||||
public function testStoreDirective()
|
||||
{
|
||||
$url = $this->model->storeDirective(
|
||||
['{{store direct_url="arbitrary_url/"}}', 'store', ' direct_url="arbitrary_url/"']
|
||||
);
|
||||
$this->assertStringMatchesFormat('http://example.com/%sarbitrary_url/', $url);
|
||||
|
||||
$url = $this->model->storeDirective(
|
||||
['{{store url="translation/ajax/index"}}', 'store', ' url="translation/ajax/index"']
|
||||
);
|
||||
$this->assertStringMatchesFormat('http://example.com/%stranslation/ajax/index/', $url);
|
||||
|
||||
$this->model->setStoreId(0);
|
||||
$backendUrlModel = $this->objectManager->create(\Magento\Backend\Model\Url::class);
|
||||
$this->model->setUrlModel($backendUrlModel);
|
||||
$url = $this->model->storeDirective(
|
||||
['{{store url="translation/ajax/index"}}', 'store', ' url="translation/ajax/index"']
|
||||
);
|
||||
$this->assertStringMatchesFormat('http://example.com/index.php/backend/translation/ajax/index/%A', $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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::class);
|
||||
$registration->register();
|
||||
$this->model = $this->objectManager->create(\Magento\Email\Model\Template\Filter::class);
|
||||
\Magento\TestFramework\Helper\Bootstrap::getInstance()->loadArea($area);
|
||||
/** @var $layout \Magento\Framework\View\LayoutInterface */
|
||||
$layout = $this->objectManager->create(\Magento\Framework\View\Layout::class);
|
||||
$this->objectManager->addSharedInstance($layout, \Magento\Framework\View\Layout::class);
|
||||
$this->objectManager->get(\Magento\Framework\View\DesignInterface::class)
|
||||
->setDesignTheme('Magento_EmailTest/default');
|
||||
|
||||
$actualOutput = $this->model->layoutDirective(
|
||||
['{{layout ' . $directiveParams . '}}', 'layout', ' ' . $directiveParams]
|
||||
);
|
||||
$this->assertEquals($expectedOutput, trim($actualOutput));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function layoutDirectiveDataProvider()
|
||||
{
|
||||
$result = [
|
||||
'area parameter - omitted' => [
|
||||
'adminhtml',
|
||||
'handle="email_template_test_handle"',
|
||||
'<strong>Email content for frontend/Magento/default theme</strong>',
|
||||
],
|
||||
'area parameter - frontend' => [
|
||||
'adminhtml',
|
||||
'handle="email_template_test_handle" area="frontend"',
|
||||
'<strong>Email content for frontend/Magento/default theme</strong>',
|
||||
],
|
||||
'area parameter - backend' => [
|
||||
'frontend',
|
||||
'handle="email_template_test_handle" area="adminhtml"',
|
||||
'<strong>Email content for adminhtml/Magento/default theme</strong>',
|
||||
],
|
||||
'custom parameter' => [
|
||||
'frontend',
|
||||
'handle="email_template_test_handle" template="Magento_Email::sample_email_content_custom.phtml"',
|
||||
'<strong>Custom Email content for frontend/Magento/default theme</strong>',
|
||||
],
|
||||
];
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $directive
|
||||
* @param $translations
|
||||
* @param $expectedResult
|
||||
* @param array $variables
|
||||
* @internal param $translatorData
|
||||
* @magentoConfigFixture default_store dev/translate_inline/active 1
|
||||
* @magentoAppArea frontend
|
||||
* @dataProvider transDirectiveDataProvider
|
||||
*/
|
||||
public function testTransDirective($directive, $translations, $expectedResult, $variables = [])
|
||||
{
|
||||
$renderer = Phrase::getRenderer();
|
||||
|
||||
$translator = $this->getMockBuilder(\Magento\Framework\Translate::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getData'])
|
||||
->getMock();
|
||||
|
||||
$translator->method('getData')
|
||||
->willReturn($translations);
|
||||
|
||||
if (!empty($variables)) {
|
||||
$this->model->setVariables($variables);
|
||||
}
|
||||
|
||||
$this->objectManager->addSharedInstance($translator, \Magento\Framework\Translate::class);
|
||||
$this->objectManager->removeSharedInstance(\Magento\Framework\Phrase\Renderer\Translate::class);
|
||||
Phrase::setRenderer($this->objectManager->create(\Magento\Framework\Phrase\RendererInterface::class));
|
||||
|
||||
$this->assertEquals($expectedResult, $this->model->filter($directive));
|
||||
|
||||
Phrase::setRenderer($renderer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function transDirectiveDataProvider()
|
||||
{
|
||||
return [
|
||||
[
|
||||
'{{trans "foobar"}}',
|
||||
[],
|
||||
'foobar',
|
||||
],
|
||||
[
|
||||
'{{trans "foobar"}}',
|
||||
['foobar' => 'barfoo'],
|
||||
'barfoo',
|
||||
],
|
||||
'empty directive' => [
|
||||
'{{trans}}',
|
||||
[],
|
||||
'',
|
||||
],
|
||||
'empty string' => [
|
||||
'{{trans ""}}',
|
||||
[],
|
||||
'',
|
||||
],
|
||||
'no padding' => [
|
||||
'{{trans"Hello cruel coder..."}}',
|
||||
[],
|
||||
'Hello cruel coder...',
|
||||
],
|
||||
'multi-line padding' => [
|
||||
"{{trans \t\n\r'Hello cruel coder...' \t\n\r}}",
|
||||
[],
|
||||
'Hello cruel coder...',
|
||||
],
|
||||
'capture escaped double-quotes inside text' => [
|
||||
'{{trans "Hello \"tested\" world!"}}',
|
||||
[],
|
||||
'Hello "tested" world!',
|
||||
],
|
||||
'capture escaped single-quotes inside text' => [
|
||||
"{{trans 'Hello \\'tested\\' world!'|escape}}",
|
||||
[],
|
||||
"Hello 'tested' world!",
|
||||
],
|
||||
'filter with params' => [
|
||||
"{{trans 'Hello \\'tested\\' world!'|escape:html}}",
|
||||
[],
|
||||
"Hello 'tested' world!",
|
||||
],
|
||||
'basic var' => [
|
||||
'{{trans "Hello %adjective world!" adjective="tested"}}',
|
||||
[],
|
||||
'Hello tested world!',
|
||||
],
|
||||
'auto-escaped output' => [
|
||||
'{{trans "Hello %adjective <strong>world</strong>!" adjective="<em>bad</em>"}}',
|
||||
[],
|
||||
'Hello <em>bad</em> <strong>world</strong>!',
|
||||
],
|
||||
'unescaped modifier' => [
|
||||
'{{trans "Hello %adjective <strong>world</strong>!" adjective="<em>bad</em>"|raw}}',
|
||||
[],
|
||||
'Hello <em>bad</em> <strong>world</strong>!',
|
||||
],
|
||||
'variable replacement' => [
|
||||
'{{trans "Hello %adjective world!" adjective="$mood"}}',
|
||||
[],
|
||||
'Hello happy world!',
|
||||
[
|
||||
'mood' => 'happy'
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the css directive will successfully compile and output contents of a LESS file,
|
||||
* as well as supporting loading files from a theme fallback structure.
|
||||
*
|
||||
* @magentoDataFixture Magento/Store/_files/core_fixturestore.php
|
||||
* @magentoComponentsDir Magento/Email/Model/_files/design
|
||||
* @magentoAppIsolation enabled
|
||||
* @magentoDbIsolation enabled
|
||||
* @dataProvider cssDirectiveDataProvider
|
||||
*
|
||||
* @param int $templateType
|
||||
* @param string $directiveParams
|
||||
* @param string $expectedOutput
|
||||
*/
|
||||
public function testCssDirective($templateType, $directiveParams, $expectedOutput)
|
||||
{
|
||||
/** @var \Magento\Theme\Model\Theme\Registration $registration */
|
||||
$registration = $this->objectManager->get(
|
||||
\Magento\Theme\Model\Theme\Registration::class
|
||||
);
|
||||
$registration->register();
|
||||
$this->setUpDesignParams();
|
||||
$this->model->setStoreId('fixturestore')
|
||||
->setPlainTemplateMode($templateType == TemplateTypesInterface::TYPE_TEXT);
|
||||
|
||||
$output = $this->model->cssDirective(['{{css ' . $directiveParams . '}}', 'css', ' ' . $directiveParams]);
|
||||
|
||||
if ($expectedOutput !== '') {
|
||||
$this->assertStringContainsString($expectedOutput, $output);
|
||||
} else {
|
||||
$this->assertSame($expectedOutput, $output);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function cssDirectiveDataProvider()
|
||||
{
|
||||
return [
|
||||
'CSS from theme' => [
|
||||
TemplateTypesInterface::TYPE_HTML,
|
||||
'file="css/email-1.css"',
|
||||
'color: #111'
|
||||
],
|
||||
'CSS from parent theme' => [
|
||||
TemplateTypesInterface::TYPE_HTML,
|
||||
'file="css/email-2.css"',
|
||||
'color: #222'
|
||||
],
|
||||
'CSS from grandparent theme' => [
|
||||
TemplateTypesInterface::TYPE_HTML,
|
||||
'file="css/email-3.css"',
|
||||
'color: #333'
|
||||
],
|
||||
'Missing file parameter' => [
|
||||
TemplateTypesInterface::TYPE_HTML,
|
||||
'',
|
||||
'/* "file" parameter must be specified */'
|
||||
],
|
||||
'Plain-text template outputs nothing' => [
|
||||
TemplateTypesInterface::TYPE_TEXT,
|
||||
'file="css/email-1.css"',
|
||||
'',
|
||||
],
|
||||
'Empty or missing file' => [
|
||||
TemplateTypesInterface::TYPE_HTML,
|
||||
'file="css/non-existent-file.css"',
|
||||
'/*' . PHP_EOL . ContentProcessorInterface::ERROR_MESSAGE_PREFIX . 'LESS file is empty: ',
|
||||
],
|
||||
'File with compilation error results in error message' => [
|
||||
TemplateTypesInterface::TYPE_HTML,
|
||||
'file="css/file-with-error.css"',
|
||||
'variable @non-existent-variable is undefined',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the inlinecss directive will successfully load and inline CSS to HTML markup,
|
||||
* as well as supporting loading files from a theme fallback structure.
|
||||
*
|
||||
* @magentoDataFixture Magento/Store/_files/core_fixturestore.php
|
||||
* @magentoComponentsDir Magento/Email/Model/_files/design
|
||||
* @magentoAppIsolation enabled
|
||||
* @magentoDbIsolation enabled
|
||||
* @magentoConfigFixture default_store dev/static/sign 0
|
||||
* @dataProvider inlinecssDirectiveDataProvider
|
||||
*
|
||||
* @param string $templateText
|
||||
* @param string $expectedOutput
|
||||
* @param bool $productionMode
|
||||
* @param bool $plainTemplateMode
|
||||
* @param bool $isChildTemplateMode
|
||||
*/
|
||||
public function testInlinecssDirective(
|
||||
$templateText,
|
||||
$expectedOutput,
|
||||
$productionMode = false,
|
||||
$plainTemplateMode = false,
|
||||
$isChildTemplateMode = false
|
||||
) {
|
||||
/** @var \Magento\Theme\Model\Theme\Registration $registration */
|
||||
$registration = $this->objectManager->get(
|
||||
\Magento\Theme\Model\Theme\Registration::class
|
||||
);
|
||||
$registration->register();
|
||||
$this->setUpDesignParams();
|
||||
|
||||
$this->model->setPlainTemplateMode($plainTemplateMode);
|
||||
$this->model->setIsChildTemplate($isChildTemplateMode);
|
||||
|
||||
$appMode = $productionMode ? State::MODE_PRODUCTION : State::MODE_DEVELOPER;
|
||||
$this->objectManager->get(\Magento\Framework\App\State::class)->setMode($appMode);
|
||||
|
||||
$this->assertStringContainsString($expectedOutput, $this->model->filter($templateText));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function inlinecssDirectiveDataProvider()
|
||||
{
|
||||
return [
|
||||
'CSS from theme' => [
|
||||
'<html><p></p> {{inlinecss file="css/email-inline-1.css"}}</html>',
|
||||
'<p style="color: #111; text-align: left;">',
|
||||
],
|
||||
'CSS from parent theme' => [
|
||||
'<html><p></p> {{inlinecss file="css/email-inline-2.css"}}</html>',
|
||||
'<p style="color: #222; text-align: left;">',
|
||||
],
|
||||
'CSS from grandparent theme' => [
|
||||
'<html><p></p> {{inlinecss file="css/email-inline-3.css"}}',
|
||||
'<p style="color: #333; text-align: left;">',
|
||||
],
|
||||
'Non-existent file results in unmodified markup' => [
|
||||
'<html><p></p> {{inlinecss file="css/non-existent-file.css"}}</html>',
|
||||
'<html><p></p> </html>',
|
||||
],
|
||||
'Plain template mode results in unmodified markup' => [
|
||||
'<html><p></p> {{inlinecss file="css/email-inline-1.css"}}</html>',
|
||||
'<html><p></p> </html>',
|
||||
false,
|
||||
true,
|
||||
],
|
||||
'Child template mode results in unmodified directive' => [
|
||||
'<html><p></p> {{inlinecss file="css/email-inline-1.css"}}</html>',
|
||||
'<html><p></p> {{inlinecss file="css/email-inline-1.css"}}</html>',
|
||||
false,
|
||||
false,
|
||||
true,
|
||||
],
|
||||
'Production mode - File with compilation error results in structurally unmodified markup' => [
|
||||
'<html><p></p> {{inlinecss file="css/file-with-error.css"}}</html>',
|
||||
'<p></p>',
|
||||
true,
|
||||
],
|
||||
'Developer mode - File with compilation error results in error message' => [
|
||||
'<html><p></p> {{inlinecss file="css/file-with-error.css"}}</html>',
|
||||
'CSS inlining error:',
|
||||
false,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Store/_files/core_fixturestore.php
|
||||
* @magentoComponentsDir Magento/Email/Model/_files/design
|
||||
* @magentoAppIsolation enabled
|
||||
* @magentoDbIsolation enabled
|
||||
* @dataProvider inlinecssDirectiveThrowsExceptionWhenMissingParameterDataProvider
|
||||
*
|
||||
* @param string $templateText
|
||||
*/
|
||||
public function testInlinecssDirectiveThrowsExceptionWhenMissingParameter($templateText)
|
||||
{
|
||||
/** @var \Magento\Theme\Model\Theme\Registration $registration */
|
||||
$registration = $this->objectManager->get(
|
||||
\Magento\Theme\Model\Theme\Registration::class
|
||||
);
|
||||
$registration->register();
|
||||
$this->setUpDesignParams();
|
||||
|
||||
$this->model->filter($templateText);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function inlinecssDirectiveThrowsExceptionWhenMissingParameterDataProvider()
|
||||
{
|
||||
return [
|
||||
'Missing "file" parameter' => [
|
||||
'{{inlinecss}}',
|
||||
],
|
||||
'Missing "file" parameter value' => [
|
||||
'{{inlinecss file=""}}',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the design params
|
||||
*/
|
||||
protected function setUpDesignParams()
|
||||
{
|
||||
$themeCode = 'Vendor_EmailTest/custom_theme';
|
||||
$this->model->setDesignParams(
|
||||
[
|
||||
'area' => Area::AREA_FRONTEND,
|
||||
'theme' => $themeCode,
|
||||
'locale' => Locale::DEFAULT_SYSTEM_LOCALE,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Magento\Email\Model\Template;
|
||||
|
||||
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class VariableCompatibilityCheckerTest extends TestCase
|
||||
{
|
||||
public function testCompatibilityCheck()
|
||||
{
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
/** @var VariableCompatibilityChecker $checker */
|
||||
$checker = $objectManager->get(VariableCompatibilityChecker::class);
|
||||
$errors = $checker->getCompatibilityIssues(file_get_contents(__DIR__ . '/../_files/variables_template.html'));
|
||||
|
||||
self::assertCount(17, $errors);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,876 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
namespace Magento\Email\Model;
|
||||
|
||||
use Magento\Backend\App\Area\FrontNameResolver as BackendFrontNameResolver;
|
||||
use Magento\Framework\App\Area;
|
||||
use Magento\Framework\App\Filesystem\DirectoryList;
|
||||
use Magento\Framework\App\TemplateTypesInterface;
|
||||
use Magento\Framework\ObjectManagerInterface;
|
||||
use Magento\Framework\View\DesignInterface;
|
||||
use Magento\Store\Model\ScopeInterface;
|
||||
use Magento\Store\Model\Store;
|
||||
use Magento\TestFramework\Helper\Bootstrap;
|
||||
|
||||
/**
|
||||
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
|
||||
*/
|
||||
class TemplateTest extends \PHPUnit\Framework\TestCase
|
||||
{
|
||||
/**
|
||||
* @var Template|\PHPUnit\Framework\MockObject\MockObject
|
||||
*/
|
||||
protected $model;
|
||||
|
||||
/**
|
||||
* @var ObjectManagerInterface
|
||||
*/
|
||||
protected $objectManager;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->objectManager = Bootstrap::getObjectManager();
|
||||
}
|
||||
|
||||
protected function mockModel($filesystem = null)
|
||||
{
|
||||
if (!$filesystem) {
|
||||
$filesystem = $this->objectManager->create(\Magento\Framework\Filesystem::class);
|
||||
}
|
||||
|
||||
$this->model = $this->getMockBuilder(\Magento\Email\Model\Template::class)
|
||||
->addMethods([])
|
||||
->setConstructorArgs(
|
||||
[
|
||||
$this->objectManager->get(\Magento\Framework\Model\Context::class),
|
||||
$this->objectManager->get(\Magento\Framework\View\DesignInterface::class),
|
||||
$this->objectManager->get(\Magento\Framework\Registry::class),
|
||||
$this->objectManager->get(\Magento\Store\Model\App\Emulation::class),
|
||||
$this->objectManager->get(\Magento\Store\Model\StoreManager::class),
|
||||
$this->objectManager->create(\Magento\Framework\View\Asset\Repository::class),
|
||||
$filesystem,
|
||||
$this->objectManager->create(\Magento\Framework\App\Config\ScopeConfigInterface::class),
|
||||
$this->objectManager->get(\Magento\Email\Model\Template\Config::class),
|
||||
$this->objectManager->get(\Magento\Email\Model\TemplateFactory::class),
|
||||
$this->objectManager->get(\Magento\Framework\Filter\FilterManager::class),
|
||||
$this->objectManager->get(\Magento\Framework\UrlInterface::class),
|
||||
$this->objectManager->get(\Magento\Email\Model\Template\FilterFactory::class),
|
||||
]
|
||||
)
|
||||
->getMock();
|
||||
|
||||
$this->objectManager->get(\Magento\Framework\App\State::class)->setAreaCode('frontend');
|
||||
$this->model
|
||||
->setSenderName('sender')
|
||||
->setSenderEmail('sender@example.com')
|
||||
->setTemplateSubject('Subject')
|
||||
->setTemplateId('abc');
|
||||
}
|
||||
|
||||
public function testSetGetTemplateFilter()
|
||||
{
|
||||
$this->mockModel();
|
||||
$filter = $this->model->getTemplateFilter();
|
||||
$this->assertSame($filter, $this->model->getTemplateFilter());
|
||||
$this->assertEquals(
|
||||
$this->objectManager->get(\Magento\Store\Model\StoreManagerInterface::class)->getStore()->getId(),
|
||||
$filter->getStoreId()
|
||||
);
|
||||
|
||||
$filter = $this->objectManager->create(\Magento\Email\Model\Template\Filter::class);
|
||||
$this->model->setTemplateFilter($filter);
|
||||
$this->assertSame($filter, $this->model->getTemplateFilter());
|
||||
}
|
||||
|
||||
public function testLoadDefault()
|
||||
{
|
||||
$this->mockModel();
|
||||
$this->model->loadDefault('customer_create_account_email_template');
|
||||
$this->assertNotEmpty($this->model->getTemplateText());
|
||||
$this->assertNotEmpty($this->model->getTemplateSubject());
|
||||
$this->assertNotEmpty($this->model->getOrigTemplateVariables());
|
||||
$this->assertIsArray(json_decode($this->model->getOrigTemplateVariables(), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoAppIsolation enabled
|
||||
* @magentoDataFixture Magento/Store/_files/core_fixturestore.php
|
||||
*/
|
||||
public function testGetProcessedTemplate()
|
||||
{
|
||||
$this->mockModel();
|
||||
$this->model->setTemplateId(null);
|
||||
$this->objectManager->get(\Magento\Framework\App\AreaList::class)
|
||||
->getArea(Area::AREA_FRONTEND)
|
||||
->load();
|
||||
|
||||
$expectedViewUrl = '/frontend/Magento/blank/en_US/Magento_Theme/favicon.ico';
|
||||
$this->model->setDesignConfig(
|
||||
[
|
||||
'area' => 'frontend',
|
||||
'store' => $this->objectManager->get(\Magento\Store\Model\StoreManagerInterface::class)
|
||||
->getStore('fixturestore')
|
||||
->getId(),
|
||||
]
|
||||
);
|
||||
$this->model->setTemplateText('{{view url="Magento_Theme::favicon.ico"}}');
|
||||
|
||||
$this->setNotDefaultThemeForFixtureStore();
|
||||
$this->assertStringEndsNotWith($expectedViewUrl, $this->model->getProcessedTemplate());
|
||||
|
||||
$this->setDefaultThemeForFixtureStore();
|
||||
$this->assertStringEndsWith($expectedViewUrl, $this->model->getProcessedTemplate());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test template directive to ensure that templates can be loaded from modules
|
||||
*
|
||||
* @param string $area
|
||||
* @param string $templateId
|
||||
* @param string $expectedOutput
|
||||
* @param bool $mockThemeFallback
|
||||
*
|
||||
* @magentoDataFixture Magento/Store/_files/core_fixturestore.php
|
||||
* @magentoComponentsDir Magento/Email/Model/_files/design
|
||||
* @magentoAppIsolation enabled
|
||||
* @magentoDbIsolation enabled
|
||||
* @dataProvider templateFallbackDataProvider
|
||||
*/
|
||||
public function testTemplateFallback($area, $templateId, $expectedOutput, $mockThemeFallback = false)
|
||||
{
|
||||
$this->mockModel();
|
||||
|
||||
if ($mockThemeFallback == BackendFrontNameResolver::AREA_CODE) {
|
||||
$this->setUpAdminThemeFallback();
|
||||
} elseif ($mockThemeFallback == Area::AREA_FRONTEND) {
|
||||
$this->setUpThemeFallback($area);
|
||||
}
|
||||
|
||||
$this->model->setId($templateId);
|
||||
|
||||
$this->assertStringContainsString($expectedOutput, $this->model->processTemplate());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function templateFallbackDataProvider()
|
||||
{
|
||||
return [
|
||||
'Template from module - admin' => [
|
||||
BackendFrontNameResolver::AREA_CODE,
|
||||
'customer_create_account_email_template',
|
||||
'To sign in to our site, use these credentials during checkout',
|
||||
],
|
||||
'Template from module - frontend' => [
|
||||
Area::AREA_FRONTEND,
|
||||
'customer_create_account_email_template',
|
||||
'To sign in to our site, use these credentials during checkout',
|
||||
],
|
||||
'Template from theme - frontend' => [
|
||||
Area::AREA_FRONTEND,
|
||||
'customer_create_account_email_template',
|
||||
'customer_create_account_email_template template from Vendor/custom_theme',
|
||||
Area::AREA_FRONTEND,
|
||||
],
|
||||
'Template from parent theme - frontend' => [
|
||||
Area::AREA_FRONTEND,
|
||||
'customer_create_account_email_confirmation_template',
|
||||
'customer_create_account_email_confirmation_template template from Vendor/default',
|
||||
Area::AREA_FRONTEND,
|
||||
],
|
||||
'Template from grandparent theme - frontend' => [
|
||||
Area::AREA_FRONTEND,
|
||||
'customer_create_account_email_confirmed_template',
|
||||
'customer_create_account_email_confirmed_template template from Magento/default',
|
||||
Area::AREA_FRONTEND,
|
||||
],
|
||||
'Template from grandparent theme - adminhtml' => [
|
||||
BackendFrontNameResolver::AREA_CODE,
|
||||
'catalog_productalert_cron_error_email_template',
|
||||
'catalog_productalert_cron_error_email_template template from Magento/default',
|
||||
BackendFrontNameResolver::AREA_CODE,
|
||||
],
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Test template directive to ensure that templates can be loaded from modules, overridden in backend, and
|
||||
* overridden in themes
|
||||
*
|
||||
* @magentoDataFixture Magento/Store/_files/core_fixturestore.php
|
||||
* @magentoComponentsDir Magento/Email/Model/_files/design
|
||||
* @magentoAppIsolation enabled
|
||||
* @magentoDbIsolation enabled
|
||||
* @dataProvider templateDirectiveDataProvider
|
||||
*
|
||||
* @param string $area
|
||||
* @param int $templateType
|
||||
* @param string $templateText
|
||||
* @param string $assertStringContainsString
|
||||
* @param string $assertStringNotContainsString
|
||||
* @param string $storeConfigPath
|
||||
* @param bool $mockAdminTheme
|
||||
*/
|
||||
public function testTemplateDirective(
|
||||
$area,
|
||||
$templateType,
|
||||
$templateText,
|
||||
$assertStringContainsString,
|
||||
$assertStringNotContainsString = null,
|
||||
$storeConfigPath = null,
|
||||
$mockAdminTheme = false
|
||||
) {
|
||||
$this->mockModel();
|
||||
|
||||
if ($mockAdminTheme) {
|
||||
$this->setUpAdminThemeFallback();
|
||||
} else {
|
||||
$this->setUpThemeFallback($area);
|
||||
}
|
||||
|
||||
$this->model->setTemplateType($templateType);
|
||||
$this->model->setTemplateText($templateText);
|
||||
|
||||
// Allows for testing of templates overridden in backend
|
||||
if ($storeConfigPath) {
|
||||
$template = $this->objectManager->create(\Magento\Email\Model\Template::class);
|
||||
$templateData = [
|
||||
'template_code' => 'some_unique_code',
|
||||
'template_type' => $templateType,
|
||||
'template_text' => $assertStringContainsString,
|
||||
];
|
||||
$template->setData($templateData);
|
||||
$template->save();
|
||||
|
||||
// Store the ID of the newly created template in the system config so that this template will be loaded
|
||||
$this->objectManager->get(\Magento\Framework\App\Config\MutableScopeConfigInterface::class)
|
||||
->setValue($storeConfigPath, $template->getId(), ScopeInterface::SCOPE_STORE, 'fixturestore');
|
||||
}
|
||||
|
||||
$this->assertStringContainsString($assertStringContainsString, $this->model->getProcessedTemplate());
|
||||
if ($assertStringNotContainsString) {
|
||||
$this->assertStringNotContainsString($assertStringNotContainsString, $this->model->getProcessedTemplate());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function templateDirectiveDataProvider()
|
||||
{
|
||||
return [
|
||||
'Template from module folder - adminhtml' => [
|
||||
BackendFrontNameResolver::AREA_CODE,
|
||||
TemplateTypesInterface::TYPE_HTML,
|
||||
'{{template config_path="design/email/footer_template"}}',
|
||||
"</table>\n<!-- End wrapper table -->",
|
||||
],
|
||||
'Template from module folder - frontend' => [
|
||||
Area::AREA_FRONTEND,
|
||||
TemplateTypesInterface::TYPE_HTML,
|
||||
'{{template config_path="design/email/footer_template"}}',
|
||||
"</table>\n<!-- End wrapper table -->",
|
||||
],
|
||||
'Template from module folder - plaintext' => [
|
||||
Area::AREA_FRONTEND,
|
||||
TemplateTypesInterface::TYPE_TEXT,
|
||||
'{{template config_path="design/email/footer_template"}}',
|
||||
'Thank you',
|
||||
"</table>\n<!-- End wrapper table -->",
|
||||
],
|
||||
'Template overridden in backend - adminhtml' => [
|
||||
BackendFrontNameResolver::AREA_CODE,
|
||||
TemplateTypesInterface::TYPE_HTML,
|
||||
'{{template config_path="design/email/footer_template"}}',
|
||||
'<b>Footer configured in backend - email loaded via adminhtml</b>',
|
||||
null,
|
||||
'design/email/footer_template',
|
||||
],
|
||||
'Template overridden in backend - frontend' => [
|
||||
Area::AREA_FRONTEND,
|
||||
TemplateTypesInterface::TYPE_HTML,
|
||||
'{{template config_path="design/email/footer_template"}}',
|
||||
'<b>Footer configured in backend - email loaded via frontend</b>',
|
||||
null,
|
||||
'design/email/footer_template',
|
||||
],
|
||||
'Template from theme - frontend' => [
|
||||
Area::AREA_FRONTEND,
|
||||
TemplateTypesInterface::TYPE_HTML,
|
||||
'{{template config_path="customer/create_account/email_template"}}',
|
||||
'<strong>customer_create_account_email_template template from Vendor/custom_theme</strong>',
|
||||
],
|
||||
'Template from parent theme - frontend' => [
|
||||
Area::AREA_FRONTEND,
|
||||
TemplateTypesInterface::TYPE_HTML,
|
||||
'{{template config_path="customer/create_account/email_confirmation_template"}}',
|
||||
'<strong>customer_create_account_email_confirmation_template template from Vendor/default</strong',
|
||||
],
|
||||
'Template from grandparent theme - frontend' => [
|
||||
Area::AREA_FRONTEND,
|
||||
TemplateTypesInterface::TYPE_HTML,
|
||||
'{{template config_path="customer/create_account/email_confirmed_template"}}',
|
||||
'<strong>customer_create_account_email_confirmed_template template from Magento/default</strong',
|
||||
],
|
||||
'Template from grandparent theme - adminhtml' => [
|
||||
BackendFrontNameResolver::AREA_CODE,
|
||||
TemplateTypesInterface::TYPE_HTML,
|
||||
'{{template config_path="catalog/productalert_cron/error_email_template"}}',
|
||||
'<strong>catalog_productalert_cron_error_email_template template from Magento/default</strong',
|
||||
null,
|
||||
null,
|
||||
true,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Store/_files/core_fixturestore.php
|
||||
* @magentoComponentsDir Magento/Email/Model/_files/design
|
||||
* @magentoAppIsolation enabled
|
||||
* @magentoDbIsolation enabled
|
||||
*/
|
||||
public function testTemplateLoadedFromDbIsFilteredInStrictMode()
|
||||
{
|
||||
$this->mockModel();
|
||||
|
||||
$this->setUpThemeFallback(BackendFrontNameResolver::AREA_CODE);
|
||||
|
||||
$this->model->setTemplateType(TemplateTypesInterface::TYPE_HTML);
|
||||
// The first variable should be processed because it didn't come from the DB
|
||||
$template = '{{var store.isSaveAllowed()}} - {{template config_path="design/email/footer_template"}}';
|
||||
$this->model->setTemplateText($template);
|
||||
|
||||
// Allows for testing of templates overridden in backend
|
||||
$template = $this->objectManager->create(\Magento\Email\Model\Template::class);
|
||||
$templateData = [
|
||||
'template_code' => 'some_unique_code',
|
||||
'template_type' => TemplateTypesInterface::TYPE_HTML,
|
||||
// This template will be processed in strict mode
|
||||
'template_text' => '{{var this.template_code}}'
|
||||
. ' - {{var store.isSaveAllowed()}} - {{var this.getTemplateCode()}}',
|
||||
];
|
||||
$template->setData($templateData);
|
||||
$template->save();
|
||||
|
||||
// Store the ID of the newly created template in the system config so that this template will be loaded
|
||||
$this->objectManager->get(\Magento\Framework\App\Config\MutableScopeConfigInterface::class)
|
||||
->setValue('design/email/footer_template', $template->getId(), ScopeInterface::SCOPE_STORE, 'fixturestore');
|
||||
|
||||
self::assertEquals(' - some_unique_code - - some_unique_code', $this->model->getProcessedTemplate());
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Store/_files/core_fixturestore.php
|
||||
* @magentoComponentsDir Magento/Email/Model/_files/design
|
||||
* @magentoAppIsolation enabled
|
||||
* @magentoDbIsolation enabled
|
||||
*/
|
||||
public function testLegacyTemplateLoadedFromDbIsFilteredInStrictMode()
|
||||
{
|
||||
$this->mockModel();
|
||||
|
||||
$this->setUpThemeFallback(BackendFrontNameResolver::AREA_CODE);
|
||||
|
||||
$this->model->setTemplateType(TemplateTypesInterface::TYPE_HTML);
|
||||
$template = '{{var store.isSaveAllowed()}} - {{template config_path="design/email/footer_template"}}';
|
||||
$this->model->setTemplateText($template);
|
||||
|
||||
$template = $this->objectManager->create(\Magento\Email\Model\Template::class);
|
||||
$templateData = [
|
||||
'template_code' => 'some_unique_code',
|
||||
'template_type' => TemplateTypesInterface::TYPE_HTML,
|
||||
'template_text' => '{{var this.template_code}}'
|
||||
. ' - {{var store.isSaveAllowed()}} - {{var this.getTemplateCode()}}',
|
||||
];
|
||||
$template->setData($templateData);
|
||||
$template->save();
|
||||
|
||||
// Store the ID of the newly created template in the system config so that this template will be loaded
|
||||
$this->objectManager->get(\Magento\Framework\App\Config\MutableScopeConfigInterface::class)
|
||||
->setValue('design/email/footer_template', $template->getId(), ScopeInterface::SCOPE_STORE, 'fixturestore');
|
||||
|
||||
self::assertEquals(' - some_unique_code - - some_unique_code', $this->model->getProcessedTemplate());
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoDataFixture Magento/Store/_files/core_fixturestore.php
|
||||
* @magentoComponentsDir Magento/Email/Model/_files/design
|
||||
* @magentoAppIsolation enabled
|
||||
* @magentoDbIsolation enabled
|
||||
*/
|
||||
public function testPreviewTemplateIsFilteredInStrictMode()
|
||||
{
|
||||
$this->mockModel();
|
||||
|
||||
$this->setUpThemeFallback(BackendFrontNameResolver::AREA_CODE);
|
||||
|
||||
$this->model->setTemplateType(TemplateTypesInterface::TYPE_HTML);
|
||||
$template = '{{var store.isSaveAllowed()}} - {{template config_path="design/email/footer_template"}}';
|
||||
$this->model->setTemplateText($template);
|
||||
|
||||
$template = $this->objectManager->create(\Magento\Email\Model\Template::class);
|
||||
$templateData = [
|
||||
'template_code' => 'some_unique_code',
|
||||
'template_type' => TemplateTypesInterface::TYPE_HTML,
|
||||
'template_text' => '{{var this.template_code}}'
|
||||
. ' - {{var store.isSaveAllowed()}} - {{var this.getTemplateCode()}}',
|
||||
];
|
||||
$template->setData($templateData);
|
||||
$template->save();
|
||||
|
||||
// Store the ID of the newly created template in the system config so that this template will be loaded
|
||||
$this->objectManager->get(\Magento\Framework\App\Config\MutableScopeConfigInterface::class)
|
||||
->setValue('design/email/footer_template', $template->getId(), ScopeInterface::SCOPE_STORE, 'fixturestore');
|
||||
|
||||
self::assertEquals(' - some_unique_code - - some_unique_code', $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::class);
|
||||
$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::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(
|
||||
[
|
||||
'readFile',
|
||||
]
|
||||
)
|
||||
->getMockForAbstractClass();
|
||||
|
||||
$themeDirectory->expects($this->once())
|
||||
->method('readFile')
|
||||
->willReturn('<!--@styles p { color: #111; } @--> {{var template_styles}}');
|
||||
|
||||
$filesystem = $this->getMockBuilder(\Magento\Framework\Filesystem::class)
|
||||
->disableOriginalConstructor()
|
||||
->setMethods(['getDirectoryRead'])
|
||||
->getMock();
|
||||
|
||||
$filesystem->expects($this->once())
|
||||
->method('getDirectoryRead')
|
||||
->with(DirectoryList::ROOT)
|
||||
->willReturn($themeDirectory);
|
||||
|
||||
$this->mockModel($filesystem);
|
||||
|
||||
$this->model->loadDefault('design_email_header_template');
|
||||
}
|
||||
|
||||
$processedTemplate = $this->model->getProcessedTemplate();
|
||||
|
||||
foreach ($unexpectedOutputs as $unexpectedOutput) {
|
||||
$this->assertStringNotContainsString($unexpectedOutput, $processedTemplate);
|
||||
}
|
||||
|
||||
$this->assertStringContainsString($expectedOutput, $processedTemplate);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function templateStylesVariableDataProvider()
|
||||
{
|
||||
return [
|
||||
'Styles from <!--@styles @--> comment - adminhtml' => [
|
||||
BackendFrontNameResolver::AREA_CODE,
|
||||
'p { color: #111; }',
|
||||
[
|
||||
'<!--@styles',
|
||||
'{{var template_styles}}',
|
||||
],
|
||||
],
|
||||
'Styles from <!--@styles @--> comment - frontend' => [
|
||||
Area::AREA_FRONTEND,
|
||||
'p { color: #111; }',
|
||||
[
|
||||
'<!--@styles',
|
||||
'{{var template_styles}}',
|
||||
],
|
||||
],
|
||||
'Styles from "Template Styles" textarea from backend - adminhtml' => [
|
||||
BackendFrontNameResolver::AREA_CODE,
|
||||
'p { color: #222; }',
|
||||
['{{var template_styles}}'],
|
||||
[
|
||||
'template_code' => 'some_unique_code',
|
||||
'template_type' => Template::TYPE_HTML,
|
||||
'template_text' => 'Footer from database {{var template_styles}}',
|
||||
'template_styles' => 'p { color: #222; }',
|
||||
],
|
||||
],
|
||||
'Styles from "Template Styles" textarea from backend - frontend' => [
|
||||
Area::AREA_FRONTEND,
|
||||
'p { color: #333; }',
|
||||
['{{var template_styles}}'],
|
||||
[
|
||||
'template_code' => 'some_unique_code',
|
||||
'template_type' => Template::TYPE_HTML,
|
||||
'template_text' => 'Footer from database {{var template_styles}}',
|
||||
'template_styles' => 'p { color: #333; }',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the theme fallback structure and set the Vendor_EmailTest/custom_theme as the current theme for
|
||||
* 'fixturestore' store
|
||||
*/
|
||||
protected function setUpAdminThemeFallback()
|
||||
{
|
||||
$themes = [BackendFrontNameResolver::AREA_CODE => 'Vendor_EmailTest/custom_theme'];
|
||||
$design = $this->objectManager->create(\Magento\Theme\Model\View\Design::class, ['themes' => $themes]);
|
||||
$this->objectManager->addSharedInstance($design, \Magento\Theme\Model\View\Design::class);
|
||||
/** @var \Magento\Theme\Model\Theme\Registration $registration */
|
||||
$registration = $this->objectManager->get(
|
||||
\Magento\Theme\Model\Theme\Registration::class
|
||||
);
|
||||
$registration->register();
|
||||
|
||||
// The Vendor_EmailTest/custom_theme adminhtml theme is set in the
|
||||
// dev/tests/integration/testsuite/Magento/Email/Model/_files/design/themes.php file, as it must be set
|
||||
// before the adminhtml area is loaded below.
|
||||
|
||||
Bootstrap::getInstance()->loadArea(BackendFrontNameResolver::AREA_CODE);
|
||||
|
||||
/** @var \Magento\Store\Model\Store $adminStore */
|
||||
$adminStore = $this->objectManager->create(\Magento\Store\Model\Store::class)
|
||||
->load(Store::ADMIN_CODE);
|
||||
|
||||
$this->model->setDesignConfig(
|
||||
[
|
||||
'area' => 'adminhtml',
|
||||
'store' => $adminStore->getId(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setup the theme fallback structure and set the Vendor_EmailTest/custom_theme as the current theme
|
||||
* for 'fixturestore' store
|
||||
*
|
||||
* @param $area
|
||||
*/
|
||||
protected function setUpThemeFallback($area)
|
||||
{
|
||||
/** @var \Magento\Theme\Model\Theme\Registration $registration */
|
||||
$registration = $this->objectManager->get(
|
||||
\Magento\Theme\Model\Theme\Registration::class
|
||||
);
|
||||
$registration->register();
|
||||
|
||||
// It is important to test from both areas, as emails will get sent from both, so we need to ensure that the
|
||||
// inline CSS files get loaded properly from both areas.
|
||||
Bootstrap::getInstance()->loadArea($area);
|
||||
|
||||
$collection = $this->objectManager->create(\Magento\Theme\Model\ResourceModel\Theme\Collection::class);
|
||||
|
||||
// Hard-coding theme as we want to test the fallback structure to ensure that the parent/grandparent themes of
|
||||
// Vendor_EmailTest/custom_theme will be checked for CSS files
|
||||
$themeId = $collection->getThemeByFullPath('frontend/Vendor_EmailTest/custom_theme')->getId();
|
||||
|
||||
$this->objectManager->get(\Magento\Framework\App\Config\MutableScopeConfigInterface::class)
|
||||
->setValue(
|
||||
DesignInterface::XML_PATH_THEME_ID,
|
||||
$themeId,
|
||||
ScopeInterface::SCOPE_STORE,
|
||||
'fixturestore'
|
||||
);
|
||||
|
||||
$this->model->setDesignConfig(
|
||||
[
|
||||
'area' => 'frontend',
|
||||
'store' => $this->objectManager->get(\Magento\Store\Model\StoreManagerInterface::class)
|
||||
->getStore('fixturestore')
|
||||
->getId(),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set 'Magento/luma' for the 'fixturestore' store.
|
||||
* Application isolation is required, if a test uses this method.
|
||||
*/
|
||||
protected function setNotDefaultThemeForFixtureStore()
|
||||
{
|
||||
/** @var \Magento\Framework\View\Design\ThemeInterface $theme */
|
||||
$theme = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Framework\View\Design\ThemeInterface::class
|
||||
);
|
||||
$theme->load('Magento/luma', 'theme_path');
|
||||
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
|
||||
\Magento\Framework\App\Config\MutableScopeConfigInterface::class
|
||||
)->setValue(
|
||||
\Magento\Framework\View\DesignInterface::XML_PATH_THEME_ID,
|
||||
$theme->getId(),
|
||||
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
|
||||
'fixturestore'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set 'Magento/blank' for the 'fixturestore' store.
|
||||
* Application isolation is required, if a test uses this method.
|
||||
*/
|
||||
protected function setDefaultThemeForFixtureStore()
|
||||
{
|
||||
/** @var \Magento\Framework\View\Design\ThemeInterface $theme */
|
||||
$theme = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
|
||||
\Magento\Framework\View\Design\ThemeInterface::class
|
||||
);
|
||||
$theme->load('Magento/blank', 'theme_path');
|
||||
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
|
||||
\Magento\Framework\App\Config\MutableScopeConfigInterface::class
|
||||
)->setValue(
|
||||
\Magento\Framework\View\DesignInterface::XML_PATH_THEME_ID,
|
||||
$theme->getId(),
|
||||
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
|
||||
'fixturestore'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoAppIsolation enabled
|
||||
* @magentoDataFixture Magento/Store/_files/core_fixturestore.php
|
||||
*/
|
||||
public function testGetProcessedTemplateSubject()
|
||||
{
|
||||
$this->mockModel();
|
||||
$this->objectManager->get(\Magento\Framework\App\AreaList::class)
|
||||
->getArea(Area::AREA_FRONTEND)
|
||||
->load();
|
||||
|
||||
$this->model->setTemplateSubject('{{view url="Magento_Theme::favicon.ico"}}');
|
||||
$this->model->setDesignConfig(
|
||||
[
|
||||
'area' => 'frontend',
|
||||
'store' => $this->objectManager->get(\Magento\Store\Model\StoreManagerInterface::class)
|
||||
->getStore('fixturestore')
|
||||
->getId(),
|
||||
]
|
||||
);
|
||||
|
||||
$this->setNotDefaultThemeForFixtureStore();
|
||||
$this->assertStringMatchesFormat(
|
||||
'%s/frontend/Magento/luma/en_US/Magento_Theme/favicon.ico',
|
||||
$this->model->getProcessedTemplateSubject([])
|
||||
);
|
||||
|
||||
$this->setDefaultThemeForFixtureStore();
|
||||
$this->assertStringMatchesFormat(
|
||||
'%s/frontend/Magento/blank/en_US/Magento_Theme/favicon.ico',
|
||||
$this->model->getProcessedTemplateSubject([])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoAppIsolation enabled
|
||||
*/
|
||||
public function testGetDefaultEmailLogo()
|
||||
{
|
||||
$this->mockModel();
|
||||
$this->objectManager->get(\Magento\Framework\App\AreaList::class)
|
||||
->getArea(Area::AREA_FRONTEND)
|
||||
->load();
|
||||
|
||||
$this->assertStringEndsWith(
|
||||
'/frontend/Magento/luma/en_US/Magento_Email/logo_email.png',
|
||||
$this->model->getDefaultEmailLogo()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $config
|
||||
* @dataProvider setDesignConfigExceptionDataProvider
|
||||
*/
|
||||
public function testSetDesignConfigException($config)
|
||||
{
|
||||
$this->expectException(\Magento\Framework\Exception\LocalizedException::class);
|
||||
|
||||
$this->mockModel();
|
||||
$model = $this->objectManager->create(\Magento\Email\Model\Template::class);
|
||||
$model->setDesignConfig($config);
|
||||
}
|
||||
|
||||
public function setDesignConfigExceptionDataProvider()
|
||||
{
|
||||
$storeId = Bootstrap::getObjectManager()->get(\Magento\Store\Model\StoreManagerInterface::class)
|
||||
->getStore()
|
||||
->getId();
|
||||
|
||||
return [
|
||||
[[]],
|
||||
[['area' => 'frontend']],
|
||||
[['store' => $storeId]],
|
||||
];
|
||||
}
|
||||
|
||||
public function testSetAndGetId()
|
||||
{
|
||||
$this->mockModel();
|
||||
$testId = 9999;
|
||||
$this->model->setId($testId);
|
||||
$this->assertEquals($testId, $this->model->getId());
|
||||
}
|
||||
|
||||
public function testIsValidForSend()
|
||||
{
|
||||
$this->mockModel();
|
||||
$this->assertTrue($this->model->isValidForSend());
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function testGetTypeNonExistentType()
|
||||
{
|
||||
$this->expectException(\UnexpectedValueException::class);
|
||||
$this->expectExceptionMessage('Email template \'foo\' is not defined.');
|
||||
|
||||
$this->mockModel();
|
||||
$this->model->setId('foo');
|
||||
$this->model->getType();
|
||||
}
|
||||
|
||||
public function testGetTypeHtml()
|
||||
{
|
||||
$this->mockModel();
|
||||
$this->model->setId('customer_create_account_email_template');
|
||||
$this->assertEquals(TemplateTypesInterface::TYPE_HTML, $this->model->getType());
|
||||
}
|
||||
|
||||
public function testGetType()
|
||||
{
|
||||
$this->mockModel();
|
||||
$templateTypeId = 'test_template';
|
||||
$this->model->setTemplateType($templateTypeId);
|
||||
$this->assertEquals($templateTypeId, $this->model->getType());
|
||||
}
|
||||
|
||||
public function testGetSendingException()
|
||||
{
|
||||
$this->mockModel();
|
||||
$this->assertNull($this->model->getSendingException());
|
||||
}
|
||||
|
||||
public function testGetVariablesOptionArray()
|
||||
{
|
||||
$this->mockModel();
|
||||
$testTemplateVariables = '{"var data.name":"Sender Name","var data.email":"Sender Email"}';
|
||||
$this->model->setOrigTemplateVariables($testTemplateVariables);
|
||||
$variablesOptionArray = $this->model->getVariablesOptionArray();
|
||||
$this->assertEquals('{{var data.name}}', $variablesOptionArray[0]['value']);
|
||||
$this->assertEquals('Sender Name', $variablesOptionArray[0]['label']->getArguments()[0]);
|
||||
$this->assertEquals('{{var data.email}}', $variablesOptionArray[1]['value']);
|
||||
$this->assertEquals('Sender Email', $variablesOptionArray[1]['label']->getArguments()[0]);
|
||||
}
|
||||
|
||||
public function testGetVariablesOptionArrayInGroup()
|
||||
{
|
||||
$this->mockModel();
|
||||
$testTemplateVariables = '{"var data.name":"Sender Name","var data.email":"Sender Email"}';
|
||||
$this->model->setOrigTemplateVariables($testTemplateVariables);
|
||||
$variablesOptionArray = $this->model->getVariablesOptionArray(true);
|
||||
$this->assertEquals('Template Variables', $variablesOptionArray['label']->getText());
|
||||
$this->assertEquals($this->model->getVariablesOptionArray(), $variablesOptionArray['value']);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public function testBeforeSaveEmptyTemplateCode()
|
||||
{
|
||||
$this->expectException(\Magento\Framework\Exception\MailException::class);
|
||||
$this->expectExceptionMessage('Please enter a template name.');
|
||||
|
||||
$this->mockModel();
|
||||
$this->model->beforeSave();
|
||||
}
|
||||
|
||||
public function testBeforeSave()
|
||||
{
|
||||
$this->mockModel();
|
||||
$this->model->setTemplateCode('test template code');
|
||||
$this->model->beforeSave();
|
||||
}
|
||||
|
||||
public function testProcessTemplate()
|
||||
{
|
||||
$this->mockModel();
|
||||
$this->model->setId('customer_create_account_email_template');
|
||||
$this->assertStringContainsString('<body', $this->model->processTemplate());
|
||||
}
|
||||
|
||||
public function testGetSubject()
|
||||
{
|
||||
$this->mockModel();
|
||||
$this->model->setVars(['foo', 'bar', 'baz']);
|
||||
$this->assertEquals('Subject', $this->model->getSubject());
|
||||
}
|
||||
|
||||
public function testSetOptions()
|
||||
{
|
||||
$this->mockModel();
|
||||
$options = ['area' => 'test area', 'store' => 1];
|
||||
$this->model->setOptions($options);
|
||||
$this->assertEquals($options, $this->model->getDesignConfig()->getData());
|
||||
}
|
||||
|
||||
/**
|
||||
* @magentoConfigFixture default_store general/store_information/name Test Store
|
||||
* @magentoConfigFixture default_store general/store_information/street_line1 Street 1
|
||||
* @magentoConfigFixture default_store general/store_information/street_line2 Street 2
|
||||
* @magentoConfigFixture default_store general/store_information/city Austin
|
||||
* @magentoConfigFixture default_store general/store_information/zip 78758
|
||||
* @magentoConfigFixture default_store general/store_information/country_id US
|
||||
* @magentoConfigFixture default_store general/store_information/region_id 57
|
||||
*/
|
||||
public function testStoreFormattedAddress()
|
||||
{
|
||||
$this->mockModel();
|
||||
$this->model->setTemplateType(TemplateTypesInterface::TYPE_HTML);
|
||||
|
||||
/* See app/design/frontend/Magento/luma/Magento_Email/email/footer.html */
|
||||
$template = '{{var store.formatted_address|raw}}';
|
||||
$this->model->setTemplateText($template);
|
||||
|
||||
$result = $this->model->getProcessedTemplate();
|
||||
$this->assertStringContainsString('Test Store', $result);
|
||||
$this->assertStringContainsString('Street 1', $result);
|
||||
$this->assertStringContainsString('Street 2', $result);
|
||||
$this->assertStringContainsString('Austin', $result);
|
||||
$this->assertStringContainsString('Texas', $result);
|
||||
$this->assertStringContainsString('United States', $result);
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<!--@subject {{trans "Footer"}} @-->
|
||||
Footer from module directory
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<!--@subject {{trans "Header"}} @-->
|
||||
<!--@styles p { color: #111; } @--> {{var template_styles}}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
|
||||
<block class="Magento\Backend\Block\Template" name="sample_email_content" template="Magento_Email::sample_email_content.phtml"/>
|
||||
</layout>
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
?>
|
||||
<strong>Email content for adminhtml/Magento/default theme</strong>
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<strong>catalog_productalert_cron_error_email_template template from Magento/default</strong>
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
|
||||
ComponentRegistrar::register(ComponentRegistrar::THEME, 'adminhtml/Magento_EmailTest/default', __DIR__);
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
|
||||
<title>Adminhtml - Magento_EmailTest/default</title>
|
||||
</theme>
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
|
||||
ComponentRegistrar::register(ComponentRegistrar::THEME, 'adminhtml/Vendor_EmailTest/custom_theme', __DIR__);
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
|
||||
<title>Adminhtml - Vendor_EmailTest/custom_theme</title>
|
||||
<parent>Vendor_EmailTest/default</parent>
|
||||
</theme>
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
|
||||
ComponentRegistrar::register(ComponentRegistrar::THEME, 'adminhtml/Vendor_EmailTest/default', __DIR__);
|
||||
dev/tests/integration/testsuite/Magento/Email/Model/_files/design/adminhtml/Vendor/default/theme.xml
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
|
||||
<title>Adminhtml - Vendor_EmailTest/default</title>
|
||||
<parent>Magento_EmailTest/default</parent>
|
||||
</theme>
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<strong>customer_create_account_email_confirmed_template template from Magento/default</strong>
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0"?>
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
|
||||
<block class="Magento\Framework\View\Element\Template" name="sample_email_content" template="Magento_Email::sample_email_content.phtml"/>
|
||||
<block class="Magento\Framework\View\Element\Text" name="ignored_email_content">
|
||||
<action method="setText">
|
||||
<argument name="text" xsi:type="string">Ignored email content, only the first block is used</argument>
|
||||
</action>
|
||||
</block>
|
||||
</layout>
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
?>
|
||||
<strong>Email content for frontend/Magento/default theme</strong>
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
?>
|
||||
<strong>Custom Email content for frontend/Magento/default theme</strong>
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
|
||||
ComponentRegistrar::register(ComponentRegistrar::THEME, 'frontend/Magento_EmailTest/default', __DIR__);
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
|
||||
<title>Frontend - Magento_EmailTest/default</title>
|
||||
</theme>
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
p {
|
||||
color: #333;
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
p {
|
||||
color: #333;
|
||||
text-align: left;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
p {
|
||||
color: @non-existent-variable;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<strong>customer_create_account_email_template template from Vendor/custom_theme</strong>
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
|
||||
ComponentRegistrar::register(ComponentRegistrar::THEME, 'frontend/Vendor_EmailTest/custom_theme', __DIR__);
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
|
||||
<title>Frontend - Vendor_EmailTest/custom_theme</title>
|
||||
<parent>Vendor_EmailTest/default</parent>
|
||||
</theme>
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
p {
|
||||
color: #111;
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
p {
|
||||
color: #111;
|
||||
text-align: left;
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<strong>customer_create_account_email_confirmation_template template from Vendor/default</strong>
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
use Magento\Framework\Component\ComponentRegistrar;
|
||||
|
||||
ComponentRegistrar::register(ComponentRegistrar::THEME, 'frontend/Vendor_EmailTest/default', __DIR__);
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<theme xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Config/etc/theme.xsd">
|
||||
<title>Frontend - Vendor_EmailTest/default</title>
|
||||
<parent>Magento_EmailTest/default</parent>
|
||||
</theme>
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
p {
|
||||
color: #222;
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
p {
|
||||
color: #222;
|
||||
text-align: left;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
/** @var \Magento\Email\Model\Template $template */
|
||||
$template = $objectManager->create(\Magento\Email\Model\Template::class);
|
||||
$template->setOptions(['area' => 'test area', 'store' => 1]);
|
||||
$template->setData(
|
||||
[
|
||||
'template_text' => file_get_contents(__DIR__ . '/template_fixture.html'),
|
||||
'template_code' => \Magento\Theme\Model\Config\ValidatorTest::TEMPLATE_CODE,
|
||||
'template_type' => \Magento\Email\Model\Template::TYPE_TEXT
|
||||
]
|
||||
);
|
||||
$template->save();
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
/** @var \Magento\Email\Model\Template $template */
|
||||
$template = $objectManager->create(\Magento\Email\Model\Template::class);
|
||||
$template->setOptions(['area' => 'test area', 'store' => 1]);
|
||||
$templateText = '{{trans "New User Notification Custom Text %first_name, ' .
|
||||
'%last_name" first_name=$user.firstname last_name=$user.lastname}}';
|
||||
$template->setData(
|
||||
[
|
||||
'template_text' => $templateText,
|
||||
'template_code' => 'New User Notification Custom Code',
|
||||
'template_type' => \Magento\Email\Model\Template::TYPE_TEXT,
|
||||
'orig_template_code' => 'admin_emails_new_user_notification_template'
|
||||
]
|
||||
);
|
||||
$template->save();
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
|
||||
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
|
||||
$origTemplateCode = 'admin_emails_forgot_email_template';
|
||||
/** @var \Magento\Email\Model\Template $template */
|
||||
$template = $objectManager->create(\Magento\Email\Model\Template::class);
|
||||
$template->loadDefault($origTemplateCode);
|
||||
$template->setTemplateCode('Reset Password User Notification Custom Code');
|
||||
$template->setOrigTemplateCode('admin_emails_forgot_email_template');
|
||||
$template->setId(null);
|
||||
$template->save();
|
||||
@@ -0,0 +1,29 @@
|
||||
{{template config_path="design/email/header_template"}}
|
||||
|
||||
<p class="greeting">{{trans "%name," name=$customer.name}}</p>
|
||||
<p>{{trans "Welcome to %store_name." store_name=$store.getFrontendName()}}</p>
|
||||
<p>
|
||||
{{trans
|
||||
'To sign in to our site, use these credentials during checkout or on the <a href="%customer_url">My Account</a> page:'
|
||||
|
||||
customer_url=$this.getUrl($store,'customer/account/',[_nosid:1])
|
||||
|raw}}
|
||||
</p>
|
||||
<ul>
|
||||
<li><strong>{{trans "Email:"}}</strong> {{var customer.email}}</li>
|
||||
<li><strong>{{trans "Password:"}}</strong> <em>{{trans "Password you set when creating account"}}</em></li>
|
||||
</ul>
|
||||
<p>
|
||||
{{trans
|
||||
'Forgot your account password? Click <a href="%reset_url">here</a> to reset it.'
|
||||
|
||||
reset_url="$this.getUrl($store,'customer/account/createPassword/',[_query:[id:$customer.id,token:$customer.rp_token],_nosid:1])"
|
||||
|raw}}
|
||||
</p>
|
||||
<p>{{trans "When you sign in to your account, you will be able to:"}}</p>
|
||||
<ul>
|
||||
<li>{{trans "Proceed through checkout faster"}}</li>
|
||||
<li>{{trans "Check the status of orders"}}</li>
|
||||
<li>{{trans "View past orders"}}</li>
|
||||
<li>{{trans "Store alternative addresses (for shipping to multiple family members and friends)"}}</li>
|
||||
</ul>
|
||||
@@ -0,0 +1,76 @@
|
||||
<!--
|
||||
/**
|
||||
* Copyright © Magento, Inc. All rights reserved.
|
||||
* See COPYING.txt for license details.
|
||||
*/
|
||||
-->
|
||||
<div>{{var foo.good}}</div>
|
||||
<div>{{var foo.good|stillfine}}</div>
|
||||
<div>{{var foo.bad()}}</div>
|
||||
<div>{{var foo.bad()|alsobad}}</div>
|
||||
<div>{{var foo.getGood()}}</div>
|
||||
<div>{{var foo.foo.getGood()}}</div>
|
||||
<div>{{var foo.getGood().fine}}</div>
|
||||
<div>{{var foo.getGood().fine|alsofine}}</div>
|
||||
<div>{{var foo.bad($bad.param())}}</div>
|
||||
<div>{{var foo.bad.baz()}}</div>
|
||||
<div>{{var foo.undeclared.baz}}</div>
|
||||
<div>{{trans "foo %bar" bar=$foo.good.trans}}</div>
|
||||
<div>{{trans "foo %bar" bar=$foo.bad.trans()}}</div>
|
||||
<div>{{trans "foo %bar" bar="something"}}</div>
|
||||
<div>{{trans "foo %bar" bar="something" bad="$bad.bad()" something=$undeclared.var.error}}</div>
|
||||
<div>{{something "
|
||||
<blah>foo %bar</blah>blah
|
||||
" bar="something"
|
||||
}}</div>
|
||||
<div>{{something "
|
||||
<blah>foo %bar</blah>blah
|
||||
" bar="something" bad=$bad.multiline()
|
||||
}}</div>
|
||||
|
||||
{{if foo.goodif}}
|
||||
<div>{{var foo.goodif2}}</div>
|
||||
{{/if}}
|
||||
|
||||
{{if foo.goodif}}
|
||||
<div>{{var foo.goodif2}}</div>
|
||||
{{else}}
|
||||
<div>{{var foo.goodif3}}</div>
|
||||
{{/if}}
|
||||
|
||||
{{if foo.badif().bad}}
|
||||
<div>{{var foo.badif2()}}</div>
|
||||
{{/if}}
|
||||
|
||||
{{if foo.badif3()}}
|
||||
<div>{{var foo.badif4()}}</div>
|
||||
{{else}}
|
||||
<div>{{var foo.badif5()}}</div>
|
||||
{{/if}}
|
||||
|
||||
{{depend foo.gooddepend}}
|
||||
<div>{{var foo.gooddepend2}}</div>
|
||||
{{/depend}}
|
||||
|
||||
{{depend foo.badDepend().bad}}
|
||||
<div>{{var foo.baddepend2()}}</div>
|
||||
{{/depend}}
|
||||
|
||||
{{for item in foo.goodFor}}
|
||||
<div>{{var foo.goodFor}}</div>
|
||||
<div>{{var foo.goodFor|stillfine}}</div>
|
||||
<div>{{var foo.badFor()}}</div>
|
||||
<div>{{var foo.badFor()|alsobad}}</div>
|
||||
{{/for}}
|
||||
|
||||
{{for item in foo.getGoodFor()}}
|
||||
<div>loopy</div>
|
||||
{{/for}}
|
||||
|
||||
{{for item in foo.badForLoop()}}
|
||||
<div>this loop has a bad variable</div>
|
||||
{{/for}}
|
||||
|
||||
{{depend iusefilterslater}}
|
||||
{{var iusefilterslater|raw}}
|
||||
{{/depend}}
|
||||
Reference in New Issue
Block a user