@@ -41,32 +41,30 @@ protected function setUp(): void
4141 'getBaseGrandTotal ' ,
4242 'canCreditmemo ' ,
4343 'getTotalRefunded ' ,
44- 'getConfig '
44+ 'getConfig ' ,
45+ 'getIsNotVirtual '
4546 ]
4647 )
4748 ->disableOriginalConstructor ()
4849 ->getMock ();
4950 $ this ->orderMock ->expects ($ this ->any ())
5051 ->method ('getConfig ' )
5152 ->willReturnSelf ();
52- $ this ->addressMock = $ this ->createMock (Address::class);
53- $ this ->addressCollectionMock = $ this ->createMock (
54- Collection::class
55- );
5653 $ this ->state = new State ();
5754 }
5855
5956 /**
60- * @param bool $isCanceled
61- * @param bool $canUnhold
62- * @param bool $canInvoice
63- * @param bool $canShip
64- * @param int $callCanSkipNum
6557 * @param bool $canCreditmemo
6658 * @param int $callCanCreditmemoNum
59+ * @param bool $canShip
60+ * @param int $callCanSkipNum
6761 * @param string $currentState
6862 * @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
7068 * @dataProvider stateCheckDataProvider
7169 * @SuppressWarnings(PHPMD.ExcessiveParameterList)
7270 */
@@ -76,12 +74,12 @@ public function testCheck(
7674 bool $ canShip ,
7775 int $ callCanSkipNum ,
7876 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
8583 ) {
8684 $ this ->orderMock ->setState ($ currentState );
8785 $ this ->orderMock ->expects ($ this ->any ())
@@ -92,7 +90,7 @@ public function testCheck(
9290 ->willReturn ($ canUnhold );
9391 $ this ->orderMock ->expects ($ this ->any ())
9492 ->method ('canInvoice ' )
95- ->willReturn ($ canInvoice );
93+ ->willReturn (false );
9694 $ this ->orderMock ->expects ($ this ->exactly ($ callCanSkipNum ))
9795 ->method ('canShip ' )
9896 ->willReturn ($ canShip );
@@ -102,11 +100,16 @@ public function testCheck(
102100 $ this ->orderMock ->expects ($ this ->exactly ($ callGetIsInProcessNum ))
103101 ->method ('getIsInProcess ' )
104102 ->willReturn ($ isInProcess );
103+ $ this ->orderMock ->method ('getIsNotVirtual ' )
104+ ->willReturn ($ isNotVirtual );
105105 $ this ->state ->check ($ this ->orderMock );
106106 $ this ->assertEquals ($ expectedState , $ this ->orderMock ->getState ());
107107 }
108108
109109 /**
110+ * Data provider for testCheck
111+ *
112+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
110113 * @return array
111114 */
112115 public function stateCheckDataProvider ()
@@ -118,63 +121,103 @@ public function stateCheckDataProvider()
118121 'can_ship ' => false ,
119122 'call_can_skip_num ' => 1 ,
120123 '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
122130 ],
123131 'complete - !canCreditmemo,!canShip -> closed ' => [
124132 'can_credit_memo ' => false ,
125133 'can_credit_memo_invoke_count ' => 1 ,
126134 'can_ship ' => false ,
127135 'call_can_skip_num ' => 1 ,
128136 '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
130143 ],
131144 'processing - !canCreditmemo,canShip -> processing ' => [
132145 'can_credit_memo ' => false ,
133146 'can_credit_memo_invoke_count ' => 1 ,
134147 'can_ship ' => true ,
135148 'call_can_skip_num ' => 2 ,
136149 '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
138156 ],
139157 'complete - !canCreditmemo,canShip -> complete ' => [
140158 'can_credit_memo ' => false ,
141159 'can_credit_memo_invoke_count ' => 1 ,
142160 'can_ship ' => true ,
143161 'call_can_skip_num ' => 1 ,
144162 '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
146169 ],
147170 'processing - canCreditmemo,!canShip -> complete ' => [
148171 'can_credit_memo ' => true ,
149172 'can_credit_memo_invoke_count ' => 1 ,
150173 'can_ship ' => false ,
151174 'call_can_skip_num ' => 1 ,
152175 '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
154182 ],
155183 'complete - canCreditmemo,!canShip -> complete ' => [
156184 'can_credit_memo ' => true ,
157185 'can_credit_memo_invoke_count ' => 1 ,
158186 'can_ship ' => false ,
159187 'call_can_skip_num ' => 0 ,
160188 '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
162195 ],
163196 'processing - canCreditmemo, canShip -> processing ' => [
164197 'can_credit_memo ' => true ,
165198 'can_credit_memo_invoke_count ' => 1 ,
166199 'can_ship ' => true ,
167200 'call_can_skip_num ' => 1 ,
168201 '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
170208 ],
171209 'complete - canCreditmemo, canShip -> complete ' => [
172210 'can_credit_memo ' => true ,
173211 'can_credit_memo_invoke_count ' => 1 ,
174212 'can_ship ' => true ,
175213 'call_can_skip_num ' => 0 ,
176214 '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
178221 ],
179222 'new - canCreditmemo, canShip, IsInProcess -> processing ' => [
180223 'can_credit_memo ' => true ,
@@ -183,8 +226,11 @@ public function stateCheckDataProvider()
183226 'call_can_skip_num ' => 1 ,
184227 'current_state ' => Order::STATE_NEW ,
185228 '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
188234 ],
189235 'new - canCreditmemo, !canShip, IsInProcess -> processing ' => [
190236 'can_credit_memo ' => true ,
@@ -193,8 +239,11 @@ public function stateCheckDataProvider()
193239 'call_can_skip_num ' => 1 ,
194240 'current_state ' => Order::STATE_NEW ,
195241 '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
198247 ],
199248 'new - canCreditmemo, canShip, !IsInProcess -> new ' => [
200249 'can_credit_memo ' => true ,
@@ -203,8 +252,11 @@ public function stateCheckDataProvider()
203252 'call_can_skip_num ' => 0 ,
204253 'current_state ' => Order::STATE_NEW ,
205254 '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
208260 ],
209261 'hold - canUnhold -> hold ' => [
210262 'can_credit_memo ' => true ,
@@ -213,10 +265,11 @@ public function stateCheckDataProvider()
213265 'call_can_skip_num ' => 0 ,
214266 'current_state ' => Order::STATE_HOLDED ,
215267 '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
220273 ],
221274 'payment_review - canUnhold -> payment_review ' => [
222275 'can_credit_memo ' => true ,
@@ -225,10 +278,11 @@ public function stateCheckDataProvider()
225278 'call_can_skip_num ' => 0 ,
226279 'current_state ' => Order::STATE_PAYMENT_REVIEW ,
227280 '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
232286 ],
233287 'pending_payment - canUnhold -> pending_payment ' => [
234288 'can_credit_memo ' => true ,
@@ -237,10 +291,11 @@ public function stateCheckDataProvider()
237291 'call_can_skip_num ' => 0 ,
238292 'current_state ' => Order::STATE_PENDING_PAYMENT ,
239293 '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
244299 ],
245300 'cancelled - isCanceled -> cancelled ' => [
246301 'can_credit_memo ' => true ,
@@ -249,9 +304,24 @@ public function stateCheckDataProvider()
249304 'call_can_skip_num ' => 0 ,
250305 'current_state ' => Order::STATE_HOLDED ,
251306 '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
255325 ],
256326 ];
257327 }
0 commit comments