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 @@ -39,4 +39,35 @@ public function testExecute()
39
39
\Magento \Framework \Message \MessageInterface::TYPE_ERROR
40
40
);
41
41
}
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
+ }
42
73
}
You can’t perform that action at this time.
0 commit comments