Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,13 @@ public function asXml($containerKey = 'conditions', $itemKey = 'condition')
*/
public function loadAttributeOptions()
{
$this->setAttributeOption(['qty' => __('total quantity'), 'base_row_total' => __('total amount')]);
$this->setAttributeOption(
[
'qty' => __('total quantity'),
'base_row_total' => __('total amount (excl. tax)'),
'base_row_total_incl_tax' => __('total amount (incl. tax)')
]
);
return $this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,97 @@ public function dataProviderForFixedBundleProduct(): array
]
];
}

/**
* Tests validate for base row total incl tax
*
* @param array|null $attributeDetails
* @param array $productDetails
* @param bool $expectedResult
* @return void
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
* @dataProvider dataProviderForBaseTotalInclTax
*/
public function testValidateForBaseTotalInclTax(
?array $attributeDetails,
array $productDetails,
bool $expectedResult
):void {
$attributeResource = new DataObject();
if ($attributeDetails) {
$attributeResource->setAttribute($attributeDetails['id']);
$this->ruleConditionMock->expects($this->any())
->method('setName')
->willReturn($attributeDetails['name']);
$this->ruleConditionMock->expects($this->any())
->method('setAttributeScope')
->willReturn($attributeDetails['attributeScope']);
$this->ruleConditionMock->expects($this->any())
->method('getAttribute')
->willReturn($attributeDetails['id']);
$this->model->setData('conditions', [$this->ruleConditionMock]);
$this->model->setData('attribute', $attributeDetails['id']);
$this->model->setData('value', $productDetails['valueParsed']);
$this->model->setData('operator', $attributeDetails['attributeOperator']);
$this->productMock->expects($this->any())
->method('hasData')
->with($attributeDetails['id'])
->willReturn(!empty($productDetails));
$this->productMock->expects($this->any())
->method('getData')
->with($attributeDetails['id'])
->willReturn($productDetails['price']);
$this->ruleConditionMock->expects($this->any())
->method('getValueParsed')
->willReturn($productDetails['valueParsed']);
$this->ruleConditionMock->expects($this->any())->method('getOperatorForValidate')
->willReturn($attributeDetails['attributeOperator']);
}

/* @var AbstractItem|MockObject $quoteItemMock */
$this->productMock->expects($this->any())
->method('getResource')
->willReturn($attributeResource);
$this->quoteItemMock->expects($this->any())
->method('getProduct')
->willReturn($this->productMock);
$this->quoteItemMock->expects($this->any())
->method('getProductId')
->willReturn($productDetails['id']);
$this->quoteItemMock->expects($this->any())
->method('getData')
->willReturn($productDetails['baseRowTotalInclTax']);
$this->assertEquals($expectedResult, $this->model->validate($this->abstractModel));
}

/**
* Get data provider array for validate base total incl tax
*
* @return array
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
*/
public function dataProviderForBaseTotalInclTax(): array
{
return [
'validate true for product data with conditions for attribute base_row_total_incl_tax' =>
[
[
'id' => 'attribute_set_id',
'name' => 'base_row_total_incl_tax',
'attributeScope' => 'frontend',
'attributeOperator' => '=='
],
[
'id'=> 1,
'type' => ProductType::TYPE_SIMPLE,
'qty' => 2,
'price' => 100,
'hasChildren' => true,
'baseRowTotalInclTax' => 200,
'valueParsed' => 200
],
false
]
];
}
}
3 changes: 2 additions & 1 deletion app/code/Magento/SalesRule/i18n/en_US.csv
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ FOUND,FOUND
"NOT FOUND","NOT FOUND"
"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:"
"total quantity","total quantity"
"total amount","total amount"
"total amount (excl. tax)","total amount (excl. tax)"
"total amount (incl. tax)","total amount (incl. tax)"
is,is
"is not","is not"
"equals or greater than","equals or greater than"
Expand Down