Skip to content

Commit 3874423

Browse files
committed
MC-22215: Add customerCart Query and cart_id changes to schema and related resolvers
- Fixed cart_id to id
1 parent a1b2a4f commit 3874423

File tree

7 files changed

+31
-32
lines changed

7 files changed

+31
-32
lines changed

app/code/Magento/QuoteGraphQl/etc/schema.graphqls

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ type PlaceOrderOutput {
193193
}
194194

195195
type Cart {
196-
cart_id: ID! @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\MaskedCartId") @doc(description: "The ID of the cart.")
196+
id: ID! @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\MaskedCartId") @doc(description: "The ID of the cart.")
197197
items: [CartItemInterface] @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\CartItems")
198198
applied_coupon: AppliedCoupon @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\AppliedCoupon") @doc(description:"An array of coupons that have been applied to the cart") @deprecated(reason: "Use applied_coupons instead ")
199199
applied_coupons: [AppliedCoupon] @resolver(class: "\\Magento\\QuoteGraphQl\\Model\\Resolver\\AppliedCoupons") @doc(description:"An array of `AppliedCoupon` objects. Each object contains the `code` text attribute, which specifies the coupon code")

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ public function testGetCart()
6565
$response = $this->graphQlQuery($query, [], '', $this->getHeaderMap());
6666

6767
self::assertArrayHasKey('cart', $response);
68-
self::assertArrayHasKey('cart_id', $response['cart']);
69-
self::assertEquals($maskedQuoteId, $response['cart']['cart_id']);
68+
self::assertArrayHasKey('id', $response['cart']);
69+
self::assertEquals($maskedQuoteId, $response['cart']['id']);
7070
self::assertArrayHasKey('items', $response['cart']);
7171
self::assertCount(2, $response['cart']['items']);
7272

@@ -190,8 +190,7 @@ public function testGetCartWithNotDefaultStore()
190190
}
191191

