@@ -41,7 +41,8 @@ protected function setUp(): void
41
41
'getBaseGrandTotal ' ,
42
42
'canCreditmemo ' ,
43
43
'getTotalRefunded ' ,
44
- 'getConfig '
44
+ 'getConfig ' ,
45
+ 'getIsNotVirtual '
45
46
]
46
47
)
47
48
->disableOriginalConstructor ()
@@ -57,16 +58,17 @@ protected function setUp(): void
57
58
}
58
59
59
60
/**
60
- * @param bool $isCanceled
61
- * @param bool $canUnhold
62
- * @param bool $canInvoice
63
- * @param bool $canShip
64
- * @param int $callCanSkipNum
65
61
* @param bool $canCreditmemo
66
62
* @param int $callCanCreditmemoNum
63
+ * @param bool $canShip
64
+ * @param int $callCanSkipNum
67
65
* @param string $currentState
68
66
* @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
70
72
* @dataProvider stateCheckDataProvider
71
73
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
72
74
*/
@@ -76,12 +78,12 @@ public function testCheck(
76
78
bool $ canShip ,
77
79
int $ callCanSkipNum ,
78
80
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
85
87
) {
86
88
$ this ->orderMock ->setState ($ currentState );
87
89
$ this ->orderMock ->expects ($ this ->any ())
@@ -92,7 +94,7 @@ public function testCheck(
92
94
->willReturn ($ canUnhold );
93
95
$ this ->orderMock ->expects ($ this ->any ())
94
96
->method ('canInvoice ' )
95
- ->willReturn ($ canInvoice );
97
+ ->willReturn (false );
96
98
$ this ->orderMock ->expects ($ this ->exactly ($ callCanSkipNum ))
97
99
->method ('canShip ' )
98
100
->willReturn ($ canShip );
@@ -102,6 +104,8 @@ public function testCheck(
102
104
$ this ->orderMock ->expects ($ this ->exactly ($ callGetIsInProcessNum ))
103
105
->method ('getIsInProcess ' )
104
106
->willReturn ($ isInProcess );
107
+ $ this ->orderMock ->method ('getIsNotVirtual ' )
108
+ ->willReturn ($ isNotVirtual );
105
109
$ this ->state ->check ($ this ->orderMock );
106
110
$ this ->assertEquals ($ expectedState , $ this ->orderMock ->getState ());
107
111
}
@@ -118,63 +122,103 @@ public function stateCheckDataProvider()
118
122
'can_ship ' => false ,
119
123
'call_can_skip_num ' => 1 ,
120
124
'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
122
131
],
123
132
'complete - !canCreditmemo,!canShip -> closed ' => [
124
133
'can_credit_memo ' => false ,
125
134
'can_credit_memo_invoke_count ' => 1 ,
126
135
'can_ship ' => false ,
127
136
'call_can_skip_num ' => 1 ,
128
137
'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
130
144
],
131
145
'processing - !canCreditmemo,canShip -> processing ' => [
132
146
'can_credit_memo ' => false ,
133
147
'can_credit_memo_invoke_count ' => 1 ,
134
148
'can_ship ' => true ,
135
149
'call_can_skip_num ' => 2 ,
136
150
'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
138
157
],
139
158
'complete - !canCreditmemo,canShip -> complete ' => [
140
159
'can_credit_memo ' => false ,
141
160
'can_credit_memo_invoke_count ' => 1 ,
142
161
'can_ship ' => true ,
143
162
'call_can_skip_num ' => 1 ,
144
163
'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
146
170
],
147
171
'processing - canCreditmemo,!canShip -> complete ' => [
148
172
'can_credit_memo ' => true ,
149
173
'can_credit_memo_invoke_count ' => 1 ,
150
174
'can_ship ' => false ,
151
175
'call_can_skip_num ' => 1 ,
152
176
'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
154
183
],
155
184
'complete - canCreditmemo,!canShip -> complete ' => [
156
185
'can_credit_memo ' => true ,
157
186
'can_credit_memo_invoke_count ' => 1 ,
158
187
'can_ship ' => false ,
159
188
'call_can_skip_num ' => 0 ,
160
189
'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
162
196
],
163
197
'processing - canCreditmemo, canShip -> processing ' => [
164
198
'can_credit_memo ' => true ,
165
199
'can_credit_memo_invoke_count ' => 1 ,
166
200
'can_ship ' => true ,
167
201
'call_can_skip_num ' => 1 ,
168
202
'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
170
209
],
171
210
'complete - canCreditmemo, canShip -> complete ' => [
172
211
'can_credit_memo ' => true ,
173
212
'can_credit_memo_invoke_count ' => 1 ,
174
213
'can_ship ' => true ,
175
214
'call_can_skip_num ' => 0 ,
176
215
'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
178
222
],
179
223
'new - canCreditmemo, canShip, IsInProcess -> processing ' => [
180
224
'can_credit_memo ' => true ,
@@ -183,8 +227,11 @@ public function stateCheckDataProvider()
183
227
'call_can_skip_num ' => 1 ,
184
228
'current_state ' => Order::STATE_NEW ,
185
229
'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
188
235
],
189
236
'new - canCreditmemo, !canShip, IsInProcess -> processing ' => [
190
237
'can_credit_memo ' => true ,
@@ -193,8 +240,11 @@ public function stateCheckDataProvider()
193
240
'call_can_skip_num ' => 1 ,
194
241
'current_state ' => Order::STATE_NEW ,
195
242
'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
198
248
],
199
249
'new - canCreditmemo, canShip, !IsInProcess -> new ' => [
200
250
'can_credit_memo ' => true ,
@@ -203,8 +253,11 @@ public function stateCheckDataProvider()
203
253
'call_can_skip_num ' => 0 ,
204
254
'current_state ' => Order::STATE_NEW ,
205
255
'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
208
261
],
209
262
'hold - canUnhold -> hold ' => [
210
263
'can_credit_memo ' => true ,
@@ -213,10 +266,11 @@ public function stateCheckDataProvider()
213
266
'call_can_skip_num ' => 0 ,
214
267
'current_state ' => Order::STATE_HOLDED ,
215
268
'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
220
274
],
221
275
'payment_review - canUnhold -> payment_review ' => [
222
276
'can_credit_memo ' => true ,
@@ -225,10 +279,11 @@ public function stateCheckDataProvider()
225
279
'call_can_skip_num ' => 0 ,
226
280
'current_state ' => Order::STATE_PAYMENT_REVIEW ,
227
281
'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
232
287
],
233
288
'pending_payment - canUnhold -> pending_payment ' => [
234
289
'can_credit_memo ' => true ,
@@ -237,10 +292,11 @@ public function stateCheckDataProvider()
237
292
'call_can_skip_num ' => 0 ,
238
293
'current_state ' => Order::STATE_PENDING_PAYMENT ,
239
294
'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
244
300
],
245
301
'cancelled - isCanceled -> cancelled ' => [
246
302
'can_credit_memo ' => true ,
@@ -249,9 +305,24 @@ public function stateCheckDataProvider()
249
305
'call_can_skip_num ' => 0 ,
250
306
'current_state ' => Order::STATE_HOLDED ,
251
307
'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
255
326
],
256
327
];
257
328
}
0 commit comments