1
1
<?php
2
2
/**
3
- * Copyright © Magento, Inc. All rights reserved.
4
- * See COPYING.txt for license details .
3
+ * Copyright 2021 Adobe
4
+ * All Rights Reserved .
5
5
*/
6
6
declare (strict_types=1 );
7
7
@@ -55,7 +55,7 @@ protected function setUp(): void
55
55
->getMock ();
56
56
$ this ->abstractModel = $ this ->getMockBuilder (AbstractModel::class)
57
57
->disableOriginalConstructor ()
58
- ->addMethods (['getQuote ' , 'getProduct ' ])
58
+ ->addMethods (['getQuote ' , 'getAllItems ' , ' getProduct ' ])
59
59
->getMockForAbstractClass ();
60
60
$ this ->productMock = $ this ->getMockBuilder (Product::class)
61
61
->onlyMethods (['getData ' , 'getResource ' , 'hasData ' ])
@@ -64,6 +64,7 @@ protected function setUp(): void
64
64
->getMock ();
65
65
$ this ->quoteMock = $ this ->getMockBuilder (Quote::class)
66
66
->disableOriginalConstructor ()
67
+ ->addMethods (['getIsMultiShipping ' ])
67
68
->onlyMethods (['getAllVisibleItems ' ])
68
69
->getMock ();
69
70
$ this ->quoteItemMock = $ this ->getMockBuilder (Item::class)
@@ -87,6 +88,9 @@ protected function setUp(): void
87
88
$ this ->abstractModel ->expects ($ this ->any ())
88
89
->method ('getQuote ' )
89
90
->willReturn ($ this ->quoteMock );
91
+ $ this ->abstractModel ->expects ($ this ->any ())
92
+ ->method ('getAllItems ' )
93
+ ->willReturn ([$ this ->quoteItemMock ]);
90
94
$ this ->abstractModel ->expects ($ this ->any ())
91
95
->method ('getProduct ' )
92
96
->willReturn ($ this ->productMock );
@@ -102,6 +106,7 @@ protected function setUp(): void
102
106
*
103
107
* @param array|null $attributeDetails
104
108
* @param array $productDetails
109
+ * @param bool $isMultiShipping
105
110
* @param bool $expectedResult
106
111
* @return void
107
112
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
@@ -110,6 +115,7 @@ protected function setUp(): void
110
115
public function testValidateForFixedBundleProduct (
111
116
?array $ attributeDetails ,
112
117
array $ productDetails ,
118
+ bool $ isMultiShipping ,
113
119
bool $ expectedResult
114
120
): void {
115
121
$ attributeResource = new DataObject ();
@@ -142,6 +148,9 @@ public function testValidateForFixedBundleProduct(
142
148
$ this ->ruleConditionMock ->expects ($ this ->any ())->method ('getOperatorForValidate ' )
143
149
->willReturn ($ attributeDetails ['attributeOperator ' ]);
144
150
}
151
+ $ this ->quoteMock ->expects ($ this ->any ())
152
+ ->method ('getIsMultiShipping ' )
153
+ ->willReturn ($ isMultiShipping );
145
154
$ this ->quoteItemMock ->expects ($ this ->any ())
146
155
->method ('getProductType ' )
147
156
->willReturn ($ productDetails ['type ' ]);
@@ -197,7 +206,7 @@ public function testValidateForFixedBundleProduct(
197
206
public static function dataProviderForFixedBundleProduct (): array
198
207
{
199
208
return [
200
- 'validate true for bundle product data with conditions ' =>
209
+ 'validate true for bundle product data with conditions with multi shipping ' =>
201
210
[
202
211
[
203
212
'id ' => 'attribute_set_id ' ,
@@ -214,9 +223,10 @@ public static function dataProviderForFixedBundleProduct(): array
214
223
'baseRowTotal ' => 100 ,
215
224
'valueParsed ' => 100
216
225
],
226
+ true ,
217
227
true
218
228
],
219
- 'validate false for bundle product data with conditions ' =>
229
+ 'validate false for bundle product data with conditions w/o multi shipping ' =>
220
230
[
221
231
[
222
232
'id ' => 'attribute_set_id ' ,
@@ -233,9 +243,10 @@ public static function dataProviderForFixedBundleProduct(): array
233
243
'baseRowTotal ' => 100 ,
234
244
'valueParsed ' => 50
235
245
],
246
+ false ,
236
247
false
237
248
],
238
- 'validate product data without conditions with bundle product ' =>
249
+ 'validate product data without conditions with bundle product w/o multi shipping ' =>
239
250
[
240
251
null ,
241
252
[
@@ -247,9 +258,11 @@ public static function dataProviderForFixedBundleProduct(): array
247
258
'baseRowTotal ' => 100 ,
248
259
'valueParsed ' => 100
249
260
],
261
+ false ,
250
262
false
251
263
],
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 ' =>
253
266
[
254
267
[
255
268
'id ' => 'attribute_set_id ' ,
@@ -266,9 +279,10 @@ public static function dataProviderForFixedBundleProduct(): array
266
279
'baseRowTotal ' => 200 ,
267
280
'valueParsed ' => 200
268
281
],
282
+ false ,
269
283
false
270
284
],
271
- 'validate true for simple product data with conditions ' =>
285
+ 'validate true for simple product data with conditions with multi shipping ' =>
272
286
[
273
287
[
274
288
'id ' => 'attribute_set_id ' ,
@@ -285,9 +299,10 @@ public static function dataProviderForFixedBundleProduct(): array
285
299
'baseRowTotal ' => 100 ,
286
300
'valueParsed ' => 100
287
301
],
302
+ true ,
288
303
true
289
304
],
290
- 'validate false for simple product data with conditions ' =>
305
+ 'validate false for simple product data with conditions w/o multi shipping ' =>
291
306
[
292
307
[
293
308
'id ' => 'attribute_set_id ' ,
@@ -304,6 +319,7 @@ public static function dataProviderForFixedBundleProduct(): array
304
319
'baseRowTotal ' => 100 ,
305
320
'valueParsed ' => 50
306
321
],
322
+ false ,
307
323
false
308
324
]
309
325
];
@@ -314,6 +330,7 @@ public static function dataProviderForFixedBundleProduct(): array
314
330
*
315
331
* @param array|null $attributeDetails
316
332
* @param array $productDetails
333
+ * @param bool $isMultiShipping
317
334
* @param bool $expectedResult
318
335
* @return void
319
336
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
@@ -322,6 +339,7 @@ public static function dataProviderForFixedBundleProduct(): array
322
339
public function testValidateForBaseTotalInclTax (
323
340
?array $ attributeDetails ,
324
341
array $ productDetails ,
342
+ bool $ isMultiShipping ,
325
343
bool $ expectedResult
326
344
):void {
327
345
$ attributeResource = new DataObject ();
@@ -355,6 +373,9 @@ public function testValidateForBaseTotalInclTax(
355
373
->willReturn ($ attributeDetails ['attributeOperator ' ]);
356
374
}
357
375
376
+ $ this ->quoteMock ->expects ($ this ->any ())
377
+ ->method ('getIsMultiShipping ' )
378
+ ->willReturn ($ isMultiShipping );
358
379
/* @var AbstractItem|MockObject $quoteItemMock */
359
380
$ this ->productMock ->expects ($ this ->any ())
360
381
->method ('getResource ' )
@@ -380,7 +401,8 @@ public function testValidateForBaseTotalInclTax(
380
401
public static function dataProviderForBaseTotalInclTax (): array
381
402
{
382
403
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 ' =>
384
406
[
385
407
[
386
408
'id ' => 'attribute_set_id ' ,
@@ -397,6 +419,7 @@ public static function dataProviderForBaseTotalInclTax(): array
397
419
'baseRowTotalInclTax ' => 200 ,
398
420
'valueParsed ' => 200
399
421
],
422
+ false ,
400
423
false
401
424
]
402
425
];
0 commit comments