Skip to content

Commit 194eaf3

Browse files
committed
Add default mode to integration element template test
1 parent b7ca3be commit 194eaf3

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

dev/tests/integration/testsuite/Magento/Framework/View/Element/TemplateTest.php

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,43 @@ class TemplateTest extends \PHPUnit_Framework_TestCase
1414
*/
1515
protected $_block;
1616

17+
/**
18+
* @var \Magento\TestFramework\ObjectManager
19+
*/
20+
protected $objectManager;
21+
22+
/**
23+
* @var string
24+
*/
25+
private $origMode;
26+
1727
protected function setUp()
1828
{
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);
2232
$this->_block = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(
2333
\Magento\Framework\View\LayoutInterface::class
2434
)->createBlock(
2535
\Magento\Framework\View\Element\Template::class,
2636
'',
2737
['context' => $context]
2838
);
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();
2954
}
3055

3156
public function testConstruct()
@@ -70,6 +95,9 @@ public function testToHtml()
7095
{
7196
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get(\Magento\Framework\App\State::class)
7297
->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);
73101
$this->assertEmpty($this->_block->toHtml());
74102
$this->_block->setTemplate(uniqid('invalid_filename.phtml'));
75103
$this->assertEmpty($this->_block->toHtml());

0 commit comments

Comments
 (0)