Skip to content

Commit 536df3b

Browse files
committed
Merge remote-tracking branch '34872/feature/product_subselect_total_incl_tax_option' into comm_247beta3
2 parents bf6d017 + 9611cf9 commit 536df3b

File tree

3 files changed

+102
-2
lines changed

3 files changed

+102
-2
lines changed

app/code/Magento/SalesRule/Model/Rule/Condition/Product/Subselect.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,13 @@ public function asXml($containerKey = 'conditions', $itemKey = 'condition')
7070
*/
7171
public function loadAttributeOptions()
7272
{
73-
$this->setAttributeOption(['qty' => __('total quantity'), 'base_row_total' => __('total amount')]);
73+
$this->setAttributeOption(
74+
[
75+
'qty' => __('total quantity'),
76+
'base_row_total' => __('total amount (excl. tax)'),
77+
'base_row_total_incl_tax' => __('total amount (incl. tax)')
78+
]
79+
);
7480
return $this;
7581
}
7682

app/code/Magento/SalesRule/Test/Unit/Model/Rule/Condition/Product/SubselectTest.php

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,4 +308,97 @@ public function dataProviderForFixedBundleProduct(): array
308308
]
309309
];
310310
}
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+
}
311404
}

app/code/Magento/SalesRule/i18n/en_US.csv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ FOUND,FOUND
9999
"NOT FOUND","NOT FOUND"
100100
"If an item is %1 in the cart with %2 of these conditions true:","If an item is %1 in the cart with %2 of these conditions true:"
101101
"total quantity","total quantity"
102-
"total amount","total amount"
102+
"total amount (excl. tax)","total amount (excl. tax)"
103+
"total amount (incl. tax)","total amount (incl. tax)"
103104
is,is
104105
"is not","is not"
105106
"equals or greater than","equals or greater than"

0 commit comments

Comments
 (0)