Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
EstimateShippingAndTaxStep.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Checkout\Test\Page\CheckoutCart;
11 use Magento\Mtf\Fixture\FixtureFactory;
12 use Magento\Customer\Test\Fixture\Address;
14 use Magento\Mtf\TestStep\TestStepInterface;
15 
19 class EstimateShippingAndTaxStep implements TestStepInterface
20 {
26  protected $checkoutCart;
27 
33  protected $address;
34 
44 
50  protected $cart;
51 
57  protected $fixtureFactory;
58 
64  protected $shipping;
65 
71  protected $products;
72 
83  public function __construct(
87  FixtureFactory $fixtureFactory,
88  array $products,
89  array $shipping = [],
90  Cart $cart = null
91  ) {
92  $this->checkoutCart = $checkoutCart;
93  $this->address = $address;
94  $this->assertEstimateShippingAndTax = $assertEstimateShippingAndTax;
95  $this->fixtureFactory = $fixtureFactory;
96  $this->products = $products;
97  $this->shipping = $shipping;
98  $this->cart = $cart;
99  }
100 
106  public function run()
107  {
108  $this->checkoutCart->open();
109  $this->checkoutCart->getCartBlock()->waitCartContainerLoading();
110  sleep(20);
112  if ($this->cart !== null) {
113  $cart = $this->fixtureFactory->createByCode(
114  'cart',
115  ['data' => array_merge($this->cart->getData(), ['items' => ['products' => $this->products]])]
116  );
117  $this->checkoutCart->getShippingBlock()->fillEstimateShippingAndTax($this->address);
118  if (!empty($this->shipping)) {
119  $this->checkoutCart->getShippingBlock()->selectShippingMethod($this->shipping);
120  }
121  $this->checkoutCart->getTotalsBlock()->waitForUpdatedTotals();
122  $this->assertEstimateShippingAndTax->processAssert($this->checkoutCart, $cart, false);
123  }
124  }
125 }
__construct(CheckoutCart $checkoutCart, Address $address, AssertEstimateShippingAndTax $assertEstimateShippingAndTax, FixtureFactory $fixtureFactory, array $products, array $shipping=[], Cart $cart=null)