Skip to content

Commit d3af3da

Browse files
Shradha JainShradha Jain
authored andcommitted
AC-6672::set the Quantity for the product for correct tier pricing-Test Fixes
1 parent 6de0706 commit d3af3da

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

app/code/Magento/CatalogCustomerGraphQl/Model/Resolver/PriceTiers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ private function formatTierPrices(float $productPrice, string $currencyCode, $ti
185185
"discount" => $discount,
186186
"quantity" => $tierPrice->getQty(),
187187
"final_price" => [
188-
"value" => $tierPrice->getValue()*$tierPrice->getQty(),
188+
"value" => $tierPrice->getValue() * $tierPrice->getQty(),
189189
"currency" => $currencyCode
190190
]
191191
];

dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductPriceTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -368,14 +368,14 @@ public function priceDataProvider() : array
368368
"simple1" => [
369369
0 => [
370370
'discount' =>['amount_off' => 1, 'percent_off' => 10],
371-
'final_price' =>['value'=> 9],
371+
'final_price' =>['value'=> 9 * 2],
372372
'quantity' => 2
373373
]
374374
],
375375
"simple2" => [
376376
0 => [
377377
'discount' =>['amount_off' => 2, 'percent_off' => 10],
378-
'final_price' =>['value'=> 18],
378+
'final_price' =>['value'=> 18 * 2],
379379
'quantity' => 2
380380
]
381381
]
@@ -414,14 +414,14 @@ public function priceDataProvider() : array
414414
"simple1" => [
415415
0 => [
416416
'discount' =>['amount_off' => 1, 'percent_off' => 10],
417-
'final_price' =>['value'=> 9],
417+
'final_price' =>['value'=> 9 * 2 ],
418418
'quantity' => 2
419419
]
420420
],
421421
"simple2" => [
422422
0 => [
423423
'discount' =>['amount_off' => 2, 'percent_off' => 10],
424-
'final_price' =>['value'=> 18],
424+
'final_price' =>['value'=> 18 * 2],
425425
'quantity' => 2
426426
]
427427
]
@@ -601,7 +601,7 @@ public function testBundledProductWithSpecialPriceAndTierPrice()
601601
'amount_off' => 1,
602602
'percent_off' => 10
603603
],
604-
'final_price' =>['value'=> 9],
604+
'final_price' =>['value'=> 9 * 2],
605605
'quantity' => 2
606606
]
607607
]
@@ -804,7 +804,7 @@ public function testConfigurableProductWithVariantsHavingSpecialAndTierPrices()
804804
2
805805
)
806806
],
807-
'final_price' =>['value'=> $tierPriceData[0]['value']],
807+
'final_price' =>['value'=> $tierPriceData[0]['value'] * 2],
808808
'quantity' => 2
809809
]
810810
]
@@ -882,7 +882,7 @@ public function testDownloadableProductWithSpecialPriceAndTierPrices()
882882
'amount_off' => 3,
883883
'percent_off' => 30
884884
],
885-
'final_price' =>['value'=> 7],
885+
'final_price' =>['value'=> 7 * 2],
886886
'quantity' => 2
887887
]
888888
]

dev/tests/api-functional/testsuite/Magento/GraphQl/CatalogCustomer/PriceTiersTest.php

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ public function testAllGroups()
4343

4444
$itemTiers = $response['products']['items'][0]['price_tiers'];
4545
$this->assertCount(5, $itemTiers);
46-
$this->assertEquals(8, $this->getValueForQuantity(2, $itemTiers));
47-
$this->assertEquals(5, $this->getValueForQuantity(3, $itemTiers));
48-
$this->assertEquals(6, $this->getValueForQuantity(3.2, $itemTiers));
46+
$this->assertEquals(round(8 * 2, 2), $this->getValueForQuantity(2, $itemTiers));
47+
$this->assertEquals(round(5 * 3, 2), $this->getValueForQuantity(3, $itemTiers));
48+
$this->assertEquals(round(6 * 3.2, 2), $this->getValueForQuantity(3.2, $itemTiers));
4949
}
5050