192192
/**
193-
* @magentoApiDataFixture Magento/Customer/_files/customer.php
194-
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
193+
* @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
195194
* @magentoApiDataFixture Magento/Store/_files/second_store.php
196195
*
197196
* @expectedException Exception
@@ -258,7 +257,7 @@ private function getQuery(string $maskedQuoteId): string
258257
return <<<QUERY
259258
{
260259
cart(cart_id: "{$maskedQuoteId}") {
261-
cart_id
260+
id
262261
items {
263262
id
264263
quantity

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ public function testGetActiveCustomerCart()
5353
$this->assertArrayHasKey('items', $response['customerCart']);
5454
$this->assertNotEmpty($response['customerCart']['items']);
5555
$this->assertEquals(2, $response['customerCart']['total_quantity']);
56-
$this->assertArrayHasKey('cart_id', $response['customerCart']);
57-
$this->assertEquals($maskedQuoteId, $response['customerCart']['cart_id']);
56+
$this->assertArrayHasKey('id', $response['customerCart']);
57+
$this->assertEquals($maskedQuoteId, $response['customerCart']['id']);
5858
$this->assertEquals(
5959
$quantity,
6060
$response['customerCart']['items'][0]['quantity'],
@@ -74,8 +74,8 @@ public function testGetNewCustomerCart()
7474
$headers = ['Authorization' => 'Bearer ' . $customerToken];
7575
$response = $this->graphQlQuery($customerCartQuery, [], '', $headers);
7676
$this->assertArrayHasKey('customerCart', $response);
77-
$this->assertArrayHasKey('cart_id', $response['customerCart']);
78-
$this->assertNotNull($response['customerCart']['cart_id']);
77+
$this->assertArrayHasKey('id', $response['customerCart']);
78+
$this->assertNotNull($response['customerCart']['id']);
7979
$this->assertEmpty($response['customerCart']['items']);
8080
$this->assertEquals(0, $response['customerCart']['total_quantity']);
8181
}
@@ -104,8 +104,8 @@ public function testGetCustomerCartAfterTokenRevoked()
104104
$customerCartQuery = $this->getCustomerCartQuery();
105105
$response = $this->graphQlMutation($customerCartQuery, [], '', $headers);
106106
$this->assertArrayHasKey('customerCart', $response);
107-
$this->assertArrayHasKey('cart_id', $response['customerCart']);
108-
$this->assertNotNull($response['customerCart']['cart_id']);
107+
$this->assertArrayHasKey('id', $response['customerCart']);
108+
$this->assertNotNull($response['customerCart']['id']);
109109
$this->revokeCustomerToken();
110110
$customerCartQuery = $this->getCustomerCartQuery();
111111
$this->expectExceptionMessage(
@@ -126,12 +126,12 @@ public function testRequestCustomerCartTwice()
126126
$customerCartQuery = $this->getCustomerCartQuery();
127127
$response = $this->graphQlMutation($customerCartQuery, [], '', $headers);
128128
$this->assertArrayHasKey('customerCart', $response);
129-
$this->assertArrayHasKey('cart_id', $response['customerCart']);
130-
$this->assertNotNull($response['customerCart']['cart_id']);
131-
$cartId = $response['customerCart']['cart_id'];
129+
$this->assertArrayHasKey('id', $response['customerCart']);
130+
$this->assertNotNull($response['customerCart']['id']);
131+
$cartId = $response['customerCart']['id'];
132132
$customerCartQuery = $this->getCustomerCartQuery();
133133
$response2 = $this->graphQlQuery($customerCartQuery, [], '', $headers);
134-
$this->assertEquals($cartId, $response2['customerCart']['cart_id']);
134+
$this->assertEquals($cartId, $response2['customerCart']['id']);
135135
}
136136

137137
/**
@@ -148,7 +148,7 @@ public function testGetInactiveCustomerCart()
148148
$customerCartQuery = $this->getCustomerCartQuery();
149149
$response = $this->graphQlQuery($customerCartQuery, [], '', $this->getHeaderMap());
150150
$this->assertArrayHasKey('customerCart', $response);
151-
$this->assertNotEmpty($response['customerCart']['cart_id']);
151+
$this->assertNotEmpty($response['customerCart']['id']);
152152
$this->assertEmpty($response['customerCart']['items']);
153153
$this->assertEmpty($response['customerCart']['total_quantity']);
154154
}
@@ -166,7 +166,7 @@ public function testGetCustomerCartSecondStore()
166166
$headerMap = $this->getHeaderMap();
167167
$headerMap['Store'] = 'fixture_second_store';
168168
$responseSecondStore = $this->graphQlQuery($customerCartQuery, [], '', $headerMap);
169-
$this->assertEquals($maskedQuoteIdSecondStore, $responseSecondStore['customerCart']['cart_id']);
169+
$this->assertEquals($maskedQuoteIdSecondStore, $responseSecondStore['customerCart']['id']);
170170
}
171171

172172
/**
@@ -223,8 +223,8 @@ private function getCustomerCartQuery(): string
223223
return <<<QUERY
224224
{
225225
customerCart {
226-
total_quantity
227-
cart_id
226+
total_quantity
227+
id
228228
items {
229229
id
230230
quantity

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public function testAddSimpleProductToCart()
5050
self::assertEquals($quantity, $response['addSimpleProductsToCart']['cart']['items'][0]['quantity']);
5151
self::assertEquals($sku, $response['addSimpleProductsToCart']['cart']['items'][0]['product']['sku']);
5252
self::assertArrayHasKey('prices', $response['addSimpleProductsToCart']['cart']['items'][0]);
53-
self::assertArrayHasKey('cart_id', $response['addSimpleProductsToCart']['cart']);
54-
self::assertEquals($maskedQuoteId, $response['addSimpleProductsToCart']['cart']['cart_id']);
53+
self::assertArrayHasKey('id', $response['addSimpleProductsToCart']['cart']);
54+
self::assertEquals($maskedQuoteId, $response['addSimpleProductsToCart']['cart']['id']);
5555

5656
self::assertArrayHasKey('price', $response['addSimpleProductsToCart']['cart']['items'][0]['prices']);
5757
$price = $response['addSimpleProductsToCart']['cart']['items'][0]['prices']['price'];
@@ -256,7 +256,7 @@ private function getQuery(string $maskedQuoteId, string $sku, float $quantity):
256256
}
257257
) {
258258
cart {
259-
cart_id
259+
id
260260
items {
261261
quantity
262262
product {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ public function testAddVirtualProductToCart()
4545
$response = $this->graphQlMutation($query);
4646

4747
self::assertArrayHasKey('cart', $response['addVirtualProductsToCart']);
48-
self::assertArrayHasKey('cart_id', $response['addVirtualProductsToCart']['cart']);
49-
self::assertEquals($maskedQuoteId, $response['addVirtualProductsToCart']['cart']['cart_id']);
48+
self::assertArrayHasKey('id', $response['addVirtualProductsToCart']['cart']);
49+
self::assertEquals($maskedQuoteId, $response['addVirtualProductsToCart']['cart']['id']);
5050
self::assertEquals($quantity, $response['addVirtualProductsToCart']['cart']['items'][0]['quantity']);
5151
self::assertEquals($sku, $response['addVirtualProductsToCart']['cart']['items'][0]['product']['sku']);
5252
}
@@ -229,7 +229,7 @@ private function getQuery(string $maskedQuoteId, string $sku, float $quantity):
229229
}
230230
) {
231231
cart {
232-
cart_id
232+
id
233233
items {
234234
quantity
235235
product {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ public function testApplyCouponToCart()
4141
$response = $this->graphQlMutation($query);
4242

4343
self::assertArrayHasKey('applyCouponToCart', $response);
44-
self::assertArrayHasKey('cart_id', $response['applyCouponToCart']['cart']);
45-
self::assertEquals($maskedQuoteId, $response['applyCouponToCart']['cart']['cart_id']);
44+
self::assertArrayHasKey('id', $response['applyCouponToCart']['cart']);
45+
self::assertEquals($maskedQuoteId, $response['applyCouponToCart']['cart']['id']);
4646
self::assertEquals($couponCode, $response['applyCouponToCart']['cart']['applied_coupon']['code']);
4747
}
4848

@@ -204,7 +204,7 @@ private function getQuery(string $maskedQuoteId, string $couponCode): string
204204
mutation {
205205
applyCouponToCart(input: {cart_id: "$maskedQuoteId", coupon_code: "$couponCode"}) {
206206
cart {
207-
cart_id
207+
id
208208
applied_coupon {
209209
code
210210
}

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ public function testGetCart()
4444

4545
self::assertArrayHasKey('cart', $response);
4646
self::assertArrayHasKey('items', $response['cart']);
47-
self::assertArrayHasKey('cart_id', $response['cart']);
48-
self::assertEquals($maskedQuoteId, $response['cart']['cart_id']);
47+
self::assertArrayHasKey('id', $response['cart']);
48+
self::assertEquals($maskedQuoteId, $response['cart']['id']);
4949
self::assertCount(2, $response['cart']['items']);
5050

5151
self::assertNotEmpty($response['cart']['items'][0]['id']);
@@ -186,7 +186,7 @@ private function getQuery(string $maskedQuoteId): string
186186
return <<<QUERY
187187
{
188188
cart(cart_id: "{$maskedQuoteId}") {
189-
cart_id
189+
id
190190
items {
191191
id
192192
quantity

0 commit comments

Comments
 (0)