|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | + |
| 7 | +namespace Magento\Bundle\Test\Unit\Observer; |
| 8 | + |
| 9 | +use Magento\Bundle\Observer\InitOptionRendererObserver; |
| 10 | +use Magento\Framework\Event\Observer; |
| 11 | +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; |
| 12 | +use Magento\Wishlist\Block\Customer\Wishlist\Item\Options; |
| 13 | +use PHPUnit\Framework\MockObject\MockObject; |
| 14 | +use PHPUnit\Framework\TestCase; |
| 15 | + |
| 16 | +/** |
| 17 | + * Test class for \Magento\Bundle\Observer\InitOptionRendererObserver |
| 18 | + */ |
| 19 | +class InitOptionRendererObserverTest extends TestCase |
| 20 | +{ |
| 21 | + /** |
| 22 | + * @var Options|MockObject |
| 23 | + */ |
| 24 | + private $blockMock; |
| 25 | + |
| 26 | + /** |
| 27 | + * Object Manager Instance |
| 28 | + * |
| 29 | + * @var ObjectManager |
| 30 | + */ |
| 31 | + private $objectManager; |
| 32 | + |
| 33 | + /** |
| 34 | + * Testable Object |
| 35 | + * |
| 36 | + * @var InitOptionRendererObserver |
| 37 | + */ |
| 38 | + private $observer; |
| 39 | + |
| 40 | + /** |
| 41 | + * @var Observer|MockObject |
| 42 | + */ |
| 43 | + private $observerMock; |
| 44 | + |
| 45 | + /** |
| 46 | + * @inheritdoc |
| 47 | + */ |
| 48 | + protected function setUp() : void |
| 49 | + { |
| 50 | + $this->objectManager = new ObjectManager($this); |
| 51 | + $this->observerMock = $this->getMockBuilder(Observer::class) |
| 52 | + ->disableOriginalConstructor() |
| 53 | + ->setMethods(['getBlock']) |
| 54 | + ->getMock(); |
| 55 | + |
| 56 | + $this->blockMock = $this->getMockBuilder(Options::class) |
| 57 | + ->disableOriginalConstructor() |
| 58 | + ->setMethods(['addOptionsRenderCfg']) |
| 59 | + ->getMock(); |
| 60 | + |
| 61 | + $this->observer = $this->objectManager->getObject(InitOptionRendererObserver::class); |
| 62 | + } |
| 63 | + |
| 64 | + /** |
| 65 | + * Test observer execute method |
| 66 | + */ |
| 67 | + public function testProductOptionRendererInit() |
| 68 | + { |
| 69 | + $this->observerMock |
| 70 | + ->expects($this->once()) |
| 71 | + ->method('getBlock') |
| 72 | + ->willReturn($this->blockMock); |
| 73 | + |
| 74 | + $this->blockMock |
| 75 | + ->expects($this->once()) |
| 76 | + ->method('addOptionsRenderCfg') |
| 77 | + ->willReturn($this->blockMock); |
| 78 | + |
| 79 | + $this->observer->execute($this->observerMock); |
| 80 | + } |
| 81 | +} |
0 commit comments