![]() 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-payment/Test/Unit/Block/Info/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Payment\Test\Unit\Block\Info; use Magento\Framework\App\Config\ScopeConfigInterface; use Magento\Framework\Event\ManagerInterface; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; use Magento\Framework\View\Element\AbstractBlock; use Magento\Framework\View\Element\Template; use Magento\Framework\View\Element\Template\Context; use Magento\Framework\View\LayoutInterface; use Magento\Payment\Block\Info\Substitution; use Magento\Payment\Model\Info; use Magento\Payment\Model\MethodInterface; use Magento\Store\Model\ScopeInterface; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; /** * @SuppressWarnings(PHPMD.CouplingBetweenObjects) */ class SubstitutionTest extends TestCase { /** * @var MockObject */ protected $layout; /** * @var Substitution */ protected $block; /** * @var ObjectManager */ protected $objectManager; /** * @inheritdoc */ protected function setUp(): void { $this->objectManager = new ObjectManager($this); $this->layout = $this->getMockBuilder( LayoutInterface::class )->disableOriginalConstructor() ->setMethods( [] )->getMock(); $eventManager = $this->getMockBuilder( ManagerInterface::class )->disableOriginalConstructor() ->setMethods( [] )->getMock(); $scopeConfig = $this->getMockBuilder( ScopeConfigInterface::class )->disableOriginalConstructor() ->setMethods( [] )->getMock(); $scopeConfig->expects( $this->any() )->method( 'getValue' )->with( $this->stringContains( 'advanced/modules_disable_output/' ), ScopeInterface::SCOPE_STORE )->willReturn( false ); $context = $this->getMockBuilder( Context::class )->disableOriginalConstructor() ->setMethods( ['getLayout', 'getEventManager', 'getScopeConfig'] )->getMock(); $context->expects( $this->any() )->method( 'getLayout' )->willReturn( $this->layout ); $context->expects( $this->any() )->method( 'getEventManager' )->willReturn( $eventManager ); $context->expects( $this->any() )->method( 'getScopeConfig' )->willReturn( $scopeConfig ); $this->block = $this->objectManager->getObject( Substitution::class, [ 'context' => $context, 'data' => [ 'template' => null, ] ] ); } public function testBeforeToHtml() { $abstractBlock = $this->getMockBuilder( AbstractBlock::class )->disableOriginalConstructor() ->setMethods( [] )->getMock(); $childAbstractBlock = clone($abstractBlock); $abstractBlock->expects($this->any())->method('getParentBlock')->willReturn($childAbstractBlock); $this->layout->expects($this->any())->method('getParentName')->willReturn('parentName'); $this->layout->expects($this->any())->method('getBlock')->willReturn($abstractBlock); $infoMock = $this->getMockBuilder( Info::class )->disableOriginalConstructor() ->setMethods( [] )->getMock(); $methodMock = $this->getMockBuilder( MethodInterface::class )->getMockForAbstractClass(); $infoMock->expects($this->once())->method('getMethodInstance')->willReturn($methodMock); $this->block->setInfo($infoMock); $fakeBlock = new \StdClass(); $this->layout->expects( $this->any() )->method( 'createBlock' )->with( Template::class, '', ['data' => ['method' => $methodMock, 'template' => 'Magento_Payment::info/substitution.phtml']] )->willReturn($fakeBlock); $childAbstractBlock->expects( $this->any() )->method( 'setChild' )->with( 'order_payment_additional', $fakeBlock ); $this->block->toHtml(); } }