File tree Expand file tree Collapse file tree 1 file changed +31
-0
lines changed
dev/tests/integration/testsuite/Magento/Checkout/Controller/Cart/Index Expand file tree Collapse file tree 1 file changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -36,4 +36,35 @@ public function testExecute()
36
36
\Magento \Framework \Message \MessageInterface::TYPE_ERROR
37
37
);
38
38
}
39
+
40
+ /**
41
+ * Testing by adding a valid coupon to cart
42
+ *
43
+ * @magentoDataFixture Magento/Checkout/_files/quote_with_virtual_product_and_address.php
44
+ * @magentoDataFixture Magento/Usps/Fixtures/cart_rule_coupon_free_shipping.php
45
+ * @return void
46
+ */
47
+ public function testAddingValidCoupon (): void
48
+ {
49
+ /** @var $session \Magento\Checkout\Model\Session */
50
+ $ session = $ this ->_objectManager ->create (\Magento \Checkout \Model \Session::class);
51
+ $ quote = $ session ->getQuote ();
52
+ $ quote ->setData ('trigger_recollect ' , 1 )->setTotalsCollectedFlag (true );
53
+
54
+ $ couponCode = 'IMPHBR852R61 ' ;
55
+ $ inputData = [
56
+ 'remove ' => 0 ,
57
+ 'coupon_code ' => $ couponCode
58
+ ];
59
+ $ this ->getRequest ()->setMethod (HttpRequest::METHOD_POST );
60
+ $ this ->getRequest ()->setPostValue ($ inputData );
61
+ $ this ->dispatch (
62
+ 'checkout/cart/couponPost/ '
63
+ );
64
+
65
+ $ this ->assertSessionMessages (
66
+ $ this ->equalTo (['You used coupon code " ' . $ couponCode . '". ' ]),
67
+ \Magento \Framework \Message \MessageInterface::TYPE_SUCCESS
68
+ );
69
+ }
39
70
}
You can’t perform that action at this time.
0 commit comments