Skip to content

Commit 7992523

Browse files
authored
ENGCOM-4164: [Checkout] Covering the successfully adding a valid coupon to cart by an integra… #21028
2 parents 0ede3c0 + e0604f3 commit 7992523

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

dev/tests/integration/testsuite/Magento/Checkout/Controller/Cart/Index/CouponPostTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,35 @@ public function testExecute()
3939
\Magento\Framework\Message\MessageInterface::TYPE_ERROR
4040
);
4141
}
42+
43+
/**
44+
* Testing by adding a valid coupon to cart
45+
*
46+
* @magentoDataFixture Magento/Checkout/_files/quote_with_virtual_product_and_address.php
47+
* @magentoDataFixture Magento/Usps/Fixtures/cart_rule_coupon_free_shipping.php
48+
* @return void
49+
*/
50+
public function testAddingValidCoupon(): void
51+
{
52+
/** @var $session \Magento\Checkout\Model\Session */
53+
$session = $this->_objectManager->create(\Magento\Checkout\Model\Session::class);
54+
$quote = $session->getQuote();
55+
$quote->setData('trigger_recollect', 1)->setTotalsCollectedFlag(true);
56+
57+
$couponCode = 'IMPHBR852R61';
58+
$inputData = [
59+
'remove' => 0,
60+
'coupon_code' => $couponCode
61+
];
62+
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
63+
$this->getRequest()->setPostValue($inputData);
64+
$this->dispatch(
65+
'checkout/cart/couponPost/'
66+
);
67+
68+
$this->assertSessionMessages(
69+
$this->equalTo(['You used coupon code "' . $couponCode . '".']),
70+
\Magento\Framework\Message\MessageInterface::TYPE_SUCCESS
71+
);
72+
}
4273
}

0 commit comments

Comments
 (0)