@@ -235,4 +235,201 @@ 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 testGetSimpleQtyToShip (array $ options , $ expectedResult )
248
+ {
249
+ $ this ->model ->setData ($ options );
250
+ $ this ->assertSame ($ this ->model ->getSimpleQtyToShip (), $ expectedResult ['to_ship ' ]);
251
+ }
252
+
253
+ /**
254
+ * Test different combinations of item qty setups
255
+ *
256
+ * @param array $options
257
+ * @param float $expectedResult
258
+ *
259
+ * @dataProvider getItemQtyVariants
260
+ */
261
+ public function testGetQtyToInvoice (array $ options , $ expectedResult )
262
+ {
263
+ $ this ->model ->setData ($ options );
264
+ $ this ->assertSame ($ this ->model ->getQtyToInvoice (), $ expectedResult ['to_invoice ' ]);
265
+ }
266
+
267
+ /**
268
+ * Provides different combinations of qty options for an item and the
269
+ * expected qtys pending shipment and invoice
270
+ *
271
+ * @return array
272
+ */
273
+ public function getItemQtyVariants ()
274
+ {
275
+ return [
276
+ 'empty_item ' => [
277
+ 'options ' => [
278
+ 'qty_ordered ' => 0 ,
279
+ 'qty_invoiced ' => 0 ,
280
+ 'qty_refunded ' => 0 ,
281
+ 'qty_shipped ' => 0 ,
282
+ 'qty_canceled ' => 0 ,
283
+ ],
284
+ 'expectedResult ' => [
285
+ 'to_ship ' => 0.0 ,
286
+ 'to_invoice ' => 0.0
287
+ ]
288
+ ],
289
+ 'ordered_item ' => [
290
+ 'options ' => [
291
+ 'qty_ordered ' => 12 ,
292
+ 'qty_invoiced ' => 0 ,
293
+ 'qty_refunded ' => 0 ,
294
+ 'qty_shipped ' => 0 ,
295
+ 'qty_canceled ' => 0 ,
296
+ ],
297
+ 'expectedResult ' => [
298
+ 'to_ship ' => 12.0 ,
299
+ 'to_invoice ' => 12.0
300
+ ]
301
+ ],
302
+ 'partially_invoiced ' => [
303
+ 'options ' => [
304
+ 'qty_ordered ' => 12 ,
305
+ 'qty_invoiced ' => 4 ,
306
+ 'qty_refunded ' => 0 ,
307
+ 'qty_shipped ' => 0 ,
308
+ 'qty_canceled ' => 0 ,
309
+ ],
310
+ 'expectedResult ' => [
311
+ 'to_ship ' => 12.0 ,
312
+ 'to_invoice ' => 8.0
313
+ ]
314
+ ],
315
+ 'completely_invoiced ' => [
316
+ 'options ' => [
317
+ 'qty_ordered ' => 12 ,
318
+ 'qty_invoiced ' => 12 ,
319
+ 'qty_refunded ' => 0 ,
320
+ 'qty_shipped ' => 0 ,
321
+ 'qty_canceled ' => 0 ,
322
+ ],
323
+ 'expectedResult ' => [
324
+ 'to_ship ' => 12.0 ,
325
+ 'to_invoice ' => 0.0
326
+ ]
327
+ ],
328
+ 'partially_invoiced_refunded ' => [
329
+ 'options ' => [
330
+ 'qty_ordered ' => 12 ,
331
+ 'qty_invoiced ' => 5 ,
332
+ 'qty_refunded ' => 5 ,
333
+ 'qty_shipped ' => 0 ,
334
+ 'qty_canceled ' => 0 ,
335
+ ],
336
+ 'expectedResult ' => [
337
+ 'to_ship ' => 7.0 ,
338
+ 'to_invoice ' => 7.0
339
+ ]
340
+ ],
341
+ 'partially_refunded ' => [
342
+ 'options ' => [
343
+ 'qty_ordered ' => 12 ,
344
+ 'qty_invoiced ' => 12 ,
345
+ 'qty_refunded ' => 5 ,
346
+ 'qty_shipped ' => 0 ,
347
+ 'qty_canceled ' => 0 ,
348
+ ],
349
+ 'expectedResult ' => [
350
+ 'to_ship ' => 7.0 ,
351
+ 'to_invoice ' => 0.0
352
+ ]
353
+ ],
354
+ 'partially_shipped ' => [
355
+ 'options ' => [
356
+ 'qty_ordered ' => 12 ,
357
+ 'qty_invoiced ' => 0 ,
358
+ 'qty_refunded ' => 0 ,
359
+ 'qty_shipped ' => 4 ,
360
+ 'qty_canceled ' => 0 ,
361
+ ],
362
+ 'expectedResult ' => [
363
+ 'to_ship ' => 8.0 ,
364
+ 'to_invoice ' => 12.0
365
+ ]
366
+ ],
367
+ 'partially_refunded_partially_shipped ' => [
368
+ 'options ' => [
369
+ 'qty_ordered ' => 12 ,
370
+ 'qty_invoiced ' => 12 ,
371
+ 'qty_refunded ' => 5 ,
372
+ 'qty_shipped ' => 4 ,
373
+ 'qty_canceled ' => 0 ,
374
+ ],
375
+ 'expectedResult ' => [
376
+ 'to_ship ' => 3.0 ,
377
+ 'to_invoice ' => 0.0
378
+ ]
379
+ ],
380
+ 'complete ' => [
381
+ 'options ' => [
382
+ 'qty_ordered ' => 12 ,
383
+ 'qty_invoiced ' => 12 ,
384
+ 'qty_refunded ' => 0 ,
385
+ 'qty_shipped ' => 12 ,
386
+ 'qty_canceled ' => 0 ,
387
+ ],
388
+ 'expectedResult ' => [
389
+ 'to_ship ' => 0.0 ,
390
+ 'to_invoice ' => 0.0
391
+ ]
392
+ ],
393
+ 'canceled ' => [
394
+ 'options ' => [
395
+ 'qty_ordered ' => 12 ,
396
+ 'qty_invoiced ' => 0 ,
397
+ 'qty_refunded ' => 0 ,
398
+ 'qty_shipped ' => 0 ,
399
+ 'qty_canceled ' => 12 ,
400
+ ],
401
+ 'expectedResult ' => [
402
+ 'to_ship ' => 0.0 ,
403
+ 'to_invoice ' => 0.0
404
+ ]
405
+ ],
406
+ 'completely_shipped_using_decimals ' => [
407
+ 'options ' => [
408
+ 'qty_ordered ' => 4.4 ,
409
+ 'qty_invoiced ' => 0.4 ,
410
+ 'qty_refunded ' => 0.4 ,
411
+ 'qty_shipped ' => 4 ,
412
+ 'qty_canceled ' => 0 ,
413
+ ],
414
+ 'expectedResult ' => [
415
+ 'to_ship ' => 0.0 ,
416
+ 'to_invoice ' => 4.0
417
+ ]
418
+ ],
419
+ 'completely_invoiced_using_decimals ' => [
420
+ 'options ' => [
421
+ 'qty_ordered ' => 4.4 ,
422
+ 'qty_invoiced ' => 4 ,
423
+ 'qty_refunded ' => 0 ,
424
+ 'qty_shipped ' => 4 ,
425
+ 'qty_canceled ' => 0.4 ,
426
+ ],
427
+ 'expectedResult ' => [
428
+ 'to_ship ' => 0.0 ,
429
+ 'to_invoice ' => 0.0
430
+ ]
431
+ ]
432
+ ];
433
+ }
434
+
238
435
}
0 commit comments