Skip to content

Commit 9e8519d

Browse files
committed
Tests refactoring based on new fixtures principle
1 parent dc2f2d6 commit 9e8519d

17 files changed

+181
-431
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Customer/CartTotalsTest.php

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,34 +49,46 @@ protected function setUp()
4949
}
5050

5151
/**
52-
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_tax_customer.php
52+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
53+
* @magentoApiDataFixture Magento/GraphQl/Tax/_files/tax_rule_for_region_1.php
54+
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
55+
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/apply_tax_for_simple_product.php
56+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
57+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
58+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
59+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php
5360
*/
5461
public function testGetCartTotalsWithTaxApplied()
5562
{
56-
$maskedQuoteId = $this->getMaskedQuoteIdByReversedQuoteId('test_order_tax');
63+
$maskedQuoteId = $this->getMaskedQuoteIdByReversedQuoteId('test_quote');
5764
$query = $this->getCartTotalsGraphqlQuery($maskedQuoteId);
5865
$response = $this->sendRequestWithToken($query);
5966

6067
self::assertArrayHasKey('prices', $response['cart']);
6168
$pricesResponse = $response['cart']['prices'];
62-
self::assertEquals(10.83, $pricesResponse['grand_total']['value']);
63-
self::assertEquals(10.83, $pricesResponse['subtotal_including_tax']['value']);
64-
self::assertEquals(10, $pricesResponse['subtotal_excluding_tax']['value']);
65-
self::assertEquals(10, $pricesResponse['subtotal_with_discount_excluding_tax']['value']);
69+
self::assertEquals(21.5, $pricesResponse['grand_total']['value']);
70+
self::assertEquals(21.5, $pricesResponse['subtotal_including_tax']['value']);
71+
self::assertEquals(20, $pricesResponse['subtotal_excluding_tax']['value']);
72+
self::assertEquals(20, $pricesResponse['subtotal_with_discount_excluding_tax']['value']);
6673

6774
$appliedTaxesResponse = $pricesResponse['applied_taxes'];
6875

69-
self::assertEquals('US-CA-*-Rate 1', $appliedTaxesResponse[0]['label']);
70-
self::assertEquals(0.83, $appliedTaxesResponse[0]['amount']['value']);
76+
self::assertEquals('US-TEST-*-Rate-1', $appliedTaxesResponse[0]['label']);
77+
self::assertEquals(1.5, $appliedTaxesResponse[0]['amount']['value']);
7178
self::assertEquals('USD', $appliedTaxesResponse[0]['amount']['currency']);
7279
}
7380

7481
/**
75-
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
82+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
83+
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
84+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
85+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
86+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
87+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php
7688
*/
7789
public function testGetTotalsWithNoTaxApplied()
7890
{
79-
$maskedQuoteId = $this->getMaskedQuoteIdByReversedQuoteId('test_order_1');
91+
$maskedQuoteId = $this->getMaskedQuoteIdByReversedQuoteId('test_quote');
8092
$query = $this->getCartTotalsGraphqlQuery($maskedQuoteId);
8193
$response = $this->sendRequestWithToken($query);
8294

@@ -92,19 +104,22 @@ public function testGetTotalsWithNoTaxApplied()
92104
* The totals calculation is based on quote address.
93105
* But the totals should be calculated even if no address is set
94106
*
95-
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_customer_no_address.php
107+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
108+
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
109+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
110+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
96111
*/
97112
public function testGetCartTotalsWithNoAddressSet()
98113
{
99-
$maskedQuoteId = $this->getMaskedQuoteIdByReversedQuoteId('test_order_1');
114+
$maskedQuoteId = $this->getMaskedQuoteIdByReversedQuoteId('test_quote');
100115
$query = $this->getCartTotalsGraphqlQuery($maskedQuoteId);
101116
$response = $this->sendRequestWithToken($query);
102117

103118
$pricesResponse = $response['cart']['prices'];
104-
self::assertEquals(10, $pricesResponse['grand_total']['value']);
105-
self::assertEquals(10, $pricesResponse['subtotal_including_tax']['value']);
106-
self::assertEquals(10, $pricesResponse['subtotal_excluding_tax']['value']);
107-
self::assertEquals(10, $pricesResponse['subtotal_with_discount_excluding_tax']['value']);
119+
self::assertEquals(20, $pricesResponse['grand_total']['value']);
120+
self::assertEquals(20, $pricesResponse['subtotal_including_tax']['value']);
121+
self::assertEquals(20, $pricesResponse['subtotal_excluding_tax']['value']);
122+
self::assertEquals(20, $pricesResponse['subtotal_with_discount_excluding_tax']['value']);
108123
self::assertEmpty($pricesResponse['applied_taxes']);
109124
}
110125

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/CartTotalsTest.php

Lines changed: 33 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,62 +42,75 @@ protected function setUp()
4242
}
4343

