Skip to content

Commit 1c93a01

Browse files
author
Prabhu Ram
committed
MC-22213: Implementation - Merge cart
- Added tests and assertions
1 parent 7122eca commit 1c93a01

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

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

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,50 @@ public function testMergeGuestWithCustomerCart()
9090
$this->getHeaderMap()
9191
);
9292

93+
self::assertArrayHasKey('cart', $cartResponse);
94+
self::assertArrayHasKey('items', $cartResponse['cart']);
95+
self::assertCount(2, $cartResponse['cart']['items']);
96+
$item1 = $cartResponse['cart']['items'][0];
97+
self::assertArrayHasKey('quantity', $item1);
98+
self::assertEquals(2, $item1['quantity']);
99+
$item2 = $cartResponse['cart']['items'][1];
100+
self::assertArrayHasKey('quantity', $item2);
101+
self::assertEquals(1, $item2['quantity']);
102+
}
103+
104+
/**
105+
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_virtual_product_saved.php
106+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
107+
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
108+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
109+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
110+
* @expectedException \Exception
111+
* @expectedExceptionMessage Current user does not have an active cart.
112+
*/
113+
public function testGuestCartExpiryAfterMerge()
114+
{
115+
$customerQuote = $this->quoteFactory->create();
116+
$this->quoteResource->load($customerQuote, 'test_quote', 'reserved_order_id');
117+
118+
$guestQuote = $this->quoteFactory->create();
119+
$this->quoteResource->load(
120+
$guestQuote,
121+
'test_order_with_virtual_product_without_address',
122+
'reserved_order_id'
123+
);
124+
125+
$customerQuoteMaskedId = $this->quoteIdToMaskedId->execute((int)$customerQuote->getId());
126+
$guestQuoteMaskedId = $this->quoteIdToMaskedId->execute((int)$guestQuote->getId());
127+
128+
$query = $this->getCartMergeMutation($guestQuoteMaskedId, $customerQuoteMaskedId);
129+
$this->graphQlMutation($query, [], '', $this->getHeaderMap());
130+
$cartResponse = $this->graphQlMutation(
131+
$this->getCartQuery($guestQuoteMaskedId),
132+
[],
133+
'',
134+
$this->getHeaderMap()
135+
);
136+
93137
self::assertArrayHasKey('cart', $cartResponse);
94138
self::assertArrayHasKey('items', $cartResponse['cart']);
95139
self::assertCount(2, $cartResponse['cart']['items']);

0 commit comments

Comments
 (0)