Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SubmitOrderStep.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Customer\Test\Fixture\Address;
11 use Magento\Mtf\Fixture\FixtureFactory;
12 use Magento\Mtf\TestStep\TestStepInterface;
14 use Magento\Sales\Test\Page\Adminhtml\OrderCreateIndex;
15 use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
16 
20 class SubmitOrderStep implements TestStepInterface
21 {
27  private $orderCreateIndex;
28 
34  private $salesOrderView;
35 
41  private $fixtureFactory;
42 
48  private $customer;
49 
55  private $billingAddress;
56 
62  private $products;
63 
69  private $order;
70 
80  public function __construct(
81  OrderCreateIndex $orderCreateIndex,
82  SalesOrderView $salesOrderView,
83  FixtureFactory $fixtureFactory,
84  Customer $customer,
85  array $products,
86  Address $billingAddress = null,
87  OrderInjectable $order = null
88  ) {
89  $this->orderCreateIndex = $orderCreateIndex;
90  $this->salesOrderView = $salesOrderView;
91  $this->fixtureFactory = $fixtureFactory;
92  $this->customer = $customer;
93  $this->billingAddress = $billingAddress;
94  $this->products = $products;
95  $this->order = $order;
96  }
97 
103  public function run()
104  {
105  $this->orderCreateIndex->getCreateBlock()->submitOrder();
106  $this->salesOrderView->getMessagesBlock()->waitSuccessMessage();
107  $orderId = trim($this->salesOrderView->getTitleBlock()->getTitle(), '#');
108  $data = [
109  'id' => $orderId,
110  'customer_id' => ['customer' => $this->customer],
111  'entity_id' => ['products' => $this->products],
112  'billing_address_id' => ['billingAddress' => $this->billingAddress],
113  ];
114  $orderData = $this->order !== null ? $this->order->getData() : [];
115  $order = $this->fixtureFactory->createByCode(
116  'orderInjectable',
117  ['data' => array_merge($data, $orderData)]
118  );
119 
120  return ['orderId' => $orderId, 'order' => $order];
121  }
122 }
$customer
Definition: customers.php:11
__construct(OrderCreateIndex $orderCreateIndex, SalesOrderView $salesOrderView, FixtureFactory $fixtureFactory, Customer $customer, array $products, Address $billingAddress=null, OrderInjectable $order=null)