Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ApplySalesRuleOnFrontendStep.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Checkout\Test\Page\CheckoutCart;
11 use Magento\Mtf\TestStep\TestStepInterface;
12 
16 class ApplySalesRuleOnFrontendStep implements TestStepInterface
17 {
23  protected $checkoutCart;
24 
30  protected $salesRule;
31 
37  public function __construct(CheckoutCart $checkoutCart, SalesRule $salesRule = null)
38  {
39  $this->checkoutCart = $checkoutCart;
40  $this->salesRule = $salesRule;
41  }
42 
48  public function run()
49  {
50  if ($this->salesRule !== null) {
51  $this->checkoutCart->getDiscountCodesBlock()->applyCouponCode($this->salesRule->getCouponCode());
52  $this->checkoutCart->getTotalsBlock()->waitForUpdatedTotals();
53  }
54  }
55 }
__construct(CheckoutCart $checkoutCart, SalesRule $salesRule=null)