6
6
*/
7
7
namespace Magento \Quote \Api ;
8
8
9
+ use Magento \Catalog \Model \Indexer \Product \Category \Processor ;
10
+ use Magento \Catalog \Test \Fixture \Product as ProductFixture ;
11
+ use Magento \Checkout \Test \Fixture \SetBillingAddress as SetBillingAddressFixture ;
12
+ use Magento \Checkout \Test \Fixture \SetDeliveryMethod as SetDeliveryMethodFixture ;
13
+ use Magento \Checkout \Test \Fixture \SetGuestEmail as SetGuestEmailFixture ;
14
+ use Magento \Checkout \Test \Fixture \SetPaymentMethod as SetPaymentMethodFixture ;
15
+ use Magento \Checkout \Test \Fixture \SetShippingAddress as SetShippingAddressFixture ;
16
+ use Magento \Quote \Api \Data \AddressInterface ;
9
17
use Magento \Quote \Model \Cart \Totals ;
10
18
use Magento \Quote \Model \Cart \Totals \Item as ItemTotals ;
11
19
use Magento \Framework \Api \FilterBuilder ;
12
20
use Magento \Framework \Api \SearchCriteriaBuilder ;
21
+ use Magento \Quote \Test \Fixture \AddProductToCart as AddProductToCartFixture ;
22
+ use Magento \Quote \Test \Fixture \GuestCart as GuestCartFixture ;
23
+ use Magento \Tax \Test \Fixture \TaxRule as TaxRule ;
24
+ use Magento \TestFramework \Fixture \DataFixture ;
25
+ use Magento \TestFramework \Fixture \DataFixtureStorageManager ;
13
26
use Magento \TestFramework \ObjectManager ;
14
27
use Magento \TestFramework \TestCase \WebapiAbstract ;
15
28
use Magento \Quote \Model \Quote ;
@@ -22,6 +35,11 @@ class CartTotalRepositoryTest extends WebapiAbstract
22
35
*/
23
36
private $ objectManager ;
24
37
38
+ /**
39
+ * @var Processor
40
+ */
41
+ private $ indexer ;
42
+
25
43
/**
26
44
* @var SearchCriteriaBuilder
27
45
*/
@@ -41,6 +59,7 @@ protected function setUp(): void
41
59
$ this ->filterBuilder = $ this ->objectManager ->create (
42
60
\Magento \Framework \Api \FilterBuilder::class
43
61
);
62
+ $ this ->fixtures = $ this ->objectManager ->get (DataFixtureStorageManager::class)->getStorage ();
44
63
}
45
64
46
65
/**
@@ -73,6 +92,32 @@ public function testGetTotals()
73
92
$ this ->assertEquals ($ data , $ actual );
74
93
}
75
94
95
+ /**
96
+ * @magentoConfigFixture default_store tax/defaults/region 43
97
+ * @magentoConfigFixture default_store tax/defaults/postcode 10036
98
+ * @magentoConfigFixture default_store shipping/origin/region_id 43
99
+ * @magentoConfigFixture default_store shipping/origin/postcode 10011
100
+ */
101
+ #[
102
+ DataFixture(TaxRule::class, ['tax_rate_ids ' => [2 ], 'product_tax_class_ids ' => [2 ], 'customer_tax_class_ids ' => [3 ], 'code ' => 'TaxRule1 ' ], 'tax_rule ' ),
103
+ DataFixture(ProductFixture::class, ['price ' =>5 ], 'product ' ),
104
+ DataFixture(GuestCartFixture::class, as: 'cart ' ),
105
+ DataFixture(AddProductToCartFixture::class, ['cart_id ' => '$cart.id$ ' , 'product_id ' => '$product.id$ ' ]),
106
+ DataFixture(SetBillingAddressFixture::class, ['cart_id ' => '$cart.id$ ' , 'address ' => [AddressInterface::KEY_POSTCODE => 10036 , AddressInterface::KEY_CITY => 'New York ' , AddressInterface::KEY_REGION_ID => 43 ] ]),
107
+ DataFixture(SetShippingAddressFixture::class, ['cart_id ' => '$cart.id$ ' , 'address ' => [AddressInterface::KEY_POSTCODE => 10036 , AddressInterface::KEY_CITY => 'New York ' , AddressInterface::KEY_REGION_ID => 43 ] ]),
108
+ DataFixture(SetGuestEmailFixture::class, ['cart_id ' => '$cart.id$ ' ]),
109
+ DataFixture(SetDeliveryMethodFixture::class, ['cart_id ' => '$cart.id$ ' ]),
110
+ DataFixture(SetPaymentMethodFixture::class, ['cart_id ' => '$cart.id$ ' ]),
111
+ ]
112
+ public function testGetGrandTotalsWithIncludedTaxAndSameCurrency ()
113
+ {
114
+ $ cart = $ this ->fixtures ->get ('cart ' );
115
+ $ cartId = $ cart ->getid ();
116
+ $ requestData = ['cartId ' => $ cartId ];
117
+ $ actual = $ this ->_webApiCall ($ this ->getServiceInfoForTotalsService ($ cartId ), $ requestData );
118
+ $ this ->assertEquals ($ actual ['base_grand_total ' ], $ actual ['grand_total ' ]);
119
+ }
120
+
76
121
/**
77
122
*/
78
123
public function testGetTotalsWithAbsentQuote ()
0 commit comments