@@ -118,10 +118,11 @@ protected function setUp(): void
118118
119119 /**
120120 * @param bool $freeshipping
121+ * @param bool $isShipSeparately
121122 * @dataProvider collectRatesWithGlobalFreeShippingDataProvider
122123 * @return void
123124 */
124- public function testCollectRatesWithGlobalFreeShipping ($ freeshipping )
125+ public function testCollectRatesWithGlobalFreeShipping ($ freeshipping, $ isShipSeparately )
125126 {
126127 $ rate = [
127128 'price ' => 15 ,
@@ -177,11 +178,17 @@ public function testCollectRatesWithGlobalFreeShipping($freeshipping)
177178 $ this ->resultFactoryMock ->expects ($ this ->once ())->method ('create ' )->willReturn ($ result );
178179
179180 $ product ->expects ($ this ->any ())->method ('isVirtual ' )->willReturn (false );
180-
181181 $ item ->expects ($ this ->any ())->method ('getProduct ' )->willReturn ($ product );
182- $ item ->expects ($ this ->any ())->method ('getFreeShipping ' )->willReturn (1 );
183182 $ item ->expects ($ this ->any ())->method ('getQty ' )->willReturn (1 );
184-
183+ if ($ isShipSeparately ) {
184+ $ freeShippingReturnValue = true ;
185+ $ item ->expects ($ this ->any ())->method ('getHasChildren ' )->willReturn (1 );
186+ $ item ->expects ($ this ->any ())->method ('isShipSeparately ' )->willReturn (1 );
187+ $ item ->expects ($ this ->any ())->method ('getChildren ' )->willReturn ([$ item ]);
188+ } else {
189+ $ freeShippingReturnValue = "1 " ;
190+ }
191+ $ item ->expects ($ this ->any ())->method ('getFreeShipping ' )->willReturn ($ freeShippingReturnValue );
185192 $ request ->expects ($ this ->any ())->method ('getAllItems ' )->willReturn ([$ item ]);
186193 $ request ->expects ($ this ->any ())->method ('getPackageQty ' )->willReturn (1 );
187194
@@ -225,8 +232,9 @@ private function captureArg(&$captureVar)
225232 public function collectRatesWithGlobalFreeShippingDataProvider ()
226233 {
227234 return [
228- ['freeshipping ' => true ],
229- ['freeshipping ' => false ]
235+ ['freeshipping ' => true , 'isShipSeparately ' => false ],
236+ ['freeshipping ' => false , 'isShipSeparately ' => false ],
237+ ['freeshipping ' => true , 'isShipSeparately ' => true ]
230238 ];
231239 }
232240}
0 commit comments