27 private $paymentMethodList;
32 private $paymentMethodInstanceFactory;
41 $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
43 $this->paymentMethodList = $this->getMockBuilder(\
Magento\
Payment\Api\PaymentMethodListInterface::class)
44 ->disableOriginalConstructor()
45 ->getMockForAbstractClass();
47 $this->paymentMethodInstanceFactory = $this->getMockBuilder(
49 )->disableOriginalConstructor()->getMock();
51 $this->specificationFactoryMock = $this->createMock(\
Magento\
Payment\Model\Checks\SpecificationFactory::class);
52 $this->methodList = $this->objectManager->getObject(
55 'specificationFactory' => $this->specificationFactoryMock
59 $this->objectManager->setBackwardCompatibleProperty(
62 $this->paymentMethodList
64 $this->objectManager->setBackwardCompatibleProperty(
66 'paymentMethodInstanceFactory',
67 $this->paymentMethodInstanceFactory
74 $quoteMock = $this->createMock(\
Magento\Quote\Model\Quote::class);
75 $quoteMock->expects($this->once())->method(
'getStoreId')->will($this->returnValue(
$storeId));
76 $quoteMock->expects($this->atLeastOnce())
77 ->method(
'getPayment')
78 ->will($this->returnValue($this->createMock(\
Magento\Quote\Model\Quote\Payment::class)));
80 $methodInstanceMock = $this->createMock(\
Magento\
Payment\Model\Method\AbstractMethod::class);
81 $methodInstanceMock->expects($this->once())
82 ->method(
'isAvailable')
85 $compositeMock = $this->createMock(\
Magento\
Payment\Model\Checks\Composite::class);
86 $compositeMock->expects($this->atLeastOnce())
87 ->method(
'isApplicable')
88 ->with($methodInstanceMock, $quoteMock)
89 ->will($this->returnValue(
true));
91 $this->specificationFactoryMock->expects($this->atLeastOnce())
99 ->will($this->returnValue($compositeMock));
101 $methodMock = $this->getMockForAbstractClass(\
Magento\
Payment\Api\
Data\PaymentMethodInterface::class);
102 $this->paymentMethodList->expects($this->once())
103 ->method(
'getActiveList')
104 ->willReturn([$methodMock]);
105 $this->paymentMethodInstanceFactory->expects($this->once())
107 ->willReturn($methodInstanceMock);
109 $methodInstanceMock->expects($this->atLeastOnce())
110 ->method(
'setInfoInstance')
111 ->with($this->createMock(\
Magento\Quote\Model\Quote\Payment::class))
112 ->will($this->returnSelf());
114 $this->assertEquals([$methodInstanceMock], $this->methodList->getAvailableMethods($quoteMock));
const CHECK_USE_FOR_CURRENCY
$specificationFactoryMock
const CHECK_ORDER_TOTAL_MIN_MAX
testGetAvailableMethods()
const CHECK_USE_FOR_COUNTRY