Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ChangeTemplateObserverTest.php
Go to the documentation of this file.
1 <?php
8 
9 use \Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
10 
11 class ChangeTemplateObserverTest extends \PHPUnit\Framework\TestCase
12 {
13  public function testChangeTemplate()
14  {
16  $observer = $this->createPartialMock(\Magento\Framework\Event\Observer::class, ['getBlock']);
17 
22  $block = $this->createMock(\Magento\ProductVideo\Block\Adminhtml\Product\Edit\NewVideo::class);
23  $block->expects($this->once())
24  ->method('setTemplate')
25  ->with('Magento_ProductVideo::helper/gallery.phtml')
26  ->willReturnSelf();
27  $observer->expects($this->once())->method('getBlock')->willReturn($block);
28 
30  $this->objectManager = new ObjectManager($this);
31  $unit = $this->objectManager->getObject(\Magento\ProductVideo\Observer\ChangeTemplateObserver::class);
32  $unit->execute($observer);
33  }
34 }
$block
Definition: block.php:8