@@ -41,7 +41,8 @@ protected function setUp(): void
4141 'getBaseGrandTotal ' ,
4242 'canCreditmemo ' ,
4343 'getTotalRefunded ' ,
44- 'getConfig '
44+ 'getConfig ' ,
45+ 'getIsNotVirtual '
4546 ]
4647 )
4748 ->disableOriginalConstructor ()
@@ -57,16 +58,17 @@ protected function setUp(): void
5758 }
5859
5960 /**
60- * @param bool $isCanceled
61- * @param bool $canUnhold
62- * @param bool $canInvoice
63- * @param bool $canShip
64- * @param int $callCanSkipNum
6561 * @param bool $canCreditmemo
6662 * @param int $callCanCreditmemoNum
63+ * @param bool $canShip
64+ * @param int $callCanSkipNum
6765 * @param string $currentState
6866 * @param string $expectedState
69- * @param int $callSetStateNum
67+ * @param bool $isInProcess
68+ * @param int $callGetIsInProcessNum
69+ * @param bool $isCanceled
70+ * @param bool $canUnhold
71+ * @param bool $isNotVirtual
7072 * @dataProvider stateCheckDataProvider
7173 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
7274 */
@@ -76,12 +78,12 @@ public function testCheck(
7678 bool $ canShip ,
7779 int $ callCanSkipNum ,
7880 string $ currentState ,
79- string $ expectedState = '' ,
80- bool $ isInProcess = false ,
81- int $ callGetIsInProcessNum = 0 ,
82- bool $ isCanceled = false ,
83- bool $ canUnhold = false ,
84- bool $ canInvoice = false
81+ string $ expectedState ,
82+ bool $ isInProcess ,
83+ int $ callGetIsInProcessNum ,
84+ bool $ isCanceled ,
85+ bool $ canUnhold ,
86+ bool $ isNotVirtual
8587 ) {
8688 $ this ->orderMock ->setState ($ currentState );
8789 $ this ->orderMock ->expects ($ this ->any ())
@@ -92,7 +94,7 @@ public function testCheck(
9294 ->willReturn ($ canUnhold );
9395 $ this ->orderMock ->expects ($ this ->any ())
9496 ->method ('canInvoice ' )
95- ->willReturn ($ canInvoice );
97+ ->willReturn (false );
9698 $ this ->orderMock ->expects ($ this ->exactly ($ callCanSkipNum ))
9799 ->method ('canShip ' )
98100 ->willReturn ($ canShip );
@@ -102,6 +104,8 @@ public function testCheck(
102104 $ this ->orderMock ->expects ($ this ->exactly ($ callGetIsInProcessNum ))
103105 ->method ('getIsInProcess ' )
104106 ->willReturn ($ isInProcess );
107+ $ this ->orderMock ->method ('getIsNotVirtual ' )
108+ ->willReturn ($ isNotVirtual );
105109 $ this ->state ->check ($ this ->orderMock );
106110 $ this ->assertEquals ($ expectedState , $ this ->orderMock ->getState ());
107111 }
@@ -118,63 +122,103 @@ public function stateCheckDataProvider()
118122 'can_ship ' => false ,
119123 'call_can_skip_num ' => 1 ,
120124 'current_state ' => Order::STATE_PROCESSING ,
121- 'expected_state ' => Order::STATE_CLOSED
125+ 'expected_state ' => Order::STATE_CLOSED ,
126+ 'is_in_process ' => false ,
127+ 'get_is_in_process_invoke_count ' => 0 ,
128+ 'is_canceled ' => false ,
129+ 'can_unhold ' => false ,
130+ 'is_not_virtual ' => true
122131 ],
123132 'complete - !canCreditmemo,!canShip -> closed ' => [
124133 'can_credit_memo ' => false ,
125134 'can_credit_memo_invoke_count ' => 1 ,
126135 'can_ship ' => false ,
127136 'call_can_skip_num ' => 1 ,
128137 'current_state ' => Order::STATE_COMPLETE ,
129- 'expected_state ' => Order::STATE_CLOSED
138+ 'expected_state ' => Order::STATE_CLOSED ,
139+ 'is_in_process ' => false ,
140+ 'get_is_in_process_invoke_count ' => 0 ,
141+ 'is_canceled ' => false ,
142+ 'can_unhold ' => false ,
143+ 'is_not_virtual ' => true
130144 ],
131145 'processing - !canCreditmemo,canShip -> processing ' => [
132146 'can_credit_memo ' => false ,
133147 'can_credit_memo_invoke_count ' => 1 ,
134148 'can_ship ' => true ,
135149 'call_can_skip_num ' => 2 ,
136150 'current_state ' => Order::STATE_PROCESSING ,
137- 'expected_state ' => Order::STATE_PROCESSING
151+ 'expected_state ' => Order::STATE_PROCESSING ,
152+ 'is_in_process ' => false ,
153+ 'get_is_in_process_invoke_count ' => 0 ,
154+ 'is_canceled ' => false ,
155+ 'can_unhold ' => false ,
156+ 'is_not_virtual ' => true
138157 ],
139158 'complete - !canCreditmemo,canShip -> complete ' => [
140159 'can_credit_memo ' => false ,
141160 'can_credit_memo_invoke_count ' => 1 ,
142161 'can_ship ' => true ,
143162 'call_can_skip_num ' => 1 ,
144163 'current_state ' => Order::STATE_COMPLETE ,
145- 'expected_state ' => Order::STATE_COMPLETE
164+ 'expected_state ' => Order::STATE_COMPLETE ,
165+ 'is_in_process ' => false ,
166+ 'get_is_in_process_invoke_count ' => 0 ,
167+ 'is_canceled ' => false ,
168+ 'can_unhold ' => false ,
169+ 'is_not_virtual ' => true
146170 ],
147171 'processing - canCreditmemo,!canShip -> complete ' => [
148172 'can_credit_memo ' => true ,
149173 'can_credit_memo_invoke_count ' => 1 ,
150174 'can_ship ' => false ,
151175 'call_can_skip_num ' => 1 ,
152176 'current_state ' => Order::STATE_PROCESSING ,
153- 'expected_state ' => Order::STATE_COMPLETE
177+ 'expected_state ' => Order::STATE_COMPLETE ,
178+ 'is_in_process ' => false ,
179+ 'get_is_in_process_invoke_count ' => 0 ,
180+ 'is_canceled ' => false ,
181+ 'can_unhold ' => false ,
182+ 'is_not_virtual ' => true
154183 ],
155184 'complete - canCreditmemo,!canShip -> complete ' => [
156185 'can_credit_memo ' => true ,
157186 'can_credit_memo_invoke_count ' => 1 ,
158187 'can_ship ' => false ,
159188 'call_can_skip_num ' => 0 ,
160189 'current_state ' => Order::STATE_COMPLETE ,
161- 'expected_state ' => Order::STATE_COMPLETE
190+ 'expected_state ' => Order::STATE_COMPLETE ,
191+ 'is_in_process ' => false ,
192+ 'get_is_in_process_invoke_count ' => 0 ,
193+ 'is_canceled ' => false ,
194+ 'can_unhold ' => false ,
195+ 'is_not_virtual ' => true
162196 ],
163197 'processing - canCreditmemo, canShip -> processing ' => [
164198 'can_credit_memo ' => true ,
165199 'can_credit_memo_invoke_count ' => 1 ,
166200 'can_ship ' => true ,
167201 'call_can_skip_num ' => 1 ,
168202 'current_state ' => Order::STATE_PROCESSING ,
169- 'expected_state ' => Order::STATE_PROCESSING
203+ 'expected_state ' => Order::STATE_PROCESSING ,
204+ 'is_in_process ' => false ,
205+ 'get_is_in_process_invoke_count ' => 0 ,
206+ 'is_canceled ' => false ,
207+ 'can_unhold ' => false ,
208+ 'is_not_virtual ' => true
170209 ],
171210 'complete - canCreditmemo, canShip -> complete ' => [
172211 'can_credit_memo ' => true ,
173212 'can_credit_memo_invoke_count ' => 1 ,
174213 'can_ship ' => true ,
175214 'call_can_skip_num ' => 0 ,
176215 'current_state ' => Order::STATE_COMPLETE ,
177- 'expected_state ' => Order::STATE_COMPLETE
216+ 'expected_state ' => Order::STATE_COMPLETE ,
217+ 'is_in_process ' => false ,
218+ 'get_is_in_process_invoke_count ' => 0 ,
219+ 'is_canceled ' => false ,
220+ 'can_unhold ' => false ,
221+ 'is_not_virtual ' => true
178222 ],
179223 'new - canCreditmemo, canShip, IsInProcess -> processing ' => [
180224 'can_credit_memo ' => true ,
@@ -183,8 +227,11 @@ public function stateCheckDataProvider()
183227 'call_can_skip_num ' => 1 ,
184228 'current_state ' => Order::STATE_NEW ,
185229 'expected_state ' => Order::STATE_PROCESSING ,
186- true ,
187- 1
230+ 'is_in_process ' => true ,
231+ 'get_is_in_process_invoke_count ' => 1 ,
232+ 'is_canceled ' => false ,
233+ 'can_unhold ' => false ,
234+ 'is_not_virtual ' => true
188235 ],
189236 'new - canCreditmemo, !canShip, IsInProcess -> processing ' => [
190237 'can_credit_memo ' => true ,
@@ -193,8 +240,11 @@ public function stateCheckDataProvider()
193240 'call_can_skip_num ' => 1 ,
194241 'current_state ' => Order::STATE_NEW ,
195242 'expected_state ' => Order::STATE_COMPLETE ,
196- true ,
197- 1
243+ 'is_in_process ' => true ,
244+ 'get_is_in_process_invoke_count ' => 1 ,
245+ 'is_canceled ' => false ,
246+ 'can_unhold ' => false ,
247+ 'is_not_virtual ' => true
198248 ],
199249 'new - canCreditmemo, canShip, !IsInProcess -> new ' => [
200250 'can_credit_memo ' => true ,
@@ -203,8 +253,11 @@ public function stateCheckDataProvider()
203253 'call_can_skip_num ' => 0 ,
204254 'current_state ' => Order::STATE_NEW ,
205255 'expected_state ' => Order::STATE_NEW ,
206- false ,
207- 1
256+ 'is_in_process ' => false ,
257+ 'get_is_in_process_invoke_count ' => 1 ,
258+ 'is_canceled ' => false ,
259+ 'can_unhold ' => false ,
260+ 'is_not_virtual ' => true
208261 ],
209262 'hold - canUnhold -> hold ' => [
210263 'can_credit_memo ' => true ,
@@ -213,10 +266,11 @@ public function stateCheckDataProvider()
213266 'call_can_skip_num ' => 0 ,
214267 'current_state ' => Order::STATE_HOLDED ,
215268 'expected_state ' => Order::STATE_HOLDED ,
216- false ,
217- 0 ,
218- false ,
219- true
269+ 'is_in_process ' => false ,
270+ 'get_is_in_process_invoke_count ' => 0 ,
271+ 'is_canceled ' => false ,
272+ 'can_unhold ' => true ,
273+ 'is_not_virtual ' => true
220274 ],
221275 'payment_review - canUnhold -> payment_review ' => [
222276 'can_credit_memo ' => true ,
@@ -225,10 +279,11 @@ public function stateCheckDataProvider()
225279 'call_can_skip_num ' => 0 ,
226280 'current_state ' => Order::STATE_PAYMENT_REVIEW ,
227281 'expected_state ' => Order::STATE_PAYMENT_REVIEW ,
228- false ,
229- 0 ,
230- false ,
231- true
282+ 'is_in_process ' => false ,
283+ 'get_is_in_process_invoke_count ' => 0 ,
284+ 'is_canceled ' => false ,
285+ 'can_unhold ' => true ,
286+ 'is_not_virtual ' => true
232287 ],
233288 'pending_payment - canUnhold -> pending_payment ' => [
234289 'can_credit_memo ' => true ,
@@ -237,10 +292,11 @@ public function stateCheckDataProvider()
237292 'call_can_skip_num ' => 0 ,
238293 'current_state ' => Order::STATE_PENDING_PAYMENT ,
239294 'expected_state ' => Order::STATE_PENDING_PAYMENT ,
240- false ,
241- 0 ,
242- false ,
243- true
295+ 'is_in_process ' => false ,
296+ 'get_is_in_process_invoke_count ' => 0 ,
297+ 'is_canceled ' => false ,
298+ 'can_unhold ' => true ,
299+ 'is_not_virtual ' => true
244300 ],
245301 'cancelled - isCanceled -> cancelled ' => [
246302 'can_credit_memo ' => true ,
@@ -249,9 +305,24 @@ public function stateCheckDataProvider()
249305 'call_can_skip_num ' => 0 ,
250306 'current_state ' => Order::STATE_HOLDED ,
251307 'expected_state ' => Order::STATE_HOLDED ,
252- false ,
253- 0 ,
254- true
308+ 'is_in_process ' => false ,
309+ 'get_is_in_process_invoke_count ' => 0 ,
310+ 'is_canceled ' => true ,
311+ 'can_unhold ' => false ,
312+ 'is_not_virtual ' => true
313+ ],
314+ 'processing - !canCreditmemo!canShip -> complete(virtual product) ' => [
315+ 'can_credit_memo ' => false ,
316+ 'can_credit_memo_invoke_count ' => 1 ,
317+ 'can_ship ' => false ,
318+ 'call_can_skip_num ' => 2 ,
319+ 'current_state ' => Order::STATE_PROCESSING ,
320+ 'expected_state ' => Order::STATE_COMPLETE ,
321+ 'is_in_process ' => false ,
322+ 'get_is_in_process_invoke_count ' => 0 ,
323+ 'is_canceled ' => false ,
324+ 'can_unhold ' => false ,
325+ 'is_not_virtual ' => false
255326 ],
256327 ];
257328 }
0 commit comments