Skip to content

Commit

Permalink
Covering the successfully adding a valid coupon to cart by an integra…
Browse files Browse the repository at this point in the history
…tion test
  • Loading branch information
eduard13 committed Feb 12, 2019
1 parent 2fcf9b7 commit 2fc33b4
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,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 2fc33b4

Please sign in to comment.