Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AddProductsStep.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Mtf\Fixture\FixtureFactory;
10 use Magento\Sales\Test\Page\Adminhtml\OrderCreateIndex;
11 use Magento\Mtf\TestStep\TestStepInterface;
12 
16 class AddProductsStep implements TestStepInterface
17 {
23  private $orderCreateIndex;
24 
30  private $products;
31 
37  private $fixtureFactory;
38 
44  public function __construct(
45  OrderCreateIndex $orderCreateIndex,
46  FixtureFactory $fixtureFactory,
47  array $products
48  ) {
49  $this->orderCreateIndex = $orderCreateIndex;
50  $this->products = $products;
51  $this->fixtureFactory = $fixtureFactory;
52  }
53 
59  public function run()
60  {
61  $createBlock = $this->orderCreateIndex->getCreateBlock();
62  $createBlock->getItemsBlock()->clickAddProducts();
63  foreach ($this->products as $product) {
64  $createBlock->getGridBlock()->searchAndSelect(['sku' => $product->getSku()]);
65  $createBlock->getTemplateBlock()->waitLoader();
66  if ($this->orderCreateIndex->getConfigureProductBlock()->isVisible()) {
67  $this->orderCreateIndex->getConfigureProductBlock()->configProduct($product);
68  }
69  }
70  $createBlock->addSelectedProductsToOrder();
71  $createBlock->getTemplateBlock()->waitLoader();
72 
73  $cart['data']['items'] = ['products' => $this->products];
74  return ['cart' => $this->fixtureFactory->createByCode('cart', $cart)];
75  }
76 }
__construct(OrderCreateIndex $orderCreateIndex, FixtureFactory $fixtureFactory, array $products)