Skip to content

Commit d3aef7c

Browse files
committed
MAGETWO-89261: Template file 'header.html' is not found.
1 parent c42130d commit d3aef7c

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed

app/code/Magento/Theme/Model/Design/Config/Validator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ private function getTemplateText($templateId, DesignConfigInterface $designConfi
114114
if (is_numeric($templateId)) {
115115
$template->load($templateId);
116116
} else {
117+
$template->setForcedArea($templateId);
117118
$template->loadDefault($templateId);
118119
}
119120
$text = $template->getTemplateText();
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Theme\Test\Unit\Model\Design\Config;
8+
9+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
10+
use Magento\Theme\Model\Design\Config\Validator;
11+
12+
/**
13+
* Unit tests for Magento\Theme\Test\Unit\Model\Design\Config\Validator.
14+
*/
15+
class ValidatorTest extends \PHPUnit\Framework\TestCase
16+
{
17+
/**
18+
* @var \Magento\Framework\Mail\TemplateInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject
19+
*/
20+
private $templateFactory;
21+
22+
/**
23+
* @var \Magento\Framework\Mail\TemplateInterface|\PHPUnit_Framework_MockObject_MockObject
24+
*/
25+
private $template;
26+
27+
/**
28+
* @var \Magento\Theme\Api\Data\DesignConfigInterface|\PHPUnit_Framework_MockObject_MockObject
29+
*/
30+
private $designConfig;
31+
32+
/**
33+
* @var ObjectManager
34+
*/
35+
private $objectManager;
36+
37+
/**
38+
* @inheritdoc
39+
*/
40+
public function setUp()
41+
{
42+
$this->objectManager = new ObjectManager($this);
43+
$this->templateFactory = $this->getMockBuilder(\Magento\Framework\Mail\TemplateInterfaceFactory::class)
44+
->disableOriginalConstructor()
45+
->setMethods(['create'])
46+
->getMockForAbstractClass();
47+
$this->template = $this->getMockBuilder(\Magento\Framework\Mail\TemplateInterface::class)
48+
->disableOriginalConstructor()
49+
->setMethods(
50+
[
51+
'emulateDesign',
52+
'setForcedArea',
53+
'loadDefault',
54+
'getTemplateText',
55+
'revertDesign',
56+
]
57+
)
58+
->getMockForAbstractClass();
59+
$this->templateFactory->expects($this->any())->method('create')->willReturn($this->template);
60+
$this->designConfig = $this->getMockBuilder(\Magento\Theme\Api\Data\DesignConfigInterface::class)
61+
->disableOriginalConstructor()
62+
->setMethods(['getExtensionAttributes'])
63+
->getMockForAbstractClass();
64+
}
65+
66+
/**
67+
* @return void
68+
*/
69+
public function testGetDefaultTemplateTextDefaultScope()
70+
{
71+
$templateId = 'email_template';
72+
$designData = [
73+
'field_config' => ['field' => 'fieldValue'],
74+
'value' => $templateId,
75+
];
76+
77+
$this->templateFactory->expects($this->once())->method('create');
78+
$this->designConfig->expects($this->any())->method('getScope')->willReturn('default');
79+
$this->template->expects($this->once())->method('emulateDesign');
80+
$this->template->expects($this->once())->method('setForcedArea')->with($templateId);
81+
$this->template->expects($this->once())->method('loadDefault')->with($templateId);
82+
$this->template->expects($this->once())->method('getTemplateText');
83+
$this->template->expects($this->once())->method('revertDesign');
84+
85+
$extensionAttributes = $this->getMockBuilder(\Magento\Theme\Api\Data\DesignConfigExtensionInterface::class)
86+
->disableOriginalConstructor()
87+
->setMethods(['getDesignConfigData'])
88+
->getMockForAbstractClass();
89+
90+
$extensionAttributes->expects($this->any())->method('getDesignConfigData')->willReturn(
91+
[
92+
$this->getDesignConfigData($designData),
93+
]
94+
);
95+
96+
$this->designConfig->expects($this->any())->method('getExtensionAttributes')->willReturn($extensionAttributes);
97+
98+
/** @var Validator $validator */
99+
$validator = $this->objectManager->getObject(
100+
Validator::class,
101+
[
102+
'templateFactory' => $this->templateFactory,
103+
'fields' => ['field' => 'fieldValue'],
104+
]
105+
);
106+
$validator->validate($this->designConfig);
107+
}
108+
109+
/**
110+
* Returns design config data object.
111+
*
112+
* @param array $data
113+
* @return \Magento\Theme\Model\Data\Design\Config\Data
114+
*/
115+
private function getDesignConfigData(array $data = [])
116+
{
117+
return $this->objectManager->getObject(
118+
\Magento\Theme\Model\Data\Design\Config\Data::class,
119+
[
120+
'data' => $data,
121+
]
122+
);
123+
}
124+
}

0 commit comments

Comments
 (0)