66 */
77namespace Magento \Quote \Api ;
88
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 ;
917use Magento \Quote \Model \Cart \Totals ;
1018use Magento \Quote \Model \Cart \Totals \Item as ItemTotals ;
1119use Magento \Framework \Api \FilterBuilder ;
1220use 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 ;
1326use Magento \TestFramework \ObjectManager ;
1427use Magento \TestFramework \TestCase \WebapiAbstract ;
1528use Magento \Quote \Model \Quote ;
@@ -22,6 +35,11 @@ class CartTotalRepositoryTest extends WebapiAbstract
2235 */
2336 private $ objectManager ;
2437
38+ /**
39+ * @var Processor
40+ */
41+ private $ indexer ;
42+
2543 /**
2644 * @var SearchCriteriaBuilder
2745 */
@@ -41,6 +59,7 @@ protected function setUp(): void
4159 $ this ->filterBuilder = $ this ->objectManager ->create (
4260 \Magento \Framework \Api \FilterBuilder::class
4361 );
62+ $ this ->fixtures = $ this ->objectManager ->get (DataFixtureStorageManager::class)->getStorage ();
4463 }
4564
4665 /**
@@ -73,6 +92,32 @@ public function testGetTotals()
7392 $ this ->assertEquals ($ data , $ actual );
7493 }
7594
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+
76121 /**
77122 */
78123 public function testGetTotalsWithAbsentQuote ()
0 commit comments