Skip to content

Commit 26f072a

Browse files
ENGCOM-5766: graphQl-810: test add non existent configurable product #867
- Merge Pull Request magento/graphql-ce#867 from magento/graphql-ce:GraphQL-810-testAddNonExistentConfigurableProduct - Merged commits: 1. 25e1590 2. bc832bb
2 parents db43c11 + bc832bb commit 26f072a

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/ConfigurableProduct/AddConfigurableProductToCartTest.php

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,56 @@ public function testAddProductIfQuantityIsNotAvailable()
164164
$this->graphQlMutation($query);
165165
}
166166

167+
/**
168+
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable_sku.php
169+
* @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
170+
* @expectedException \Exception
171+
* @expectedExceptionMessage Could not find a product with SKU "configurable_no_exist"
172+
*/
173+
public function testAddNonExistentConfigurableProductParentToCart()
174+
{
175+
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_order_1');
176+
$parentSku = 'configurable_no_exist';
177+
$sku = 'simple_20';
178+
179+
$query = $this->getQuery(
180+
$maskedQuoteId,
181+
$parentSku,
182+
$sku,
183+
2000
184+
);
185+
186+
$this->graphQlMutation($query);
187+
}
188+
189+
/**
190+
* @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable_sku.php
191+
* @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
192+
*/
193+
public function testAddNonExistentConfigurableProductVariationToCart()
194+
{
195+
$searchResponse = $this->graphQlQuery($this->getFetchProductQuery('configurable'));
196+
$product = current($searchResponse['products']['items']);
197+
198+
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_order_1');
199+
$parentSku = $product['sku'];
200+
$sku = 'simple_no_exist';
201+
202+
$query = $this->getQuery(
203+
$maskedQuoteId,
204+
$parentSku,
205+
$sku,
206+
2000
207+
);
208+
209+
$this->expectException(\Exception::class);
210+
$this->expectExceptionMessage(
211+
'Could not add the product with SKU configurable to the shopping cart: Could not find specified product.'
212+
);
213+
214+
$this->graphQlMutation($query);
215+
}
216+
167217
/**
168218
* @param string $maskedQuoteId
169219
* @param string $parentSku

0 commit comments

Comments
 (0)