18
18
use Magento \Payment \Model \Method \Free ;
19
19
use Magento \Payment \Model \Method \Logger ;
20
20
use Magento \Quote \Model \Quote ;
21
+ use Magento \Sales \Model \Order \Config ;
21
22
use PHPUnit \Framework \MockObject \MockObject ;
22
23
use PHPUnit \Framework \TestCase ;
23
24
use Psr \Log \LoggerInterface ;
@@ -42,6 +43,11 @@ class FreeTest extends TestCase
42
43
*/
43
44
protected $ currencyPrice ;
44
45
46
+ /**
47
+ * @var MockObject
48
+ */
49
+ protected $ configMock ;
50
+
45
51
/**
46
52
* @inheritdoc
47
53
*/
@@ -64,6 +70,8 @@ protected function setUp(): void
64
70
->setConstructorArgs ([$ this ->getMockForAbstractClass (LoggerInterface::class)])
65
71
->getMock ();
66
72
73
+ $ this ->configMock = $ this ->createMock (Config::class);
74
+
67
75
$ this ->methodFree = new Free (
68
76
$ context ,
69
77
$ registry ,
@@ -72,26 +80,32 @@ protected function setUp(): void
72
80
$ paymentData ,
73
81
$ this ->scopeConfig ,
74
82
$ loggerMock ,
75
- $ this ->currencyPrice
83
+ $ this ->currencyPrice ,
84
+ null ,
85
+ null ,
86
+ [],
87
+ $ this ->configMock
76
88
);
77
89
}
78
90
79
91
/**
80
92
* @param string $orderStatus
81
93
* @param string $paymentAction
82
94
* @param mixed $result
95
+ * @param array $stateStatuses
83
96
*
84
97
* @return void
85
98
* @dataProvider getConfigPaymentActionProvider
86
99
*/
87
- public function testGetConfigPaymentAction ($ orderStatus , $ paymentAction , $ result ): void
100
+ public function testGetConfigPaymentAction ($ orderStatus , $ paymentAction , $ result, $ stateStatuses ): void
88
101
{
89
-
90
- if ($ orderStatus != 'pending ' ) {
91
- $ this ->scopeConfig
92
- ->method ('getValue ' )
93
- ->willReturnOnConsecutiveCalls ($ orderStatus , $ paymentAction );
94
- }
102
+ $ this ->configMock
103
+ ->method ('getStateStatuses ' )
104
+ ->with ('new ' )
105
+ ->willReturn ($ stateStatuses );
106
+ $ this ->scopeConfig
107
+ ->method ('getValue ' )
108
+ ->willReturnOnConsecutiveCalls ($ orderStatus , $ paymentAction );
95
109
$ this ->assertEquals ($ result , $ this ->methodFree ->getConfigPaymentAction ());
96
110
}
97
111
@@ -150,8 +164,10 @@ public function getIsAvailableProvider(): array
150
164
public function getConfigPaymentActionProvider (): array
151
165
{
152
166
return [
153
- ['pending ' , 'action ' , null ],
154
- ['processing ' , 'payment_action ' , 'payment_action ' ]
167
+ ['pending ' , 'action ' , null , ['pending ' => 'Pending ' ]],
168
+ ['new ' , 'action ' , null , ['pending ' => 'Pending ' , 'new ' => 'New ' ]],
169
+ ['new ' , 'payment_action ' , 'payment_action ' , ['pending ' => 'Pending ' ]],
170
+ ['processing ' , 'payment_action ' , 'payment_action ' , ['pending ' => 'Pending ' ]]
155
171
];
156
172
}
157
173
}
0 commit comments