@@ -41,32 +41,30 @@ 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 ()
48
49
->getMock ();
49
50
$ this ->orderMock ->expects ($ this ->any ())
50
51
->method ('getConfig ' )
51
52
->willReturnSelf ();
52
- $ this ->addressMock = $ this ->createMock (Address::class);
53
- $ this ->addressCollectionMock = $ this ->createMock (
54
- Collection::class
55
- );
56
53
$ this ->state = new State ();
57
54
}
58
55
59
56
/**
60
- * @param bool $isCanceled
61
- * @param bool $canUnhold
62
- * @param bool $canInvoice
63
- * @param bool $canShip
64
- * @param int $callCanSkipNum
65
57
* @param bool $canCreditmemo
66
58
* @param int $callCanCreditmemoNum
59
+ * @param bool $canShip
60
+ * @param int $callCanSkipNum
67
61
* @param string $currentState
68
62
* @param string $expectedState
69
- * @param int $callSetStateNum
63
+ * @param bool $isInProcess
64
+ * @param int $callGetIsInProcessNum
65
+ * @param bool $isCanceled
66
+ * @param bool $canUnhold
67
+ * @param bool $isNotVirtual
70
68
* @dataProvider stateCheckDataProvider
71
69
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
72
70
*/
@@ -76,12 +74,12 @@ public function testCheck(
76
74
bool $ canShip ,
77
75
int $ callCanSkipNum ,
78
76
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
77
+ string $ expectedState ,
78
+ bool $ isInProcess ,
79
+ int $ callGetIsInProcessNum ,
80
+ bool $ isCanceled ,
81
+ bool $ canUnhold ,
82
+ bool $ isNotVirtual
85
83
) {
86
84
$ this ->orderMock ->setState ($ currentState );
87
85
$ this ->orderMock ->expects ($ this ->any ())
@@ -92,7 +90,7 @@ public function testCheck(
92
90
->willReturn ($ canUnhold );
93
91
$ this ->orderMock ->expects ($ this ->any ())
94
92
->method ('canInvoice ' )
95
- ->willReturn ($ canInvoice );
93
+ ->willReturn (false );
96
94
$ this ->orderMock ->expects ($ this ->exactly ($ callCanSkipNum ))
97
95
->method ('canShip ' )
98
96
->willReturn ($ canShip );
@@ -102,11 +100,16 @@ public function testCheck(
102
100
$ this ->orderMock ->expects ($ this ->exactly ($ callGetIsInProcessNum ))
103
101
->method ('getIsInProcess ' )
104
102
->willReturn ($ isInProcess );
103
+ $ this ->orderMock ->method ('getIsNotVirtual ' )
104
+ ->willReturn ($ isNotVirtual );
105
105
$ this ->state ->check ($ this ->orderMock );
106
106
$ this ->assertEquals ($ expectedState , $ this ->orderMock ->getState ());
107
107
}
108
108
109
109
/**
110
+ * Data provider for testCheck
111
+ *
112
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
110
113
* @return array
111
114
*/
112
115
public function stateCheckDataProvider ()
@@ -118,63 +121,103 @@ public function stateCheckDataProvider()
118
121
'can_ship ' => false ,
119
122
'call_can_skip_num ' => 1 ,
120
123
'current_state ' => Order::STATE_PROCESSING ,
121
- 'expected_state ' => Order::STATE_CLOSED
124
+ 'expected_state ' => Order::STATE_CLOSED ,
125
+ 'is_in_process ' => false ,
126
+ 'get_is_in_process_invoke_count ' => 0 ,
127
+ 'is_canceled ' => false ,
128
+ 'can_unhold ' => false ,
129
+ 'is_not_virtual ' => true
122
130
],
123
131
'complete - !canCreditmemo,!canShip -> closed ' => [
124
132
'can_credit_memo ' => false ,
125
133
'can_credit_memo_invoke_count ' => 1 ,
126
134
'can_ship ' => false ,
127
135
'call_can_skip_num ' => 1 ,
128
136
'current_state ' => Order::STATE_COMPLETE ,
129
- 'expected_state ' => Order::STATE_CLOSED
137
+ 'expected_state ' => Order::STATE_CLOSED ,
138
+ 'is_in_process ' => false ,
139
+ 'get_is_in_process_invoke_count ' => 0 ,
140
+ 'is_canceled ' => false ,
141
+ 'can_unhold ' => false ,
142
+ 'is_not_virtual ' => true
130
143
],
131
144
'processing - !canCreditmemo,canShip -> processing ' => [
132
145
'can_credit_memo ' => false ,
133
146
'can_credit_memo_invoke_count ' => 1 ,
134
147
'can_ship ' => true ,
135
148
'call_can_skip_num ' => 2 ,
136
149
'current_state ' => Order::STATE_PROCESSING ,
137
- 'expected_state ' => Order::STATE_PROCESSING
150
+ 'expected_state ' => Order::STATE_PROCESSING ,
151
+ 'is_in_process ' => false ,
152
+ 'get_is_in_process_invoke_count ' => 0 ,
153
+ 'is_canceled ' => false ,
154
+ 'can_unhold ' => false ,
155
+ 'is_not_virtual ' => true
138
156
],
139
157
'complete - !canCreditmemo,canShip -> complete ' => [
140
158
'can_credit_memo ' => false ,
141
159
'can_credit_memo_invoke_count ' => 1 ,
142
160
'can_ship ' => true ,
143
161
'call_can_skip_num ' => 1 ,
144
162
'current_state ' => Order::STATE_COMPLETE ,
145
- 'expected_state ' => Order::STATE_COMPLETE
163
+ 'expected_state ' => Order::STATE_COMPLETE ,
164
+ 'is_in_process ' => false ,
165
+ 'get_is_in_process_invoke_count ' => 0 ,
166
+ 'is_canceled ' => false ,
167
+ 'can_unhold ' => false ,
168
+ 'is_not_virtual ' => true
146
169
],
147
170
'processing - canCreditmemo,!canShip -> complete ' => [
148
171
'can_credit_memo ' => true ,
149
172
'can_credit_memo_invoke_count ' => 1 ,
150
173
'can_ship ' => false ,
151
174
'call_can_skip_num ' => 1 ,
152
175
'current_state ' => Order::STATE_PROCESSING ,
153
- 'expected_state ' => Order::STATE_COMPLETE
176
+ 'expected_state ' => Order::STATE_COMPLETE ,
177
+ 'is_in_process ' => false ,
178
+ 'get_is_in_process_invoke_count ' => 0 ,
179
+ 'is_canceled ' => false ,
180
+ 'can_unhold ' => false ,
181
+ 'is_not_virtual ' => true
154
182
],
155
183
'complete - canCreditmemo,!canShip -> complete ' => [
156
184
'can_credit_memo ' => true ,
157
185
'can_credit_memo_invoke_count ' => 1 ,
158
186
'can_ship ' => false ,
159
187
'call_can_skip_num ' => 0 ,
160
188
'current_state ' => Order::STATE_COMPLETE ,
161
- 'expected_state ' => Order::STATE_COMPLETE
189
+ 'expected_state ' => Order::STATE_COMPLETE ,
190
+ 'is_in_process ' => false ,
191
+ 'get_is_in_process_invoke_count ' => 0 ,
192
+ 'is_canceled ' => false ,
193
+ 'can_unhold ' => false ,
194
+ 'is_not_virtual ' => true
162
195
],
163
196
'processing - canCreditmemo, canShip -> processing ' => [
164
197
'can_credit_memo ' => true ,
165
198
'can_credit_memo_invoke_count ' => 1 ,
166
199
'can_ship ' => true ,
167
200
'call_can_skip_num ' => 1 ,
168
201
'current_state ' => Order::STATE_PROCESSING ,
169
- 'expected_state ' => Order::STATE_PROCESSING
202
+ 'expected_state ' => Order::STATE_PROCESSING ,
203
+ 'is_in_process ' => false ,
204
+ 'get_is_in_process_invoke_count ' => 0 ,
205
+ 'is_canceled ' => false ,
206
+ 'can_unhold ' => false ,
207
+ 'is_not_virtual ' => true
170
208
],
171
209
'complete - canCreditmemo, canShip -> complete ' => [
172
210
'can_credit_memo ' => true ,
173
211
'can_credit_memo_invoke_count ' => 1 ,
174
212
'can_ship ' => true ,
175
213
'call_can_skip_num ' => 0 ,
176
214
'current_state ' => Order::STATE_COMPLETE ,
177
- 'expected_state ' => Order::STATE_COMPLETE
215
+ 'expected_state ' => Order::STATE_COMPLETE ,
216
+ 'is_in_process ' => false ,
217
+ 'get_is_in_process_invoke_count ' => 0 ,
218
+ 'is_canceled ' => false ,
219
+ 'can_unhold ' => false ,
220
+ 'is_not_virtual ' => true
178
221
],
179
222
'new - canCreditmemo, canShip, IsInProcess -> processing ' => [
180
223
'can_credit_memo ' => true ,
@@ -183,8 +226,11 @@ public function stateCheckDataProvider()
183
226
'call_can_skip_num ' => 1 ,
184
227
'current_state ' => Order::STATE_NEW ,
185
228
'expected_state ' => Order::STATE_PROCESSING ,
186
- true ,
187
- 1
229
+ 'is_in_process ' => true ,
230
+ 'get_is_in_process_invoke_count ' => 1 ,
231
+ 'is_canceled ' => false ,
232
+ 'can_unhold ' => false ,
233
+ 'is_not_virtual ' => true
188
234
],
189
235
'new - canCreditmemo, !canShip, IsInProcess -> processing ' => [
190
236
'can_credit_memo ' => true ,
@@ -193,8 +239,11 @@ public function stateCheckDataProvider()
193
239
'call_can_skip_num ' => 1 ,
194
240
'current_state ' => Order::STATE_NEW ,
195
241
'expected_state ' => Order::STATE_COMPLETE ,
196
- true ,
197
- 1
242
+ 'is_in_process ' => true ,
243
+ 'get_is_in_process_invoke_count ' => 1 ,
244
+ 'is_canceled ' => false ,
245
+ 'can_unhold ' => false ,
246
+ 'is_not_virtual ' => true
198
247
],
199
248
'new - canCreditmemo, canShip, !IsInProcess -> new ' => [
200
249
'can_credit_memo ' => true ,
@@ -203,8 +252,11 @@ public function stateCheckDataProvider()
203
252
'call_can_skip_num ' => 0 ,
204
253
'current_state ' => Order::STATE_NEW ,
205
254
'expected_state ' => Order::STATE_NEW ,
206
- false ,
207
- 1
255
+ 'is_in_process ' => false ,
256
+ 'get_is_in_process_invoke_count ' => 1 ,
257
+ 'is_canceled ' => false ,
258
+ 'can_unhold ' => false ,
259
+ 'is_not_virtual ' => true
208
260
],
209
261
'hold - canUnhold -> hold ' => [
210
262
'can_credit_memo ' => true ,
@@ -213,10 +265,11 @@ public function stateCheckDataProvider()
213
265
'call_can_skip_num ' => 0 ,
214
266
'current_state ' => Order::STATE_HOLDED ,
215
267
'expected_state ' => Order::STATE_HOLDED ,
216
- false ,
217
- 0 ,
218
- false ,
219
- true
268
+ 'is_in_process ' => false ,
269
+ 'get_is_in_process_invoke_count ' => 0 ,
270
+ 'is_canceled ' => false ,
271
+ 'can_unhold ' => true ,
272
+ 'is_not_virtual ' => true
220
273
],
221
274
'payment_review - canUnhold -> payment_review ' => [
222
275
'can_credit_memo ' => true ,
@@ -225,10 +278,11 @@ public function stateCheckDataProvider()
225
278
'call_can_skip_num ' => 0 ,
226
279
'current_state ' => Order::STATE_PAYMENT_REVIEW ,
227
280
'expected_state ' => Order::STATE_PAYMENT_REVIEW ,
228
- false ,
229
- 0 ,
230
- false ,
231
- true
281
+ 'is_in_process ' => false ,
282
+ 'get_is_in_process_invoke_count ' => 0 ,
283
+ 'is_canceled ' => false ,
284
+ 'can_unhold ' => true ,
285
+ 'is_not_virtual ' => true
232
286
],
233
287
'pending_payment - canUnhold -> pending_payment ' => [
234
288
'can_credit_memo ' => true ,
@@ -237,10 +291,11 @@ public function stateCheckDataProvider()
237
291
'call_can_skip_num ' => 0 ,
238
292
'current_state ' => Order::STATE_PENDING_PAYMENT ,
239
293
'expected_state ' => Order::STATE_PENDING_PAYMENT ,
240
- false ,
241
- 0 ,
242
- false ,
243
- true
294
+ 'is_in_process ' => false ,
295
+ 'get_is_in_process_invoke_count ' => 0 ,
296
+ 'is_canceled ' => false ,
297
+ 'can_unhold ' => true ,
298
+ 'is_not_virtual ' => true
244
299
],
245
300
'cancelled - isCanceled -> cancelled ' => [
246
301
'can_credit_memo ' => true ,
@@ -249,9 +304,24 @@ public function stateCheckDataProvider()
249
304
'call_can_skip_num ' => 0 ,
250
305
'current_state ' => Order::STATE_HOLDED ,
251
306
'expected_state ' => Order::STATE_HOLDED ,
252
- false ,
253
- 0 ,
254
- true
307
+ 'is_in_process ' => false ,
308
+ 'get_is_in_process_invoke_count ' => 0 ,
309
+ 'is_canceled ' => true ,
310
+ 'can_unhold ' => false ,
311
+ 'is_not_virtual ' => true
312
+ ],
313
+ 'processing - !canCreditmemo!canShip -> complete(virtual product) ' => [
314
+ 'can_credit_memo ' => false ,
315
+ 'can_credit_memo_invoke_count ' => 1 ,
316
+ 'can_ship ' => false ,
317
+ 'call_can_skip_num ' => 2 ,
318
+ 'current_state ' => Order::STATE_PROCESSING ,
319
+ 'expected_state ' => Order::STATE_COMPLETE ,
320
+ 'is_in_process ' => false ,
321
+ 'get_is_in_process_invoke_count ' => 0 ,
322
+ 'is_canceled ' => false ,
323
+ 'can_unhold ' => false ,
324
+ 'is_not_virtual ' => false
255
325
],
256
326
];
257
327
}
0 commit comments