@@ -62,6 +62,41 @@ public function testGetCart()
62
62
self ::assertEquals ('virtual-product ' , $ response ['cart ' ]['items ' ][1 ]['product ' ]['sku ' ]);
63
63
}
64
64
65
+ /**
66
+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
67
+ * @magentoApiDataFixture Magento/Catalog/_files/product_virtual.php
68
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
69
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
70
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_virtual_product.php
71
+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/set_simple_product_out_of_stock.php
72
+ */
73
+ public function testCartErrorWithOutOfStockItem ()
74
+ {
75
+ $ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ('test_quote ' );
76
+ $ query = $ this ->getQuery ($ maskedQuoteId );
77
+
78
+ $ response = $ this ->graphQlQuery ($ query );
79
+
80
+ self ::assertArrayHasKey ('cart ' , $ response );
81
+ self ::assertArrayHasKey ('items ' , $ response ['cart ' ]);
82
+ self ::assertArrayHasKey ('errors ' , $ response ['cart ' ]['items ' ][0 ]);
83
+ self ::assertEquals (
84
+ 'There are no source items with the in stock status ' ,
85
+ $ response ['cart ' ]['items ' ][0 ]['errors ' ][0 ]['message ' ]
86
+ );
87
+ self ::assertArrayHasKey ('id ' , $ response ['cart ' ]);
88
+ self ::assertEquals ($ maskedQuoteId , $ response ['cart ' ]['id ' ]);
89
+ self ::assertCount (2 , $ response ['cart ' ]['items ' ]);
90
+
91
+ self ::assertNotEmpty ($ response ['cart ' ]['items ' ][0 ]['id ' ]);
92
+ self ::assertEquals (2 , $ response ['cart ' ]['items ' ][0 ]['quantity ' ]);
93
+ self ::assertEquals ('simple_product ' , $ response ['cart ' ]['items ' ][0 ]['product ' ]['sku ' ]);
94
+
95
+ self ::assertNotEmpty ($ response ['cart ' ]['items ' ][1 ]['id ' ]);
96
+ self ::assertEquals (2 , $ response ['cart ' ]['items ' ][1 ]['quantity ' ]);
97
+ self ::assertEquals ('virtual-product ' , $ response ['cart ' ]['items ' ][1 ]['product ' ]['sku ' ]);
98
+ }
99
+
65
100
/**
66
101
* _security
67
102
* @magentoApiDataFixture Magento/Customer/_files/customer.php
@@ -279,6 +314,10 @@ private function getQuery(string $maskedQuoteId): string
279
314
currency
280
315
}
281
316
}
317
+ errors {
318
+ code
319
+ message
320
+ }
282
321
}
283
322
}
284
323
}
0 commit comments