@@ -386,11 +386,14 @@ public function testInitTotalsCanApplyDiscount()
386
386
'getDiscountCalculationPrice ' ,
387
387
'getBaseDiscountCalculationPrice ' ,
388
388
'getCalculationPrice ' ,
389
- 'getParentItemId '
389
+ 'getParentItemId ' ,
390
+ 'getParentItem '
390
391
]
391
392
);
392
393
$ item2 = clone $ item1 ;
393
- $ items = [$ item1 , $ item2 ];
394
+ $ item3 = clone $ item1 ;
395
+ $ item4 = clone $ item1 ;
396
+ $ items = [$ item1 , $ item2 , $ item3 , $ item4 ];
394
397
395
398
$ rule ->expects ($ this ->any ())
396
399
->method ('getSimpleAction ' )
@@ -407,12 +410,22 @@ public function testInitTotalsCanApplyDiscount()
407
410
$ validator ->expects ($ this ->at (0 ))->method ('isValid ' )->with ($ item1 )->willReturn (false );
408
411
$ validator ->expects ($ this ->at (1 ))->method ('isValid ' )->with ($ item2 )->willReturn (true );
409
412
410
- $ item1 ->expects ($ this ->any ())->method ('getParentItemId ' )->willReturn (false );
413
+ $ item1 ->expects ($ this ->any ())->method ('getParentItemId ' )->willReturn (null );
414
+ $ item1 ->expects ($ this ->any ())->method ('getParentItem ' )->willReturn (null );
411
415
$ item1 ->expects ($ this ->never ())->method ('getDiscountCalculationPrice ' );
412
416
$ item1 ->expects ($ this ->never ())->method ('getBaseDiscountCalculationPrice ' );
413
- $ item2 ->expects ($ this ->any ())->method ('getParentItemId ' )->willReturn (false );
417
+ $ item2 ->expects ($ this ->any ())->method ('getParentItemId ' )->willReturn (null );
418
+ $ item2 ->expects ($ this ->any ())->method ('getParentItem ' )->willReturn (null );
414
419
$ item2 ->expects ($ this ->any ())->method ('getDiscountCalculationPrice ' )->willReturn (50 );
415
420
$ item2 ->expects ($ this ->once ())->method ('getBaseDiscountCalculationPrice ' )->willReturn (50 );
421
+ $ item3 ->expects ($ this ->any ())->method ('getParentItemId ' )->willReturn (null );
422
+ $ item3 ->expects ($ this ->any ())->method ('getParentItem ' )->willReturn ($ item1 );
423
+ $ item3 ->expects ($ this ->never ())->method ('getDiscountCalculationPrice ' );
424
+ $ item3 ->expects ($ this ->never ())->method ('getBaseDiscountCalculationPrice ' );
425
+ $ item4 ->expects ($ this ->any ())->method ('getParentItemId ' )->willReturn (12345 );
426
+ $ item4 ->expects ($ this ->any ())->method ('getParentItem ' )->willReturn (null );
427
+ $ item4 ->expects ($ this ->never ())->method ('getDiscountCalculationPrice ' );
428
+ $ item4 ->expects ($ this ->never ())->method ('getBaseDiscountCalculationPrice ' );
416
429
$ this ->utility ->expects ($ this ->once ())->method ('getItemQty ' )->willReturn (1 );
417
430
$ this ->utility ->expects ($ this ->any ())->method ('canProcessRule ' )->willReturn (true );
418
431
0 commit comments