Skip to content

Commit

Permalink
#481 Added testRemoveCouponFromCartWithNoCouponApplied case
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Glushko committed Mar 17, 2019
1 parent 9000000 commit a8b4cc9
Showing 1 changed file with 30 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function testRemoveCouponFromCart()
{
$couponCode = '2?ds5!2d';

/* Apply coupon to the customer quote */
/* Assign the quote to the customer */
$this->quoteResource->load(
$this->quote,
'test_order_with_simple_product_without_address',
Expand All @@ -85,6 +85,7 @@ public function testRemoveCouponFromCart()
$this->quote->setCustomerId(1);
$this->quoteResource->save($this->quote);

/* Apply coupon to the customer quote */
$queryHeaders = $this->prepareAuthorizationHeaders('customer@example.com', 'password');
$query = $this->prepareAddCouponRequestQuery($maskedQuoteId, $couponCode);
$this->graphQlQuery($query, [], '', $queryHeaders);
Expand All @@ -106,7 +107,7 @@ public function testRemoveCouponFromCartTwice()
{
$couponCode = '2?ds5!2d';

/* Apply coupon to the customer quote */
/* Assign the quote to the customer */
$this->quoteResource->load(
$this->quote,
'test_order_with_simple_product_without_address',
Expand All @@ -117,6 +118,7 @@ public function testRemoveCouponFromCartTwice()
$this->quote->setCustomerId(1);
$this->quoteResource->save($this->quote);

/* Apply coupon to the customer quote */
$queryHeaders = $this->prepareAuthorizationHeaders('customer@example.com', 'password');
$query = $this->prepareAddCouponRequestQuery($maskedQuoteId, $couponCode);
$this->graphQlQuery($query, [], '', $queryHeaders);
Expand All @@ -136,6 +138,32 @@ public function testRemoveCouponFromCartTwice()
self::assertNull($response['removeCouponFromCart']['cart']['applied_coupon']['code']);
}

/**
* @magentoApiDataFixture Magento/Customer/_files/customer.php
* @magentoApiDataFixture Magento/Checkout/_files/quote_with_simple_product_saved.php
*/
public function testRemoveCouponFromCartWithNoCouponApplied()
{
/* Assign the quote to the customer */
$this->quoteResource->load(
$this->quote,
'test_order_with_simple_product_without_address',
'reserved_order_id'
);
$maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$this->quote->getId());

$this->quote->setCustomerId(1);
$this->quoteResource->save($this->quote);

/* Remove coupon from the quote */
$query = $this->prepareRemoveCouponRequestQuery($maskedQuoteId);
$queryHeaders = $this->prepareAuthorizationHeaders('customer@example.com', 'password');
$response = $this->graphQlQuery($query, [], '', $queryHeaders);

self::assertArrayHasKey('removeCouponFromCart', $response);
self::assertNull($response['removeCouponFromCart']['cart']['applied_coupon']['code']);
}

/**
* @magentoApiDataFixture Magento/Customer/_files/customer.php
* @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
Expand Down

0 comments on commit a8b4cc9

Please sign in to comment.