@@ -206,6 +206,7 @@ public function testAddDisabledProductToCart(): void
206206 /**
207207 * Add out of stock product to cart
208208 *
209+ * @magentoConfigFixture cataloginventory/options/enable_inventory_check 1
209210 * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
210211 * @magentoApiDataFixture Magento/Catalog/_files/multiple_products.php
211212 * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
@@ -230,6 +231,90 @@ public function testAddOutOfStockProductToCart(): void
230231 $ this ->graphQlMutation ($ query );
231232 }
232233
234+ /**
235+ * Add out of stock product to cart with disabled quote item check
236+ *
237+ * @magentoConfigFixture cataloginventory/options/enable_inventory_check 0
238+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
239+ * @magentoApiDataFixture Magento/Catalog/_files/multiple_products.php
240+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
241+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
242+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/set_simple_product_out_of_stock.php
243+ * @return void
244+ * @throws NoSuchEntityException
245+ */
246+ public function testAddOutOfStockProductToCartWithDisabledInventoryCheck (): void
247+ {
248+ $ sku = 'simple1 ' ;
249+ $ quantity = 1 ;
250+
251+ $ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ('test_quote ' );
252+ $ query = $ this ->getQuery ($ maskedQuoteId , $ sku , $ quantity );
253+ $ response = $ this ->graphQlMutation ($ query );
254+
255+ $ this ->assertArrayHasKey ('cart ' , $ response ['addSimpleProductsToCart ' ]);
256+ $ this ->assertCount (2 , $ response ['addSimpleProductsToCart ' ]['cart ' ]['items ' ]);
257+ $ cartItems = $ response ['addSimpleProductsToCart ' ]['cart ' ]['items ' ];
258+ $ this ->assertEquals (2 , $ cartItems [0 ]['quantity ' ]);
259+ $ this ->assertEquals (1 , $ cartItems [1 ]['quantity ' ]);
260+ }
261+
262+ /**
263+ * Add out of stock simple product to cart with disabled quote item check
264+ *
265+ * @magentoConfigFixture cataloginventory/options/enable_inventory_check 1
266+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
267+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
268+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
269+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/set_simple_product_out_of_stock.php
270+ * @return void
271+ * @throws NoSuchEntityException
272+ */
273+ public function testAddOutOfStockSimpleProductToCart (): void
274+ {
275+ $ sku = 'simple_product ' ;
276+ $ quantity = 1 ;
277+
278+ $ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ('test_quote ' );
279+ $ query = $ this ->getQuery ($ maskedQuoteId , $ sku , $ quantity );
280+
281+ $ this ->expectException (ResponseContainsErrorsException::class);
282+ $ this ->expectExceptionMessage (
283+ 'Could not add the product with SKU ' . $ sku . ' to the shopping cart: ' .
284+ 'Product that you are trying to add is not available. '
285+ );
286+
287+ $ this ->graphQlMutation ($ query );
288+ }
289+
290+ /**
291+ * Add out of stock simple product to cart with disabled quote item check
292+ *
293+ * @magentoConfigFixture cataloginventory/options/enable_inventory_check 0
294+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
295+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
296+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
297+ * @magentoApiDataFixture Magento/GraphQl/Catalog/_files/set_simple_product_out_of_stock.php
298+ * @return void
299+ * @throws NoSuchEntityException
300+ */
301+ public function testAddOutOfStockSimpleProductToCartWithDisabledInventoryCheck (): void
302+ {
303+ $ sku = 'simple_product ' ;
304+ $ quantity = 1 ;
305+
306+ $ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ('test_quote ' );
307+ $ query = $ this ->getQuery ($ maskedQuoteId , $ sku , $ quantity );
308+
309+ $ this ->expectException (ResponseContainsErrorsException::class);
310+ $ this ->expectExceptionMessage (
311+ 'Could not add the product with SKU ' . $ sku . ' to the shopping cart: ' .
312+ 'Product that you are trying to add is not available. '
313+ );
314+
315+ $ this ->graphQlMutation ($ query );
316+ }
317+
233318 /**
234319 */
235320 public function testAddSimpleProductToCartIfCartIdIsEmpty ()
0 commit comments