TemplateEnginePoolTest.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\View\Test\Unit;
  7. use \Magento\Framework\View\TemplateEnginePool;
  8. class TemplateEnginePoolTest extends \PHPUnit\Framework\TestCase
  9. {
  10. /**
  11. * @var TemplateEnginePool
  12. */
  13. protected $_model;
  14. /**
  15. * @var\PHPUnit_Framework_MockObject_MockObject
  16. */
  17. protected $_factory;
  18. protected function setUp()
  19. {
  20. $this->_factory = $this->createMock(\Magento\Framework\View\TemplateEngineFactory::class);
  21. $this->_model = new TemplateEnginePool($this->_factory);
  22. }
  23. public function testGet()
  24. {
  25. $engine = $this->createMock(\Magento\Framework\View\TemplateEngineInterface::class);
  26. $this->_factory->expects($this->once())->method('create')->with('test')->will($this->returnValue($engine));
  27. $this->assertSame($engine, $this->_model->get('test'));
  28. // Make sure factory is invoked only once and the same instance is returned afterwards
  29. $this->assertSame($engine, $this->_model->get('test'));
  30. }
  31. }