@@ -308,4 +308,97 @@ public function dataProviderForFixedBundleProduct(): array
308
308
]
309
309
];
310
310
}
311
+
312
+ /**
313
+ * Tests validate for base row total incl tax
314
+ *
315
+ * @param array|null $attributeDetails
316
+ * @param array $productDetails
317
+ * @param bool $expectedResult
318
+ * @return void
319
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
320
+ * @dataProvider dataProviderForBaseTotalInclTax
321
+ */
322
+ public function testValidateForBaseTotalInclTax (
323
+ ?array $ attributeDetails ,
324
+ array $ productDetails ,
325
+ bool $ expectedResult
326
+ ):void {
327
+ $ attributeResource = new DataObject ();
328
+ if ($ attributeDetails ) {
329
+ $ attributeResource ->setAttribute ($ attributeDetails ['id ' ]);
330
+ $ this ->ruleConditionMock ->expects ($ this ->any ())
331
+ ->method ('setName ' )
332
+ ->willReturn ($ attributeDetails ['name ' ]);
333
+ $ this ->ruleConditionMock ->expects ($ this ->any ())
334
+ ->method ('setAttributeScope ' )
335
+ ->willReturn ($ attributeDetails ['attributeScope ' ]);
336
+ $ this ->ruleConditionMock ->expects ($ this ->any ())
337
+ ->method ('getAttribute ' )
338
+ ->willReturn ($ attributeDetails ['id ' ]);
339
+ $ this ->model ->setData ('conditions ' , [$ this ->ruleConditionMock ]);
340
+ $ this ->model ->setData ('attribute ' , $ attributeDetails ['id ' ]);
341
+ $ this ->model ->setData ('value ' , $ productDetails ['valueParsed ' ]);
342
+ $ this ->model ->setData ('operator ' , $ attributeDetails ['attributeOperator ' ]);
343
+ $ this ->productMock ->expects ($ this ->any ())
344
+ ->method ('hasData ' )
345
+ ->with ($ attributeDetails ['id ' ])
346
+ ->willReturn (!empty ($ productDetails ));
347
+ $ this ->productMock ->expects ($ this ->any ())
348
+ ->method ('getData ' )
349
+ ->with ($ attributeDetails ['id ' ])
350
+ ->willReturn ($ productDetails ['price ' ]);
351
+ $ this ->ruleConditionMock ->expects ($ this ->any ())
352
+ ->method ('getValueParsed ' )
353
+ ->willReturn ($ productDetails ['valueParsed ' ]);
354
+ $ this ->ruleConditionMock ->expects ($ this ->any ())->method ('getOperatorForValidate ' )
355
+ ->willReturn ($ attributeDetails ['attributeOperator ' ]);
356
+ }
357
+
358
+ /* @var AbstractItem|MockObject $quoteItemMock */
359
+ $ this ->productMock ->expects ($ this ->any ())
360
+ ->method ('getResource ' )
361
+ ->willReturn ($ attributeResource );
362
+ $ this ->quoteItemMock ->expects ($ this ->any ())
363
+ ->method ('getProduct ' )
364
+ ->willReturn ($ this ->productMock );
365
+ $ this ->quoteItemMock ->expects ($ this ->any ())
366
+ ->method ('getProductId ' )
367
+ ->willReturn ($ productDetails ['id ' ]);
368
+ $ this ->quoteItemMock ->expects ($ this ->any ())
369
+ ->method ('getData ' )
370
+ ->willReturn ($ productDetails ['baseRowTotalInclTax ' ]);
371
+ $ this ->assertEquals ($ expectedResult , $ this ->model ->validate ($ this ->abstractModel ));
372
+ }
373
+
374
+ /**
375
+ * Get data provider array for validate base total incl tax
376
+ *
377
+ * @return array
378
+ * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
379
+ */
380
+ public function dataProviderForBaseTotalInclTax (): array
381
+ {
382
+ return [
383
+ 'validate true for product data with conditions for attribute base_row_total_incl_tax ' =>
384
+ [
385
+ [
386
+ 'id ' => 'attribute_set_id ' ,
387
+ 'name ' => 'base_row_total_incl_tax ' ,
388
+ 'attributeScope ' => 'frontend ' ,
389
+ 'attributeOperator ' => '== '
390
+ ],
391
+ [
392
+ 'id ' => 1 ,
393
+ 'type ' => ProductType::TYPE_SIMPLE ,
394
+ 'qty ' => 2 ,
395
+ 'price ' => 100 ,
396
+ 'hasChildren ' => true ,
397
+ 'baseRowTotalInclTax ' => 200 ,
398
+ 'valueParsed ' => 200
399
+ ],
400
+ false
401
+ ]
402
+ ];
403
+ }
311
404
}
0 commit comments