File tree Expand file tree Collapse file tree 2 files changed +35
-2
lines changed
dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest
lib/internal/Magento/Framework/GraphQl/Exception Expand file tree Collapse file tree 2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change 8
8
namespace Magento \GraphQl \Quote \Guest ;
9
9
10
10
use Magento \Catalog \Test \Fixture \Product as ProductFixture ;
11
+ use Magento \Framework \GraphQl \Exception \GraphQlNoSuchEntityException ;
11
12
use Magento \GraphQl \Quote \GetMaskedQuoteIdByReservedOrderId ;
12
13
use Magento \Quote \Model \QuoteIdToMaskedQuoteIdInterface ;
13
14
use Magento \Quote \Test \Fixture \AddProductToCart as AddProductToCartFixture ;
@@ -315,6 +316,25 @@ public function testGetSelectedShippingMethodFromCustomerCart()
315
316
$ this ->graphQlQuery ($ query );
316
317
}
317
318
319
+ public function testGetCartTotalsWithNonExistingCartId (): void
320
+ {
321
+ $ maskedQuoteId = 'NonExistingQuoteId ' ;
322
+ $ query = $ this ->getQuery ($ maskedQuoteId );
323
+ try {
324
+ $ this ->graphQlQuery ($ query );
325
+ $ this ->fail ('Expected exception was not raised ' );
326
+ } catch (\Exception $ exception ) {
327
+ $ response = $ exception ->getResponseData ();
328
+ $ this ->assertArrayHasKey ('errors ' , $ response );
329
+ $ actualError = reset ($ response ['errors ' ]);
330
+ $ this ->assertEquals ("Could not find a cart with ID \"$ maskedQuoteId \"" , $ actualError ['message ' ]);
331
+ $ this ->assertEquals (
332
+ GraphQlNoSuchEntityException::EXCEPTION_CATEGORY ,
333
+ $ actualError ['extensions ' ]['category ' ]
334
+ );
335
+ }
336
+ }
337
+
318
338
/**
319
339
* Generates GraphQl query for retrieving cart totals
320
340
*
Original file line number Diff line number Diff line change 7
7
8
8
namespace Magento \Framework \GraphQl \Exception ;
9
9
10
+ use GraphQL \Error \ClientAware ;
11
+ use GraphQL \Error \ProvidesExtensions ;
10
12
use Magento \Framework \Exception \NoSuchEntityException ;
11
13
use Magento \Framework \Phrase ;
12
14
15
17
*
16
18
* @api
17
19
*/
18
- class GraphQlNoSuchEntityException extends NoSuchEntityException implements \ GraphQL \ Error \ ClientAware
20
+ class GraphQlNoSuchEntityException extends NoSuchEntityException implements ClientAware, ProvidesExtensions
19
21
{
20
- const EXCEPTION_CATEGORY = 'graphql-no-such-entity ' ;
22
+ public const EXCEPTION_CATEGORY = 'graphql-no-such-entity ' ;
21
23
22
24
/**
23
25
* @var boolean
@@ -53,4 +55,15 @@ public function getCategory(): string
53
55
{
54
56
return self ::EXCEPTION_CATEGORY ;
55
57
}
58
+
59
+ /**
60
+ * Get error category
61
+ *
62
+ * @return array
63
+ */
64
+ public function getExtensions (): array
65
+ {
66
+ $ exceptionCategory ['category ' ] = $ this ->getCategory ();
67
+ return $ exceptionCategory ;
68
+ }
56
69
}
You can’t perform that action at this time.
0 commit comments