11<?php
22/**
3- * Copyright © Magento, Inc. All rights reserved.
4- * See COPYING.txt for license details .
3+ * Copyright 2021 Adobe
4+ * All Rights Reserved .
55 */
66declare (strict_types=1 );
77
@@ -55,7 +55,7 @@ protected function setUp(): void
5555 ->getMock ();
5656 $ this ->abstractModel = $ this ->getMockBuilder (AbstractModel::class)
5757 ->disableOriginalConstructor ()
58- ->addMethods (['getQuote ' , 'getProduct ' ])
58+ ->addMethods (['getQuote ' , 'getAllItems ' , ' getProduct ' ])
5959 ->getMockForAbstractClass ();
6060 $ this ->productMock = $ this ->getMockBuilder (Product::class)
6161 ->onlyMethods (['getData ' , 'getResource ' , 'hasData ' ])
@@ -64,6 +64,7 @@ protected function setUp(): void
6464 ->getMock ();
6565 $ this ->quoteMock = $ this ->getMockBuilder (Quote::class)
6666 ->disableOriginalConstructor ()
67+ ->addMethods (['getIsMultiShipping ' ])
6768 ->onlyMethods (['getAllVisibleItems ' ])
6869 ->getMock ();
6970 $ this ->quoteItemMock = $ this ->getMockBuilder (Item::class)
@@ -87,6 +88,9 @@ protected function setUp(): void
8788 $ this ->abstractModel ->expects ($ this ->any ())
8889 ->method ('getQuote ' )
8990 ->willReturn ($ this ->quoteMock );
91+ $ this ->abstractModel ->expects ($ this ->any ())
92+ ->method ('getAllItems ' )
93+ ->willReturn ([$ this ->quoteItemMock ]);
9094 $ this ->abstractModel ->expects ($ this ->any ())
9195 ->method ('getProduct ' )
9296 ->willReturn ($ this ->productMock );
@@ -102,6 +106,7 @@ protected function setUp(): void
102106 *
103107 * @param array|null $attributeDetails
104108 * @param array $productDetails
109+ * @param bool $isMultiShipping
105110 * @param bool $expectedResult
106111 * @return void
107112 * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
@@ -110,6 +115,7 @@ protected function setUp(): void
110115 public function testValidateForFixedBundleProduct (
111116 ?array $ attributeDetails ,
112117 array $ productDetails ,
118+ bool $ isMultiShipping ,
113119 bool $ expectedResult
114120 ): void {
115121 $ attributeResource = new DataObject ();
@@ -142,6 +148,9 @@ public function testValidateForFixedBundleProduct(
142148 $ this ->ruleConditionMock ->expects ($ this ->any ())->method ('getOperatorForValidate ' )
143149 ->willReturn ($ attributeDetails ['attributeOperator ' ]);
144150 }
151+ $ this ->quoteMock ->expects ($ this ->any ())
152+ ->method ('getIsMultiShipping ' )
153+ ->willReturn ($ isMultiShipping );
145154 $ this ->quoteItemMock ->expects ($ this ->any ())
146155 ->method ('getProductType ' )
147156 ->willReturn ($ productDetails ['type ' ]);
@@ -197,7 +206,7 @@ public function testValidateForFixedBundleProduct(
197206 public static function dataProviderForFixedBundleProduct (): array
198207 {
199208 return [
200- 'validate true for bundle product data with conditions ' =>
209+ 'validate true for bundle product data with conditions with multi shipping ' =>
201210 [
202211 [
203212 'id ' => 'attribute_set_id ' ,
@@ -214,9 +223,10 @@ public static function dataProviderForFixedBundleProduct(): array
214223 'baseRowTotal ' => 100 ,
215224 'valueParsed ' => 100
216225 ],
226+ true ,
217227 true
218228 ],
219- 'validate false for bundle product data with conditions ' =>
229+ 'validate false for bundle product data with conditions w/o multi shipping ' =>
220230 [
221231 [
222232 'id ' => 'attribute_set_id ' ,
@@ -233,9 +243,10 @@ public static function dataProviderForFixedBundleProduct(): array
233243 'baseRowTotal ' => 100 ,
234244 'valueParsed ' => 50
235245 ],
246+ false ,
236247 false
237248 ],
238- 'validate product data without conditions with bundle product ' =>
249+ 'validate product data without conditions with bundle product w/o multi shipping ' =>
239250 [
240251 null ,
241252 [
@@ -247,9 +258,11 @@ public static function dataProviderForFixedBundleProduct(): array
247258 'baseRowTotal ' => 100 ,
248259 'valueParsed ' => 100
249260 ],
261+ false ,
250262 false
251263 ],
252- 'validate true for bundle product data with conditions for attribute base_row_total ' =>
264+ 'validate true for bundle product
265+ data with conditions for attribute base_row_total w/o multi shipping ' =>
253266 [
254267 [
255268 'id ' => 'attribute_set_id ' ,
@@ -266,9 +279,10 @@ public static function dataProviderForFixedBundleProduct(): array
266279 'baseRowTotal ' => 200 ,
267280 'valueParsed ' => 200
268281 ],
282+ false ,
269283 false
270284 ],
271- 'validate true for simple product data with conditions ' =>
285+ 'validate true for simple product data with conditions with multi shipping ' =>
272286 [
273287 [
274288 'id ' => 'attribute_set_id ' ,
@@ -285,9 +299,10 @@ public static function dataProviderForFixedBundleProduct(): array
285299 'baseRowTotal ' => 100 ,
286300 'valueParsed ' => 100
287301 ],
302+ true ,
288303 true
289304 ],
290- 'validate false for simple product data with conditions ' =>
305+ 'validate false for simple product data with conditions w/o multi shipping ' =>
291306 [
292307 [
293308 'id ' => 'attribute_set_id ' ,
@@ -304,6 +319,7 @@ public static function dataProviderForFixedBundleProduct(): array
304319 'baseRowTotal ' => 100 ,
305320 'valueParsed ' => 50
306321 ],
322+ false ,
307323 false
308324 ]
309325 ];
@@ -314,6 +330,7 @@ public static function dataProviderForFixedBundleProduct(): array
314330 *
315331 * @param array|null $attributeDetails
316332 * @param array $productDetails
333+ * @param bool $isMultiShipping
317334 * @param bool $expectedResult
318335 * @return void
319336 * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
@@ -322,6 +339,7 @@ public static function dataProviderForFixedBundleProduct(): array
322339 public function testValidateForBaseTotalInclTax (
323340 ?array $ attributeDetails ,
324341 array $ productDetails ,
342+ bool $ isMultiShipping ,
325343 bool $ expectedResult
326344 ):void {
327345 $ attributeResource = new DataObject ();
@@ -355,6 +373,9 @@ public function testValidateForBaseTotalInclTax(
355373 ->willReturn ($ attributeDetails ['attributeOperator ' ]);
356374 }
357375
376+ $ this ->quoteMock ->expects ($ this ->any ())
377+ ->method ('getIsMultiShipping ' )
378+ ->willReturn ($ isMultiShipping );
358379 /* @var AbstractItem|MockObject $quoteItemMock */
359380 $ this ->productMock ->expects ($ this ->any ())
360381 ->method ('getResource ' )
@@ -380,7 +401,8 @@ public function testValidateForBaseTotalInclTax(
380401 public static function dataProviderForBaseTotalInclTax (): array
381402 {
382403 return [
383- 'validate true for product data with conditions for attribute base_row_total_incl_tax ' =>
404+ 'validate true for product data with conditions
405+ for attribute base_row_total_incl_tax w/o multi shipping ' =>
384406 [
385407 [
386408 'id ' => 'attribute_set_id ' ,
@@ -397,6 +419,7 @@ public static function dataProviderForBaseTotalInclTax(): array
397419 'baseRowTotalInclTax ' => 200 ,
398420 'valueParsed ' => 200
399421 ],
422+ false ,
400423 false
401424 ]
402425 ];
0 commit comments