@@ -80,24 +80,48 @@ public function testAddSimpleProductToCart()
80
80
self ::assertEquals ('USD ' , $ rowTotalIncludingTax ['currency ' ]);
81
81
}
82
82
83
+ /**
84
+ * Add disabled product to cart
85
+ *
86
+ * @magentoApiDataFixture Magento/Catalog/_files/multiple_products.php
87
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
88
+ * @return void
89
+ */
90
+ public function testAddDisabledProductToCart (): void
91
+ {
92
+ $ sku = 'simple3 ' ;
93
+ $ quantity = 2 ;
94
+
95
+ $ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ('test_quote ' );
96
+ $ query = $ this ->getQuery ($ maskedQuoteId , $ sku , $ quantity );
97
+
98
+ $ this ->expectException (ResponseContainsErrorsException::class);
99
+ $ this ->expectExceptionMessage (
100
+ 'Could not add the product with SKU ' . $ sku . ' to the shopping cart: ' .
101
+ 'Product that you are trying to add is not available. '
102
+ );
103
+
104
+ $ this ->graphQlMutation ($ query );
105
+ }
106
+
83
107
/**
84
108
* Add out of stock product to cart
85
109
*
86
- * @@ magentoApiDataFixture Magento/Catalog/_files/multiple_products .php
110
+ * @magentoApiDataFixture Magento/Catalog/_files/product_virtual_out_of_stock .php
87
111
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
88
112
* @return void
89
113
*/
90
- public function testAddProductToCartWithError (): void
114
+ public function testAddOutOfStockProductToCart (): void
91
115
{
92
- $ disabledProductSku = 'simple3 ' ;
116
+ $ sku = 'virtual-product-out ' ;
93
117
$ quantity = 2 ;
94
118
95
119
$ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ('test_quote ' );
96
- $ query = $ this ->getQuery ($ maskedQuoteId , $ disabledProductSku , $ quantity );
120
+ $ query = $ this ->getQuery ($ maskedQuoteId , $ sku , $ quantity );
97
121
98
122
$ this ->expectException (ResponseContainsErrorsException::class);
99
123
$ this ->expectExceptionMessage (
100
- 'Could not add the product with SKU simple3 to the shopping cart: ' .
124
+ 'Could not add the product with SKU ' . $ sku . ' to the shopping cart: ' .
101
125
'Product that you are trying to add is not available. '
102
126
);
103
127
0 commit comments