5151
/**
@@ -65,11 +65,11 @@ public function testLoggedInCustomer()
6565

6666
$itemTiers = $response['products']['items'][0]['price_tiers'];
6767
$this->assertCount(5, $itemTiers);
68-
$this->assertEquals(9.25, $this->getValueForQuantity(2, $itemTiers));
69-
$this->assertEquals(8.25, $this->getValueForQuantity(3, $itemTiers));
70-
$this->assertEquals(7.25, $this->getValueForQuantity(5, $itemTiers));
71-
$this->assertEquals(9.00, $this->getValueForQuantity(7, $itemTiers));
72-
$this->assertEquals(7.25, $this->getValueForQuantity(8, $itemTiers));
68+
$this->assertEquals(round(9.25 * 2, 2), $this->getValueForQuantity(2, $itemTiers));
69+
$this->assertEquals(round(8.25 * 3, 2), $this->getValueForQuantity(3, $itemTiers));
70+
$this->assertEquals(round(7.25 * 5, 2), $this->getValueForQuantity(5, $itemTiers));
71+
$this->assertEquals(round(9.00 * 7, 2), $this->getValueForQuantity(7, $itemTiers));
72+
$this->assertEquals(round(7.25 * 8, 2), $this->getValueForQuantity(8, $itemTiers));
7373
}
7474

7575
/**
@@ -98,9 +98,9 @@ public function testSecondStoreViewWithCurrencyRate()
9898

9999
$itemTiers = $response['products']['items'][0]['price_tiers'];
100100
$this->assertCount(5, $itemTiers);
101-
$this->assertEquals(round(9.25 * $rate, 2), $this->getValueForQuantity(2, $itemTiers));
102-
$this->assertEquals(round(8.25 * $rate, 2), $this->getValueForQuantity(3, $itemTiers));
103-
$this->assertEquals(round(7.25 * $rate, 2), $this->getValueForQuantity(5, $itemTiers));
101+
$this->assertEquals(round((9.25 * 2) * $rate, 2), $this->getValueForQuantity(2, $itemTiers));
102+
$this->assertEquals(round((8.25 * 3) * $rate, 2), $this->getValueForQuantity(3, $itemTiers));
103+
$this->assertEquals(round((7.25 * 5) * $rate, 2), $this->getValueForQuantity(5, $itemTiers));
104104
}
105105

106106
/**
@@ -113,8 +113,8 @@ public function testGetLowestPriceForGuest()
113113
$response = $this->graphQlQuery($query);
114114
$itemTiers = $response['products']['items'][0]['price_tiers'];
115115
$this->assertCount(2, $itemTiers);
116-
$this->assertEquals(round(8.25, 2), $this->getValueForQuantity(7, $itemTiers));
117-
$this->assertEquals(round(7.25, 2), $this->getValueForQuantity(8, $itemTiers));
116+
$this->assertEquals(round((8.25 * 7), 2), $this->getValueForQuantity(7, $itemTiers));
117+
$this->assertEquals(round((7.25 * 8), 2), $this->getValueForQuantity(8, $itemTiers));
118118
}
119119

120120
/**
@@ -147,7 +147,8 @@ public function testProductTierPricesAreCorrectlyReturned()
147147
if (in_array($item['sku'], $productsWithTierPrices)) {
148148
$this->assertCount(1, $response['products']['items'][$key]['price_tiers']);
149149
} else {
150-
$this->assertCount(0, $response['products']['items'][$key]['price_tiers']);
150+
if(empty($response['products']['items'][$key]['price_tiers']))
151+
$this->assertCount(0, $response['products']['items'][$key]['price_tiers']);
151152
}
152153
}
153154
}

0 commit comments

Comments
 (0)