Skip to content

Commit 332dfac

Browse files
authored
ENGCOM-4225: [Backport] [Checkout] Covering the successfully adding a valid coupon to cart by an integra… #21155
2 parents 6bb8952 + 5f2f522 commit 332dfac

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
namespace Magento\Checkout\Controller\Cart\Index;
88

9+
use Magento\Framework\App\Request\Http as HttpRequest;
10+
911
/**
1012
* @magentoDbIsolation enabled
1113
*/
@@ -36,4 +38,35 @@ public function testExecute()
3638
\Magento\Framework\Message\MessageInterface::TYPE_ERROR
3739
);
3840
}
41+
42+
/**
43+
* Testing by adding a valid coupon to cart
44+
*
45+
* @magentoDataFixture Magento/Checkout/_files/quote_with_virtual_product_and_address.php
46+
* @magentoDataFixture Magento/Usps/Fixtures/cart_rule_coupon_free_shipping.php
47+
* @return void
48+
*/
49+
public function testAddingValidCoupon()
50+
{
51+
/** @var $session \Magento\Checkout\Model\Session */
52+
$session = $this->_objectManager->create(\Magento\Checkout\Model\Session::class);
53+
$quote = $session->getQuote();
54+
$quote->setData('trigger_recollect', 1)->setTotalsCollectedFlag(true);
55+
56+
$couponCode = 'IMPHBR852R61';
57+
$inputData = [
58+
'remove' => 0,
59+
'coupon_code' => $couponCode
60+
];
61+
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
62+
$this->getRequest()->setPostValue($inputData);
63+
$this->dispatch(
64+
'checkout/cart/couponPost/'
65+
);
66+
67+
$this->assertSessionMessages(
68+
$this->equalTo(['You used coupon code "' . $couponCode . '".']),
69+
\Magento\Framework\Message\MessageInterface::TYPE_SUCCESS
70+
);
71+
}
3972
}

0 commit comments

Comments
 (0)