11<?php
22/**
3- * Copyright © Magento, Inc. All rights reserved.
4- * See COPYING.txt for license details .
3+ * Copyright 2014 Adobe
4+ * All Rights Reserved .
55 */
66declare (strict_types=1 );
77
@@ -183,7 +183,7 @@ function ($argument) {
183183 /**
184184 * @return void
185185 */
186- public function testCollectItemNoDiscount ()
186+ public function testCollectItemNoDiscount (): void
187187 {
188188 $ itemNoDiscount = $ this ->getMockBuilder (Item::class)
189189 ->addMethods (['getNoDiscount ' ])
@@ -244,7 +244,7 @@ public function testCollectItemNoDiscount()
244244 /**
245245 * @return void
246246 */
247- public function testCollectItemHasParent ()
247+ public function testCollectItemHasParent (): void
248248 {
249249 $ itemWithParentId = $ this ->getMockBuilder (Item::class)
250250 ->addMethods (['getNoDiscount ' ])
@@ -303,7 +303,7 @@ public function testCollectItemHasParent()
303303 /**
304304 * @return void
305305 */
306- public function testCollectItemHasNoChildren ()
306+ public function testCollectItemHasNoChildren (): void
307307 {
308308 $ itemWithChildren = $ this ->getMockBuilder (Item::class)
309309 ->disableOriginalConstructor ()
@@ -387,7 +387,7 @@ public function testCollectItemHasNoChildren()
387387 * @return void
388388 * @throws \PHPUnit\Framework\MockObject\Exception
389389 */
390- public function testFetch ()
390+ public function testFetch (): void
391391 {
392392 $ discountAmount = 100 ;
393393 $ discountDescription = 100 ;
@@ -413,7 +413,7 @@ public function testFetch()
413413 * @return void
414414 * @throws \PHPUnit\Framework\MockObject\Exception
415415 */
416- public function testCollectAddressBaseDiscountAmount (): void
416+ public function testCollectAddressBaseDiscountAmountIncludingItemChildren (): void
417417 {
418418 $ storeId = 1 ;
419419 $ quote = $ this ->createMock (Quote::class);
@@ -442,16 +442,31 @@ public function testCollectAddressBaseDiscountAmount(): void
442442 ->willReturn ([$ rule1 , $ rule2 ]);
443443 $ item = $ this ->getMockBuilder (Item::class)
444444 ->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+ )
446455 ->disableOriginalConstructor ()
447456 ->getMock ();
448457 $ item ->expects ($ this ->any ())->method ('getNoDiscount ' )->willReturn (false );
449458 $ item ->expects ($ this ->any ())->method ('getId ' )->willReturn (1 );
450459 $ item ->expects ($ this ->any ())->method ('getParentItem ' )->willReturn (false );
451460 $ item ->expects ($ this ->any ())->method ('getExtensionAttributes ' )->willReturn (false );
452461 $ 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 );
453468 $ index = 1 ;
454- $ item ->expects ($ this ->any ())->method ('getBaseDiscountAmount ' )->willReturnCallback (function () use (&$ index ) {
469+ $ child ->expects ($ this ->any ())->method ('getBaseDiscountAmount ' )->willReturnCallback (function () use (&$ index ) {
455470 $ value = $ index * 10 ;
456471 $ index ++;
457472 return $ value ;
0 commit comments