Skip to content

Commit 9f64ae6

Browse files
committed
MC-21491: Pricing :: FPT display settings
- fix test
1 parent bf40eca commit 9f64ae6

File tree

2 files changed

+97
-3
lines changed

2 files changed

+97
-3
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Tax/ProductViewTest.php

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,22 @@ private function getFixtureTaxRules()
270270
*/
271271
private function assertBaseFields($product, $actualResponse)
272272
{
273+
$pricesTypes = [
274+
'minimalPrice',
275+
'regularPrice',
276+
'maximalPrice',
277+
];
278+
foreach ($pricesTypes as $priceType) {
279+
if (isset($actualResponse['price'][$priceType]['amount']['value'])) {
280+
$actualResponse['price'][$priceType]['amount']['value'] =
281+
round($actualResponse['price'][$priceType]['amount']['value'], 4);
282+
}
283+
284+
if (isset($actualResponse['price'][$priceType]['adjustments'][0]['amount']['value'])) {
285+
$actualResponse['price'][$priceType]['adjustments'][0]['amount']['value'] =
286+
round($actualResponse['price'][$priceType]['adjustments'][0]['amount']['value'], 4);
287+
}
288+
}
273289
// product_object_field_name, expected_value
274290
$assertionMap = [
275291
['response_field' => 'attribute_set_id', 'expected_value' => $product->getAttributeSetId()],
@@ -288,7 +304,7 @@ private function assertBaseFields($product, $actualResponse)
288304
[
289305
'amount' =>
290306
[
291-
'value' => 0.286501,
307+
'value' => 0.2865,
292308
'currency' => 'USD',
293309
],
294310
'code' => 'TAX',
@@ -306,7 +322,7 @@ private function assertBaseFields($product, $actualResponse)
306322
[
307323
'amount' =>
308324
[
309-
'value' => 0.750001,
325+
'value' => 0.7500,
310326
'currency' => 'USD',
311327
],
312328
'code' => 'TAX',
@@ -324,7 +340,7 @@ private function assertBaseFields($product, $actualResponse)
324340
[
325341
'amount' =>
326342
[
327-
'value' => 0.286501,
343+
'value' => 0.2865,
328344
'currency' => 'USD',
329345
],
330346
'code' => 'TAX',

dev/tests/api-functional/testsuite/Magento/GraphQl/Weee/ProductPriceWithFPTTest.php

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ class ProductPriceWithFPTTest extends GraphQlAbstract
3333
/** @var ScopeConfigInterface */
3434
private $scopeConfig;
3535

36+
37+
/** @var \Magento\Tax\Model\Calculation\Rate[] */
38+
private $fixtureTaxRates;
39+
40+
/** @var \Magento\Tax\Model\Calculation\Rule[] */
41+
private $fixtureTaxRules;
42+
3643
/**
3744
* @inheritdoc
3845
*/
@@ -52,18 +59,46 @@ protected function setUp(): void
5259
'tax/calculation/price_includes_tax'
5360
];
5461

62+
63+
$this->getFixtureTaxRates();
64+
$this->getFixtureTaxRules();
65+
$taxRules = $this->getFixtureTaxRules();
66+
if (count($taxRules)) {
67+
$taxRates = $this->getFixtureTaxRates();
68+
foreach ($taxRules as $taxRule) {
69+
$taxRule->delete();
70+
}
71+
foreach ($taxRates as $taxRate) {
72+
$taxRate->delete();
73+
}
74+
}
75+
5576
foreach ($currentSettingsArray as $configPath) {
5677
$this->initialConfig[$configPath] = $this->scopeConfig->getValue(
5778
$configPath
5879
);
5980
}
81+
/** @var \Magento\Framework\App\Config\ReinitableConfigInterface $config */
82+
$config = $this->objectManager->get(\Magento\Framework\App\Config\ReinitableConfigInterface::class);
83+
$config->reinit();
6084
}
6185

6286
/**
6387
* @inheritdoc
6488
*/
6589
protected function tearDown(): void
6690
{
91+
$taxRules = $this->getFixtureTaxRules();
92+
if (count($taxRules)) {
93+
$taxRates = $this->getFixtureTaxRates();
94+
foreach ($taxRules as $taxRule) {
95+
$taxRule->delete();
96+
}
97+
foreach ($taxRates as $taxRate) {
98+
$taxRate->delete();
99+
}
100+
}
101+
67102
$this->writeConfig($this->initialConfig);
68103
}
69104

@@ -727,4 +762,47 @@ private function getProductQuery(array $skus): string
727762
}
728763
QUERY;
729764
}
765+
766+
/**
767+
* Get tax rates created in Magento\Tax\_files\tax_rule_region_1_al.php
768+
*
769+
* @return \Magento\Tax\Model\Calculation\Rate[]
770+
*/
771+
private function getFixtureTaxRates()
772+
{
773+
if ($this->fixtureTaxRates === null) {
774+
$this->fixtureTaxRates = [];
775+
if ($this->getFixtureTaxRules()) {
776+
$taxRateIds = (array)$this->getFixtureTaxRules()[0]->getRates();
777+
foreach ($taxRateIds as $taxRateId) {
778+
/** @var \Magento\Tax\Model\Calculation\Rate $taxRate */
779+
$taxRate = Bootstrap::getObjectManager()->create(\Magento\Tax\Model\Calculation\Rate::class);
780+
$this->fixtureTaxRates[] = $taxRate->load($taxRateId);
781+
}
782+
}
783+
}
784+
return $this->fixtureTaxRates;
785+
}
786+
787+
/**
788+
* Get tax rule created in Magento\Tax\_files\tax_rule_region_1_al.php
789+
*
790+
* @return \Magento\Tax\Model\Calculation\Rule[]
791+
*/
792+
private function getFixtureTaxRules()
793+
{
794+
if ($this->fixtureTaxRules === null) {
795+
$this->fixtureTaxRules = [];
796+
$taxRuleCodes = ['AL Test Rule'];
797+
foreach ($taxRuleCodes as $taxRuleCode) {
798+
/** @var \Magento\Tax\Model\Calculation\Rule $taxRule */
799+
$taxRule = Bootstrap::getObjectManager()->create(\Magento\Tax\Model\Calculation\Rule::class);
800+
$taxRule->load($taxRuleCode, 'code');
801+
if ($taxRule->getId()) {
802+
$this->fixtureTaxRules[] = $taxRule;
803+
}
804+
}
805+
}
806+
return $this->fixtureTaxRules;
807+
}
730808
}

0 commit comments

Comments
 (0)