Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
TemplateEnginePoolTest.php
Go to the documentation of this file.
1 <?php
7 
8 use \Magento\Framework\View\TemplateEnginePool;
9 
10 class TemplateEnginePoolTest extends \PHPUnit\Framework\TestCase
11 {
15  protected $_model;
16 
20  protected $_factory;
21 
22  protected function setUp()
23  {
24  $this->_factory = $this->createMock(\Magento\Framework\View\TemplateEngineFactory::class);
25  $this->_model = new TemplateEnginePool($this->_factory);
26  }
27 
28  public function testGet()
29  {
30  $engine = $this->createMock(\Magento\Framework\View\TemplateEngineInterface::class);
31  $this->_factory->expects($this->once())->method('create')->with('test')->will($this->returnValue($engine));
32  $this->assertSame($engine, $this->_model->get('test'));
33  // Make sure factory is invoked only once and the same instance is returned afterwards
34  $this->assertSame($engine, $this->_model->get('test'));
35  }
36 }