@@ -235,4 +235,114 @@ public function getProductOptionsDataProvider()
235
235
]
236
236
];
237
237
}
238
+
239
+ /**
240
+ * Test different combinations of item qty setups
241
+ *
242
+ * @param array $options
243
+ * @param float $expectedResult
244
+ *
245
+ * @dataProvider getItemQtyVariants
246
+ */
247
+ public function testGetSimpleQtyToMethods (array $ options , $ expectedResult )
248
+ {
249
+ $ this ->model ->setData ($ options );
250
+ $ this ->assertSame ($ this ->model ->getSimpleQtyToShip (), $ expectedResult ['to_ship ' ]);
251
+ $ this ->assertSame ($ this ->model ->getQtyToInvoice (), $ expectedResult ['to_invoice ' ]);
252
+ }
253
+
254
+ /**
255
+ * Provides different combinations of qty options for an item and the
256
+ * expected qtys pending shipment and invoice
257
+ *
258
+ * @return array
259
+ */
260
+ public function getItemQtyVariants ()
261
+ {
262
+ return [
263
+ 'empty_item ' => [
264
+ 'options ' => [
265
+ 'qty_ordered ' => 0 , 'qty_invoiced ' => 0 , 'qty_refunded ' => 0 , 'qty_shipped ' => 0 ,
266
+ 'qty_canceled ' => 0
267
+ ],
268
+ 'expectedResult ' => ['to_ship ' => 0.0 , 'to_invoice ' => 0.0 ]
269
+ ],
270
+ 'ordered_item ' => [
271
+ 'options ' => [
272
+ 'qty_ordered ' => 12 , 'qty_invoiced ' => 0 , 'qty_refunded ' => 0 , 'qty_shipped ' => 0 ,
273
+ 'qty_canceled ' => 0
274
+ ],
275
+ 'expectedResult ' => ['to_ship ' => 12.0 , 'to_invoice ' => 12.0 ]
276
+ ],
277
+ 'partially_invoiced ' => [
278
+ 'options ' => ['qty_ordered ' => 12 , 'qty_invoiced ' => 4 , 'qty_refunded ' => 0 , 'qty_shipped ' => 0 ,
279
+ 'qty_canceled ' => 0 ,
280
+ ],
281
+ 'expectedResult ' => ['to_ship ' => 12.0 , 'to_invoice ' => 8.0 ]
282
+ ],
283
+ 'completely_invoiced ' => [
284
+ 'options ' => [
285
+ 'qty_ordered ' => 12 , 'qty_invoiced ' => 12 , 'qty_refunded ' => 0 , 'qty_shipped ' => 0 ,
286
+ 'qty_canceled ' => 0 ,
287
+ ],
288
+ 'expectedResult ' => ['to_ship ' => 12.0 , 'to_invoice ' => 0.0 ]
289
+ ],
290
+ 'partially_invoiced_refunded ' => [
291
+ 'options ' => [
292
+ 'qty_ordered ' => 12 , 'qty_invoiced ' => 5 , 'qty_refunded ' => 5 , 'qty_shipped ' => 0 ,
293
+ 'qty_canceled ' => 0 ,
294
+ ],
295
+ 'expectedResult ' => ['to_ship ' => 7.0 , 'to_invoice ' => 7.0 ]
296
+ ],
297
+ 'partially_refunded ' => [
298
+ 'options ' => [
299
+ 'qty_ordered ' => 12 , 'qty_invoiced ' => 12 , 'qty_refunded ' => 5 , 'qty_shipped ' => 0 ,
300
+ 'qty_canceled ' => 0 ,
301
+ ],
302
+ 'expectedResult ' => ['to_ship ' => 7.0 , 'to_invoice ' => 0.0 ]
303
+ ],
304
+ 'partially_shipped ' => [
305
+ 'options ' => [
306
+ 'qty_ordered ' => 12 , 'qty_invoiced ' => 0 , 'qty_refunded ' => 0 , 'qty_shipped ' => 4 ,
307
+ 'qty_canceled ' => 0
308
+ ],
309
+ 'expectedResult ' => ['to_ship ' => 8.0 , 'to_invoice ' => 12.0 ]
310
+ ],
311
+ 'partially_refunded_partially_shipped ' => [
312
+ 'options ' => [
313
+ 'qty_ordered ' => 12 , 'qty_invoiced ' => 12 , 'qty_refunded ' => 5 , 'qty_shipped ' => 4 ,
314
+ 'qty_canceled ' => 0
315
+ ],
316
+ 'expectedResult ' => ['to_ship ' => 3.0 , 'to_invoice ' => 0.0 ]
317
+ ],
318
+ 'complete ' => [
319
+ 'options ' => [
320
+ 'qty_ordered ' => 12 , 'qty_invoiced ' => 12 , 'qty_refunded ' => 0 , 'qty_shipped ' => 12 ,
321
+ 'qty_canceled ' => 0
322
+ ],
323
+ 'expectedResult ' => ['to_ship ' => 0.0 , 'to_invoice ' => 0.0 ]
324
+ ],
325
+ 'canceled ' => [
326
+ 'options ' => [
327
+ 'qty_ordered ' => 12 , 'qty_invoiced ' => 0 , 'qty_refunded ' => 0 , 'qty_shipped ' => 0 ,
328
+ 'qty_canceled ' => 12
329
+ ],
330
+ 'expectedResult ' => ['to_ship ' => 0.0 , 'to_invoice ' => 0.0 ]
331
+ ],
332
+ 'completely_shipped_using_decimals ' => [
333
+ 'options ' => [
334
+ 'qty_ordered ' => 4.4 , 'qty_invoiced ' => 0.4 , 'qty_refunded ' => 0.4 , 'qty_shipped ' => 4 ,
335
+ 'qty_canceled ' => 0 ,
336
+ ],
337
+ 'expectedResult ' => ['to_ship ' => 0.0 , 'to_invoice ' => 4.0 ]
338
+ ],
339
+ 'completely_invoiced_using_decimals ' => [
340
+ 'options ' => [
341
+ 'qty_ordered ' => 4.4 , 'qty_invoiced ' => 4 , 'qty_refunded ' => 0 , 'qty_shipped ' => 4 ,
342
+ 'qty_canceled ' => 0.4
343
+ ],
344
+ 'expectedResult ' => ['to_ship ' => 0.0 , 'to_invoice ' => 0.0 ]
345
+ ]
346
+ ];
347
+ }
238
348
}
0 commit comments