File tree Expand file tree Collapse file tree 2 files changed +21
-1
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 +21
-1
lines changed Original file line number Diff line number Diff line change 88namespace Magento \GraphQl \Quote \Guest ;
99
1010use Magento \Catalog \Test \Fixture \Product as ProductFixture ;
11+ use Magento \Framework \GraphQl \Exception \GraphQlNoSuchEntityException ;
1112use Magento \GraphQl \Quote \GetMaskedQuoteIdByReservedOrderId ;
1213use Magento \Quote \Model \QuoteIdToMaskedQuoteIdInterface ;
1314use Magento \Quote \Test \Fixture \AddProductToCart as AddProductToCartFixture ;
@@ -315,6 +316,25 @@ public function testGetSelectedShippingMethodFromCustomerCart()
315316 $ this ->graphQlQuery ($ query );
316317 }
317318
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+
318338 /**
319339 * Generates GraphQl query for retrieving cart totals
320340 *
Original file line number Diff line number Diff line change 1919 */
2020class GraphQlNoSuchEntityException extends NoSuchEntityException implements ClientAware, ProvidesExtensions
2121{
22- const EXCEPTION_CATEGORY = 'graphql-no-such-entity ' ;
22+ public const EXCEPTION_CATEGORY = 'graphql-no-such-entity ' ;
2323
2424 /**
2525 * @var boolean
You can’t perform that action at this time.
0 commit comments