@@ -183,7 +183,7 @@ function ($argument) {
183
183
/**
184
184
* @return void
185
185
*/
186
- public function testCollectItemNoDiscount ()
186
+ public function testCollectItemNoDiscount (): void
187
187
{
188
188
$ itemNoDiscount = $ this ->getMockBuilder (Item::class)
189
189
->addMethods (['getNoDiscount ' ])
@@ -244,7 +244,7 @@ public function testCollectItemNoDiscount()
244
244
/**
245
245
* @return void
246
246
*/
247
- public function testCollectItemHasParent ()
247
+ public function testCollectItemHasParent (): void
248
248
{
249
249
$ itemWithParentId = $ this ->getMockBuilder (Item::class)
250
250
->addMethods (['getNoDiscount ' ])
@@ -303,7 +303,7 @@ public function testCollectItemHasParent()
303
303
/**
304
304
* @return void
305
305
*/
306
- public function testCollectItemHasNoChildren ()
306
+ public function testCollectItemHasNoChildren (): void
307
307
{
308
308
$ itemWithChildren = $ this ->getMockBuilder (Item::class)
309
309
->disableOriginalConstructor ()
@@ -387,7 +387,7 @@ public function testCollectItemHasNoChildren()
387
387
* @return void
388
388
* @throws \PHPUnit\Framework\MockObject\Exception
389
389
*/
390
- public function testFetch ()
390
+ public function testFetch (): void
391
391
{
392
392
$ discountAmount = 100 ;
393
393
$ discountDescription = 100 ;
@@ -413,7 +413,7 @@ public function testFetch()
413
413
* @return void
414
414
* @throws \PHPUnit\Framework\MockObject\Exception
415
415
*/
416
- public function testCollectAddressBaseDiscountAmount (): void
416
+ public function testCollectAddressBaseDiscountAmountIncludingItemChildren (): void
417
417
{
418
418
$ storeId = 1 ;
419
419
$ quote = $ this ->createMock (Quote::class);
@@ -442,16 +442,31 @@ public function testCollectAddressBaseDiscountAmount(): void
442
442
->willReturn ([$ rule1 , $ rule2 ]);
443
443
$ item = $ this ->getMockBuilder (Item::class)
444
444
->addMethods (['getNoDiscount ' , 'getBaseDiscountAmount ' ])
445
- ->onlyMethods (['getParentItem ' , 'getId ' , 'getExtensionAttributes ' , 'getAddress ' ])
445
+ ->onlyMethods (
446
+ [
447
+ 'getParentItem ' ,
448
+ 'getId ' ,
449
+ 'getExtensionAttributes ' ,
450
+ 'getAddress ' ,
451
+ 'getChildren ' ,
452
+ 'isChildrenCalculated '
453
+ ]
454
+ )
446
455
->disableOriginalConstructor ()
447
456
->getMock ();
448
457
$ item ->expects ($ this ->any ())->method ('getNoDiscount ' )->willReturn (false );
449
458
$ item ->expects ($ this ->any ())->method ('getId ' )->willReturn (1 );
450
459
$ item ->expects ($ this ->any ())->method ('getParentItem ' )->willReturn (false );
451
460
$ item ->expects ($ this ->any ())->method ('getExtensionAttributes ' )->willReturn (false );
452
461
$ item ->expects ($ this ->once ())->method ('getAddress ' )->willReturn ($ this ->addressMock );
462
+ $ child = $ this ->getMockBuilder (Item::class)
463
+ ->addMethods (['getBaseDiscountAmount ' ])
464
+ ->disableOriginalConstructor ()
465
+ ->getMock ();
466
+ $ item ->expects ($ this ->exactly (2 ))->method ('getChildren ' )->willReturn ([$ child ]);
467
+ $ item ->expects ($ this ->once ())->method ('isChildrenCalculated ' )->willReturn (true );
453
468
$ index = 1 ;
454
- $ item ->expects ($ this ->any ())->method ('getBaseDiscountAmount ' )->willReturnCallback (function () use (&$ index ) {
469
+ $ child ->expects ($ this ->any ())->method ('getBaseDiscountAmount ' )->willReturnCallback (function () use (&$ index ) {
455
470
$ value = $ index * 10 ;
456
471
$ index ++;
457
472
return $ value ;
0 commit comments