File tree 5 files changed +67
-6
lines changed
api-functional/testsuite/Magento/GraphQl/Quote
integration/testsuite/Magento/Checkout/_files 5 files changed +67
-6
lines changed Original file line number Diff line number Diff line change @@ -73,7 +73,6 @@ public function testGetCartTotalsWithTaxApplied()
73
73
74
74
/**
75
75
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_address_saved.php
76
- * @group last
77
76
*/
78
77
public function testGetTotalsWithNoTaxApplied ()
79
78
{
@@ -89,6 +88,26 @@ public function testGetTotalsWithNoTaxApplied()
89
88
self ::assertEmpty ($ pricesResponse ['applied_taxes ' ]);
90
89
}
91
90
91
+ /**
92
+ * The totals calculation is based on quote address.
93
+ * But the totals should be calculated even if no address is set
94
+ *
95
+ * @magentoApiDataFixture Magento/Checkout/_files/quote_with_customer_no_address.php
96
+ */
97
+ public function testGetCartTotalsWithNoAddressSet ()
98
+ {
99
+ $ maskedQuoteId = $ this ->getMaskedQuoteIdByReversedQuoteId ('test_order_1 ' );
100
+ $ query = $ this ->getCartTotalsGraphqlQuery ($ maskedQuoteId );
101
+ $ response = $ this ->sendRequestWithToken ($ query );
102
+
103
+ $ 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 ' ]);
108
+ self ::assertEmpty ($ pricesResponse ['applied_taxes ' ]);
109
+ }
110
+
92
111
/**
93
112
* Generates GraphQl query for retrieving cart totals
94
113
*
Original file line number Diff line number Diff line change @@ -81,6 +81,26 @@ public function testGetTotalsWithNoTaxApplied()
81
81
self ::assertEmpty ($ pricesResponse ['applied_taxes ' ]);
82
82
}
83
83
84
+ /**
85
+ * The totals calculation is based on quote address.
86
+ * But the totals should be calculated even if no address is set
87
+ *
88
+ * @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
89
+ */
90
+ public function testGetCartTotalsWithNoAddressSet ()
91
+ {
92
+ $ maskedQuoteId = $ this ->getMaskedQuoteIdByReversedQuoteId ('test_order_with_simple_product_without_address ' );
93
+ $ query = $ this ->getCartTotalsGraphqlQuery ($ maskedQuoteId );
94
+ $ response = $ this ->graphQlQuery ($ query );
95
+
96
+ $ 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 ' ]);
101
+ self ::assertEmpty ($ pricesResponse ['applied_taxes ' ]);
102
+ }
103
+
84
104
/**
85
105
* Generates GraphQl query for retrieving cart totals
86
106
*
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+
7
+ use Magento \Quote \Model \Quote ;
8
+ use Magento \Quote \Model \QuoteIdMask ;
9
+ use Magento \TestFramework \Helper \Bootstrap ;
10
+ use Magento \TestFramework \ObjectManager ;
11
+
12
+ require __DIR__ . '/../../Customer/_files/customer_rollback.php ' ;
13
+ require __DIR__ . '/../../../Magento/Catalog/_files/products_rollback.php ' ;
14
+
15
+ /** @var $objectManager ObjectManager */
16
+ $ objectManager = Bootstrap::getObjectManager ();
17
+ $ quote = $ objectManager ->create (Quote::class);
18
+ $ quote ->load ('test_order_1 ' , 'reserved_order_id ' )->delete ();
19
+
20
+ /** @var QuoteIdMask $quoteIdMask */
21
+ $ quoteIdMask = $ objectManager ->create (QuoteIdMask::class);
22
+ $ quoteIdMask ->delete ($ quote ->getId ());
Original file line number Diff line number Diff line change 59
59
$ quoteRepository ->save ($ quote );
60
60
61
61
/** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */
62
- $ quoteIdMask = \ Magento \ TestFramework \ Helper \Bootstrap:: getObjectManager ()
63
- ->create (\Magento \Quote \Model \QuoteIdMaskFactory::class)
62
+ $ quoteIdMask = $ objectManager
63
+ ->get (\Magento \Quote \Model \QuoteIdMaskFactory::class)
64
64
->create ();
65
65
$ quoteIdMask ->setQuoteId ($ quote ->getId ());
66
66
$ quoteIdMask ->setDataChanges (true );
Original file line number Diff line number Diff line change 39
39
)->setBillingAddress (
40
40
$ quoteAddress
41
41
)->setCheckoutMethod (
42
- 'customer '
42
+ 'guest '
43
43
)->setReservedOrderId (
44
44
'test_order_tax '
45
45
)->addProduct (
55
55
$ quoteRepository ->save ($ quote );
56
56
57
57
/** @var \Magento\Quote\Model\QuoteIdMask $quoteIdMask */
58
- $ quoteIdMask = \ Magento \ TestFramework \ Helper \Bootstrap:: getObjectManager ()
59
- ->create (\Magento \Quote \Model \QuoteIdMaskFactory::class)
58
+ $ quoteIdMask = $ objectManager
59
+ ->get (\Magento \Quote \Model \QuoteIdMaskFactory::class)
60
60
->create ();
61
61
$ quoteIdMask ->setQuoteId ($ quote ->getId ());
62
62
$ quoteIdMask ->setDataChanges (true );
You can’t perform that action at this time.
0 commit comments