![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-gift-message/Test/Unit/Helper/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\GiftMessage\Test\Unit\Helper; use Magento\Framework\DataObject; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Framework\View\Layout; use Magento\Framework\View\LayoutFactory; use Magento\GiftMessage\Block\Message\Inline; use Magento\GiftMessage\Helper\Message; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class MessageTest extends TestCase { /** * @var MockObject */ protected $layoutFactoryMock; /** * @var Message */ protected $helper; protected function setUp(): void { $objectManager = new ObjectManager($this); $this->layoutFactoryMock = $this->createMock(LayoutFactory::class); $this->helper = $objectManager->getObject( Message::class, [ 'layoutFactory' => $this->layoutFactoryMock, 'skipMessageCheck' => ['onepage_checkout'] ] ); } /** * Make sure that isMessagesAllowed is not called */ public function testGetInlineForCheckout() { $expectedHtml = '<a href="here">here</a>'; $layoutMock = $this->createMock(Layout::class); $entityMock = $this->createMock(DataObject::class); $inlineMock = $this->getMockBuilder(Inline::class) ->addMethods(['setId', 'setDontDisplayContainer']) ->onlyMethods(['setEntity', 'setCheckoutType', 'toHtml']) ->disableOriginalConstructor() ->getMock(); $this->layoutFactoryMock->expects($this->once())->method('create')->willReturn($layoutMock); $layoutMock->expects($this->once())->method('createBlock')->willReturn($inlineMock); $inlineMock->expects($this->once())->method('setId')->willReturnSelf(); $inlineMock->expects($this->once())->method('setDontDisplayContainer')->willReturnSelf(); $inlineMock->expects($this->once())->method('setEntity')->with($entityMock)->willReturnSelf(); $inlineMock->expects($this->once())->method('setCheckoutType')->willReturnSelf(); $inlineMock->expects($this->once())->method('toHtml')->willReturn($expectedHtml); $this->assertEquals($expectedHtml, $this->helper->getInline('onepage_checkout', $entityMock)); } }