Skip to content

Commit 1e915d4

Browse files
committed
Cover changes with unit test
1 parent 882868a commit 1e915d4

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

app/code/Magento/Payment/Test/Unit/Model/MethodListTest.php

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
namespace Magento\Payment\Test\Unit\Model;
88

9-
use Magento\Payment\Model\MethodList;
109
use Magento\Payment\Model\Method\AbstractMethod;
10+
use Magento\Payment\Model\MethodList;
1111

1212
class MethodListTest extends \PHPUnit\Framework\TestCase
1313
{
@@ -36,6 +36,11 @@ class MethodListTest extends \PHPUnit\Framework\TestCase
3636
*/
3737
protected $specificationFactoryMock;
3838

39+
/**
40+
* @var array $additionalChecks
41+
*/
42+
private $additionalChecks;
43+
3944
protected function setUp()
4045
{
4146
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
@@ -49,10 +54,14 @@ protected function setUp()
4954
)->disableOriginalConstructor()->getMock();
5055

5156
$this->specificationFactoryMock = $this->createMock(\Magento\Payment\Model\Checks\SpecificationFactory::class);
57+
58+
$this->additionalChecks = ['acme_custom_payment_method_check' => 'acme_custom_payment_method_check'];
59+
5260
$this->methodList = $this->objectManager->getObject(
5361
\Magento\Payment\Model\MethodList::class,
5462
[
55-
'specificationFactory' => $this->specificationFactoryMock
63+
'specificationFactory' => $this->specificationFactoryMock,
64+
'additionalChecks' => $this->additionalChecks
5665
]
5766
);
5867

@@ -68,6 +77,9 @@ protected function setUp()
6877
);
6978
}
7079

80+
/**
81+
* Verify available payment methods
82+
*/
7183
public function testGetAvailableMethods()
7284
{
7385
$storeId = 1;
@@ -90,13 +102,17 @@ public function testGetAvailableMethods()
90102

91103
$this->specificationFactoryMock->expects($this->atLeastOnce())
92104
->method('create')
93-
->with([
94-
AbstractMethod::CHECK_USE_CHECKOUT,
95-
AbstractMethod::CHECK_USE_FOR_COUNTRY,
96-
AbstractMethod::CHECK_USE_FOR_CURRENCY,
97-
AbstractMethod::CHECK_ORDER_TOTAL_MIN_MAX
98-
])
99-
->will($this->returnValue($compositeMock));
105+
->with(
106+
array_merge(
107+
[
108+
AbstractMethod::CHECK_USE_CHECKOUT,
109+
AbstractMethod::CHECK_USE_FOR_COUNTRY,
110+
AbstractMethod::CHECK_USE_FOR_CURRENCY,
111+
AbstractMethod::CHECK_ORDER_TOTAL_MIN_MAX
112+
],
113+
$this->additionalChecks
114+
)
115+
)->will($this->returnValue($compositeMock));
100116

101117
$methodMock = $this->getMockForAbstractClass(\Magento\Payment\Api\Data\PaymentMethodInterface::class);
102118
$this->paymentMethodList->expects($this->once())

0 commit comments

Comments
 (0)