@@ -126,7 +126,7 @@ public function testGuestCannotGetWishlist()
126
126
127
127
/**
128
128
* Add product to wishlist with quantity 0
129
- *
129
+ *
130
130
* @magentoConfigFixture default_store wishlist/general/active 1
131
131
* @magentoApiDataFixture Magento/Customer/_files/customer.php
132
132
* @magentoApiDataFixture Magento/Catalog/_files/product_simple_duplicated.php
@@ -196,6 +196,78 @@ public function testAddProductToWishlistWithZeroQty()
196
196
);
197
197
}
198
198
199
+ /**
200
+ * Add disabled product to wishlist
201
+ *
202
+ * @magentoConfigFixture default_store wishlist/general/active 1
203
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
204
+ * @magentoApiDataFixture Magento/Catalog/_files/simple_product_disabled.php
205
+ */
206
+ public function testAddProductToWishlistWithDisabledProduct ()
207
+ {
208
+ $ customerWishlistQuery =
209
+ <<<QUERY
210
+ {
211
+ customer {
212
+ wishlist {
213
+ id
214
+ }
215
+ }
216
+ }
217
+ QUERY ;
218
+
219
+ $ response = $ this ->graphQlQuery (
220
+ $ customerWishlistQuery ,
221
+ [],
222
+ '' ,
223
+ $ this ->getCustomerAuthHeaders ('customer@example.com ' , 'password ' )
224
+ );
225
+ $ qty = 2 ;
226
+ $ sku = 'product_disabled ' ;
227
+ $ wishlistId = $ response ['customer ' ]['wishlist ' ]['id ' ];
228
+ $ addProductToWishlistQuery =
229
+ <<<QUERY
230
+ mutation{
231
+ addProductsToWishlist(
232
+ wishlistId: {$ wishlistId }
233
+ wishlistItems:[
234
+ {
235
+ sku:" {$ sku }"
236
+ quantity: {$ qty }
237
+ }
238
+ ])
239
+ {
240
+ wishlist{
241
+ id
242
+ items_count
243
+ items{product{name sku} description qty}
244
+ }
245
+ user_errors{code message}
246
+ }
247
+ }
248
+
249
+ QUERY ;
250
+ $ addToWishlistResponse = $ this ->graphQlMutation (
251
+ $ addProductToWishlistQuery ,
252
+ [],
253
+ '' ,
254
+ $ this ->getCustomerAuthHeaders ('customer@example.com ' , 'password ' )
255
+ );
256
+ $ this ->assertArrayHasKey ('user_errors ' , $ addToWishlistResponse ['addProductsToWishlist ' ]);
257
+ $ this ->assertCount (1 , $ addToWishlistResponse ['addProductsToWishlist ' ]['user_errors ' ]);
258
+ $ this ->assertEmpty ($ addToWishlistResponse ['addProductsToWishlist ' ]['wishlist ' ]['items ' ]);
259
+ $ this ->assertEquals (
260
+ 0 ,
261
+ $ addToWishlistResponse ['addProductsToWishlist ' ]['wishlist ' ]['items_count ' ],
262
+ 'Count is greater than 0 '
263
+ );
264
+ $ message = 'The product is disabled ' ;
265
+ $ this ->assertEquals (
266
+ $ message ,
267
+ $ addToWishlistResponse ['addProductsToWishlist ' ]['user_errors ' ][0 ]['message ' ]
268
+ );
269
+ }
270
+
199
271
/**
200
272
* @magentoConfigFixture default_store wishlist/general/active 0
201
273
* @magentoApiDataFixture Magento/Customer/_files/customer.php
0 commit comments