Skip to content

Commit b565d02

Browse files
authored
ENGCOM-4609: Resolve random fails on Bamboo with \Magento\GraphQl\Quote\CouponTest:testApplyCouponToCartWithNoItems #503
2 parents b9aa7cc + 90b1389 commit b565d02

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

app/code/Magento/QuoteGraphQl/Model/Resolver/ApplyCouponToCart.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,11 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
7575
try {
7676
$this->couponManagement->set($cartId, $couponCode);
7777
} catch (NoSuchEntityException $e) {
78-
throw new GraphQlNoSuchEntityException(__($e->getMessage()), $e);
78+
$message = $e->getMessage();
79+
if (preg_match('/The "\d+" Cart doesn\'t contain products/', $message)) {
80+
$message = 'Cart does not contain products.';
81+
}
82+
throw new GraphQlNoSuchEntityException(__($message), $e);
7983
} catch (CouldNotSaveException $e) {
8084
throw new LocalizedException(__($e->getMessage()), $e);
8185
}

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/CouponTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,17 @@ public function testApplyCouponTwice()
8989
/**
9090
* @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
9191
* @magentoApiDataFixture Magento/SalesRule/_files/coupon_code_with_wildcard.php
92+
* @expectedException \Exception
93+
* @expectedExceptionMessage Cart does not contain products.
9294
*/
9395
public function testApplyCouponToCartWithNoItems()
9496
{
95-
$this->markTestIncomplete('https://github.com/magento/graphql-ce/issues/191');
9697
$couponCode = '2?ds5!2d';
9798

9899
$this->quoteResource->load($this->quote, 'test_order_1', 'reserved_order_id');
99100
$maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$this->quote->getId());
100101
$query = $this->prepareAddCouponRequestQuery($maskedQuoteId, $couponCode);
101102

102-
self::expectExceptionMessageRegExp('/Cart doesn\'t contain products/');
103103
$this->graphQlQuery($query);
104104
}
105105

0 commit comments

Comments
 (0)