@@ -14,18 +14,43 @@ class TemplateTest extends \PHPUnit_Framework_TestCase
14
14
*/
15
15
protected $ _block ;
16
16
17
+ /**
18
+ * @var \Magento\TestFramework\ObjectManager
19
+ */
20
+ protected $ objectManager ;
21
+
22
+ /**
23
+ * @var string
24
+ */
25
+ private $ origMode ;
26
+
17
27
protected function setUp ()
18
28
{
19
- $ objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
20
- $ params = ['layout ' => $ objectManager ->create (\Magento \Framework \View \Layout::class, [])];
21
- $ context = $ objectManager ->create (\Magento \Framework \View \Element \Template \Context::class, $ params );
29
+ $ this -> objectManager = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ();
30
+ $ params = ['layout ' => $ this -> objectManager ->create (\Magento \Framework \View \Layout::class, [])];
31
+ $ context = $ this -> objectManager ->create (\Magento \Framework \View \Element \Template \Context::class, $ params );
22
32
$ this ->_block = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->get (
23
33
\Magento \Framework \View \LayoutInterface::class
24
34
)->createBlock (
25
35
\Magento \Framework \View \Element \Template::class,
26
36
'' ,
27
37
['context ' => $ context ]
28
38
);
39
+
40
+ /** @var \Magento\TestFramework\App\State $appState */
41
+ $ appState = $ this ->objectManager ->get (\Magento \TestFramework \App \State::class);
42
+ $ this ->origMode = $ appState ->getMode ();
43
+ }
44
+
45
+ /**
46
+ * {@inheritDoc}
47
+ */
48
+ protected function tearDown ()
49
+ {
50
+ /** @var \Magento\TestFramework\App\State $appState */
51
+ $ appState = $ this ->objectManager ->get (\Magento \TestFramework \App \State::class);
52
+ $ appState ->setMode ($ this ->origMode );
53
+ parent ::tearDown ();
29
54
}
30
55
31
56
public function testConstruct ()
@@ -70,6 +95,9 @@ public function testToHtml()
70
95
{
71
96
\Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->get (\Magento \Framework \App \State::class)
72
97
->setAreaCode (Area::AREA_GLOBAL );
98
+ /** @var \Magento\TestFramework\App\State $appState */
99
+ $ appState = $ this ->objectManager ->get (\Magento \TestFramework \App \State::class);
100
+ $ appState ->setMode (\Magento \TestFramework \App \State::MODE_DEFAULT );
73
101
$ this ->assertEmpty ($ this ->_block ->toHtml ());
74
102
$ this ->_block ->setTemplate (uniqid ('invalid_filename.phtml ' ));
75
103
$ this ->assertEmpty ($ this ->_block ->toHtml ());
0 commit comments