![]() 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/Gateway/Validator/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\Payment\Test\Unit\Gateway\Validator; use Magento\Framework\Exception\NotFoundException; use Magento\Framework\ObjectManager\TMap; use Magento\Framework\ObjectManager\TMapFactory; use Magento\Payment\Gateway\Validator\ValidatorInterface; use Magento\Payment\Gateway\Validator\ValidatorPool; use PHPUnit\Framework\TestCase; class ValidatorPoolTest extends TestCase { public function testGet() { $commandI = $this->getMockBuilder(ValidatorInterface::class) ->getMockForAbstractClass(); $tMap = $this->getMockBuilder(TMap::class) ->disableOriginalConstructor() ->getMock(); $tMapFactory = $this->getMockBuilder(TMapFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $tMapFactory->expects(static::once()) ->method('create') ->with( [ 'array' => ['validator' => ValidatorInterface::class], 'type' => ValidatorInterface::class ] ) ->willReturn($tMap); $tMap->expects(static::once()) ->method('offsetExists') ->with('validator') ->willReturn(true); $tMap->expects(static::once()) ->method('offsetGet') ->with('validator') ->willReturn($commandI); $pool = new ValidatorPool( $tMapFactory, ['validator' => ValidatorInterface::class] ); static::assertSame($commandI, $pool->get('validator')); } public function testGetException() { $this->expectException(NotFoundException::class); $tMapFactory = $this->getMockBuilder(TMapFactory::class) ->disableOriginalConstructor() ->setMethods(['create']) ->getMock(); $tMap = $this->getMockBuilder(TMap::class) ->disableOriginalConstructor() ->getMock(); $tMapFactory->expects(static::once()) ->method('create') ->with( [ 'array' => [], 'type' => ValidatorInterface::class ] ) ->willReturn($tMap); $tMap->expects(static::once()) ->method('offsetExists') ->with('validator') ->willReturn(false); $pool = new ValidatorPool($tMapFactory, []); $pool->get('validator'); } }