Skip to content

Commit

Permalink
ENGCOM-4164: [Checkout] Covering the successfully adding a valid coup…
Browse files Browse the repository at this point in the history
…on to cart by an integra… #21028
  • Loading branch information
sidolov authored Feb 11, 2019
2 parents 0ede3c0 + e0604f3 commit 7992523
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,35 @@ public function testExecute()
\Magento\Framework\Message\MessageInterface::TYPE_ERROR
);
}

/**
* Testing by adding a valid coupon to cart
*
* @magentoDataFixture Magento/Checkout/_files/quote_with_virtual_product_and_address.php
* @magentoDataFixture Magento/Usps/Fixtures/cart_rule_coupon_free_shipping.php
* @return void
*/
public function testAddingValidCoupon(): void
{
/** @var $session \Magento\Checkout\Model\Session */
$session = $this->_objectManager->create(\Magento\Checkout\Model\Session::class);
$quote = $session->getQuote();
$quote->setData('trigger_recollect', 1)->setTotalsCollectedFlag(true);

$couponCode = 'IMPHBR852R61';
$inputData = [
'remove' => 0,
'coupon_code' => $couponCode
];
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue($inputData);
$this->dispatch(
'checkout/cart/couponPost/'
);

$this->assertSessionMessages(
$this->equalTo(['You used coupon code "' . $couponCode . '".']),
\Magento\Framework\Message\MessageInterface::TYPE_SUCCESS
);
}
}

0 comments on commit 7992523

Please sign in to comment.