Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertTrackingDetailsIsPresent.php
Go to the documentation of this file.
1 <?php
7 
8 use Magento\Mtf\Client\BrowserInterface;
9 use Magento\Mtf\Constraint\AbstractConstraint;
12 use Magento\Sales\Test\Page\Adminhtml\OrderIndex;
13 use Magento\Sales\Test\Page\Adminhtml\SalesOrderView;
14 
18 class AssertTrackingDetailsIsPresent extends AbstractConstraint
19 {
25  private $mainContainer = '.main';
26 
36  public function processAssert(
37  BrowserInterface $browser,
38  OrderInjectable $order,
39  OrderIndex $orderIndex,
40  SalesOrderView $salesOrderView,
41  $resultTrackingData
42  ) {
43  $orderIndex->open();
44  $orderIndex->getSalesOrderGrid()
45  ->searchAndOpen(['id' => $order->getId()]);
46 
48  $infoTab = $salesOrderView->getOrderForm()
49  ->openTab('info')
50  ->getTab('info');
51 
52  $mainWindow = $browser->getCurrentWindow();
53  $shippingInfoBlock = $infoTab->getShippingInfoBlock();
54  $shippingInfoBlock->openTrackingPopup();
55 
56  $browser->selectWindow();
57 
58  $selector = '.close';
59  $browser->waitUntil(function () use ($browser, $selector) {
60  $element = $browser->find($selector);
61  return $element->isVisible() ? true : null;
62  });
63 
64  $body = $browser->find($this->mainContainer)->getText();
65  foreach ($resultTrackingData as $value) {
66  \PHPUnit\Framework\Assert::assertContains(
67  $value,
68  $body,
69  'The "' . $value . '" is not present in Shipping Tracking popup.'
70  );
71  }
72  $popupWindow = $browser->getCurrentWindow();
73  $browser->selectWindow($mainWindow);
74  $browser->closeWindow($popupWindow);
75  }
76 
80  public function toString()
81  {
82  return 'Shipment tracking data is present in the popup window.';
83  }
84 }
$order
Definition: order.php:55
$value
Definition: gender.phtml:16
$element
Definition: element.phtml:12