4444
/**
45-
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_tax_guest.php
45+
* @magentoApiDataFixture Magento/GraphQl/Tax/_files/tax_rule_for_region_1.php
46+
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
47+
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/apply_tax_for_simple_product.php
48+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
49+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
50+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
51+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php
4652
*/
4753
public function testGetCartTotalsWithTaxApplied()
4854
{
49-
$maskedQuoteId = $this->getMaskedQuoteIdByReversedQuoteId('test_order_tax');
55+
$maskedQuoteId = $this->getMaskedQuoteIdByReversedQuoteId('test_quote');
5056
$query = $this->getCartTotalsGraphqlQuery($maskedQuoteId);
5157
$response = $this->graphQlQuery($query);
5258

5359
self::assertArrayHasKey('prices', $response['cart']);
5460
$pricesResponse = $response['cart']['prices'];
55-
self::assertEquals(10.83, $pricesResponse['grand_total']['value']);
56-
self::assertEquals(10.83, $pricesResponse['subtotal_including_tax']['value']);
57-
self::assertEquals(10, $pricesResponse['subtotal_excluding_tax']['value']);
58-
self::assertEquals(10, $pricesResponse['subtotal_with_discount_excluding_tax']['value']);
61+
self::assertEquals(21.5, $pricesResponse['grand_total']['value']);
62+
self::assertEquals(21.5, $pricesResponse['subtotal_including_tax']['value']);
63+
self::assertEquals(20, $pricesResponse['subtotal_excluding_tax']['value']);
64+
self::assertEquals(20, $pricesResponse['subtotal_with_discount_excluding_tax']['value']);
5965

6066
$appliedTaxesResponse = $pricesResponse['applied_taxes'];
6167

62-
self::assertEquals('US-CA-*-Rate 1', $appliedTaxesResponse[0]['label']);
63-
self::assertEquals(0.83, $appliedTaxesResponse[0]['amount']['value']);
68+
self::assertEquals('US-TEST-*-Rate-1', $appliedTaxesResponse[0]['label']);
69+
self::assertEquals(1.5, $appliedTaxesResponse[0]['amount']['value']);
6470
self::assertEquals('USD', $appliedTaxesResponse[0]['amount']['currency']);
6571
}
6672

6773
/**
68-
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_guest.php
74+
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
75+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
76+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
77+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_shipping_address.php
78+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/set_new_billing_address.php
6979
*/
7080
public function testGetTotalsWithNoTaxApplied()
7181
{
72-
$maskedQuoteId = $this->getMaskedQuoteIdByReversedQuoteId('test_order_1');
82+
$maskedQuoteId = $this->getMaskedQuoteIdByReversedQuoteId('test_quote');
7383
$query = $this->getCartTotalsGraphqlQuery($maskedQuoteId);
7484
$response = $this->graphQlQuery($query);
7585

7686
$pricesResponse = $response['cart']['prices'];
77-
self::assertEquals(10, $pricesResponse['grand_total']['value']);
78-
self::assertEquals(10, $pricesResponse['subtotal_including_tax']['value']);
79-
self::assertEquals(10, $pricesResponse['subtotal_excluding_tax']['value']);
80-
self::assertEquals(10, $pricesResponse['subtotal_with_discount_excluding_tax']['value']);
87+
self::assertEquals(20, $pricesResponse['grand_total']['value']);
88+
self::assertEquals(20, $pricesResponse['subtotal_including_tax']['value']);
89+
self::assertEquals(20, $pricesResponse['subtotal_excluding_tax']['value']);
90+
self::assertEquals(20, $pricesResponse['subtotal_with_discount_excluding_tax']['value']);
8191
self::assertEmpty($pricesResponse['applied_taxes']);
8292
}
8393

8494
/**
8595
* The totals calculation is based on quote address.
8696
* But the totals should be calculated even if no address is set
8797
*
88-
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
98+
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
99+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
100+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
101+
* @group recent
89102
*/
90103
public function testGetCartTotalsWithNoAddressSet()
91104
{
92-
$maskedQuoteId = $this->getMaskedQuoteIdByReversedQuoteId('test_order_with_simple_product_without_address');
105+
$maskedQuoteId = $this->getMaskedQuoteIdByReversedQuoteId('test_quote');
93106
$query = $this->getCartTotalsGraphqlQuery($maskedQuoteId);
94107
$response = $this->graphQlQuery($query);
95108

96109
$pricesResponse = $response['cart']['prices'];
97-
self::assertEquals(10, $pricesResponse['grand_total']['value']);
98-
self::assertEquals(10, $pricesResponse['subtotal_including_tax']['value']);
99-
self::assertEquals(10, $pricesResponse['subtotal_excluding_tax']['value']);
100-
self::assertEquals(10, $pricesResponse['subtotal_with_discount_excluding_tax']['value']);
110+
self::assertEquals(20, $pricesResponse['grand_total']['value']);
111+
self::assertEquals(20, $pricesResponse['subtotal_including_tax']['value']);
112+
self::assertEquals(20, $pricesResponse['subtotal_excluding_tax']['value']);
113+
self::assertEquals(20, $pricesResponse['subtotal_with_discount_excluding_tax']['value']);
101114
self::assertEmpty($pricesResponse['applied_taxes']);
102115
}
103116

dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_tax.php

Lines changed: 0 additions & 45 deletions
This file was deleted.

dev/tests/integration/testsuite/Magento/Catalog/_files/product_simple_with_tax_rollback.php

Lines changed: 0 additions & 8 deletions
This file was deleted.

dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_address_guest.php

Lines changed: 0 additions & 61 deletions
This file was deleted.

dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_address_guest_rollback.php

Lines changed: 0 additions & 21 deletions
This file was deleted.

dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_customer_no_address.php

Lines changed: 0 additions & 48 deletions
This file was deleted.

dev/tests/integration/testsuite/Magento/Checkout/_files/quote_with_customer_no_address_rollback.php

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)