Skip to content

Commit cad2de4

Browse files
author
Prabhu Ram
committed
Merge branch 'MC-36897' of github.com:magento-honey-badgers/magento2ce into MC-36897
2 parents 912e9e1 + 048a489 commit cad2de4

File tree

1 file changed

+73
-1
lines changed

1 file changed

+73
-1
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Wishlist/CustomerWishlistTest.php

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function testGuestCannotGetWishlist()
126126

127127
/**
128128
* Add product to wishlist with quantity 0
129-
*
129+
*
130130
* @magentoConfigFixture default_store wishlist/general/active 1
131131
* @magentoApiDataFixture Magento/Customer/_files/customer.php
132132
* @magentoApiDataFixture Magento/Catalog/_files/product_simple_duplicated.php
@@ -196,6 +196,78 @@ public function testAddProductToWishlistWithZeroQty()
196196
);
197197
}
198198

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+
199271
/**
200272
* @magentoConfigFixture default_store wishlist/general/active 0
201273
* @magentoApiDataFixture Magento/Customer/_files/customer.php

0 commit comments

Comments
 (0)