Skip to content

Commit 990a373

Browse files
committed
429 - Test coverage: nonExistentCart
1. Add none existing cart test - Could not find a cart with ID "non_existent_masked_id"
1 parent 75cf826 commit 990a373

File tree

4 files changed

+134
-0
lines changed

4 files changed

+134
-0
lines changed

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,40 @@ public function testSetBillingAddressIfCustomerIsNotOwnerOfAddress()
403403
$this->graphQlQuery($query, [], '', $this->getHeaderMap('[email protected]'));
404404
}
405405

406+
/**
407+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
408+
* @expectedException \Exception
409+
* @expectedExceptionMessage Could not find a cart with ID "non_existent_masked_id"
410+
*/
411+
public function testSetBillingAddressOnNonExistentCart()
412+
{
413+
$maskedQuoteId = 'non_existent_masked_id';
414+
$query = $this->getCartQuery($maskedQuoteId);
415+
$this->graphQlQuery($query, [], '', $this->getHeaderMap());
416+
}
417+
418+
/**
419+
* @param string $maskedQuoteId
420+
* @return string
421+
*/
422+
private function getCartQuery(
423+
string $maskedQuoteId
424+
) : string {
425+
return <<<QUERY
426+
{
427+
cart(cart_id: "$maskedQuoteId") {
428+
items {
429+
id
430+
qty
431+
product {
432+
sku
433+
}
434+
}
435+
}
436+
}
437+
QUERY;
438+
}
439+
406440
/**
407441
* Verify the all the whitelisted fields for a New Address Object
408442
*

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,40 @@ public function testSetPaymentMethodToAnotherCustomerCart()
151151
$this->graphQlQuery($query, [], '', $this->getHeaderMap('[email protected]'));
152152
}
153153

154+
/**
155+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
156+
* @expectedException \Exception
157+
* @expectedExceptionMessage Could not find a cart with ID "non_existent_masked_id"
158+
*/
159+
public function testPaymentMethodOnNonExistentCart()
160+
{
161+
$maskedQuoteId = 'non_existent_masked_id';
162+
$query = $this->getCartQuery($maskedQuoteId);
163+
$this->graphQlQuery($query, [], '', $this->getHeaderMap());
164+
}
165+
166+
/**
167+
* @param string $maskedQuoteId
168+
* @return string
169+
*/
170+
private function getCartQuery(
171+
string $maskedQuoteId
172+
) : string {
173+
return <<<QUERY
174+
{
175+
cart(cart_id: "$maskedQuoteId") {
176+
items {
177+
id
178+
qty
179+
product {
180+
sku
181+
}
182+
}
183+
}
184+
}
185+
QUERY;
186+
}
187+
154188
/**
155189
* @param string $maskedQuoteId
156190
* @param string $methodCode

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,39 @@ public function testSetBillingAddressFromAddressBook()
244244
$this->graphQlQuery($query);
245245
}
246246

247+
/**
248+
* @expectedException \Exception
249+
* @expectedExceptionMessage Could not find a cart with ID "non_existent_masked_id"
250+
*/
251+
public function testSetBillingAddressOnNonExistentCart()
252+
{
253+
$maskedQuoteId = 'non_existent_masked_id';
254+
$query = $this->getCartQuery($maskedQuoteId);
255+
$this->graphQlQuery($query);
256+
}
257+
258+
/**
259+
* @param string $maskedQuoteId
260+
* @return string
261+
*/
262+
private function getCartQuery(
263+
string $maskedQuoteId
264+
) : string {
265+
return <<<QUERY
266+
{
267+
cart(cart_id: "$maskedQuoteId") {
268+
items {
269+
id
270+
qty
271+
product {
272+
sku
273+
}
274+
}
275+
}
276+
}
277+
QUERY;
278+
}
279+
247280
/**
248281
* Verify the all the whitelisted fields for a New Address Object
249282
*

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,17 @@ public function testSetPaymentMethodToCustomerCart()
126126
$this->graphQlQuery($query);
127127
}
128128

129+
/**
130+
* @expectedException \Exception
131+
* @expectedExceptionMessage Could not find a cart with ID "non_existent_masked_id"
132+
*/
133+
public function testSetPaymentOnNonExistentCart()
134+
{
135+
$maskedQuoteId = 'non_existent_masked_id';
136+
$query = $this->getCartQuery($maskedQuoteId);
137+
$this->graphQlQuery($query);
138+
}
139+
129140
/**
130141
* @param string $maskedQuoteId
131142
* @param string $methodCode
@@ -155,6 +166,28 @@ private function prepareMutationQuery(
155166
QUERY;
156167
}
157168

169+
/**
170+
* @param string $maskedQuoteId
171+
* @return string
172+
*/
173+
private function getCartQuery(
174+
string $maskedQuoteId
175+
) : string {
176+
return <<<QUERY
177+
{
178+
cart(cart_id: "$maskedQuoteId") {
179+
items {
180+
id
181+
qty
182+
product {
183+
sku
184+
}
185+
}
186+
}
187+
}
188+
QUERY;
189+
}
190+
158191
/**
159192
* @param string $reversedQuoteId
160193
* @param int $customerId

0 commit comments

Comments
 (0)