Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
GetPlacedOrderIdStep.php
Go to the documentation of this file.
1 <?php
8 
9 use Magento\Mtf\TestStep\TestStepInterface;
10 use Magento\Checkout\Test\Page\CheckoutOnepageSuccess;
12 
16 class GetPlacedOrderIdStep implements TestStepInterface
17 {
23  private $checkoutOnepageSuccess;
24 
30  private $decorator;
31 
36  public function __construct(
37  CheckoutOnepageSuccess $checkoutOnepageSuccess,
38  WebapiDecorator $decorator
39  ) {
40  $this->checkoutOnepageSuccess = $checkoutOnepageSuccess;
41  $this->decorator = $decorator;
42  }
43 
49  public function run()
50  {
51  $incrementId = $this->checkoutOnepageSuccess->getSuccessBlock()->getGuestOrderId();
52  return [
53  'entityId' => $this->getEntityId($incrementId),
54  'orderId' => $incrementId
55  ];
56  }
57 
64  private function getEntityId($incrementId)
65  {
66  $url = $_ENV['app_frontend_url'] . 'rest/V1/orders/';
67  $url .= '?searchCriteria[filterGroups][0][filters][0][field]=increment_id';
68  $url .= '&searchCriteria[filterGroups][0][filters][0][value]=' . $incrementId;
69  $this->decorator->write($url, [], WebapiDecorator::GET);
70  $response = json_decode($this->decorator->read(), true);
71  $this->decorator->close();
72  return $response['items'][0]['entity_id'];
73  }
74 }
$response
Definition: 404.php:11
__construct(CheckoutOnepageSuccess $checkoutOnepageSuccess, WebapiDecorator $decorator)