Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AssertShipmentItems.php
Go to the documentation of this file.
1 <?php
8 
11 use Magento\Shipping\Test\Page\Adminhtml\SalesShipmentView;
12 use Magento\Shipping\Test\Page\Adminhtml\ShipmentIndex;
13 use Magento\Mtf\ObjectManager;
14 use Magento\Mtf\System\Event\EventManagerInterface;
15 
20 {
26  protected $shipmentPage;
27 
34  public function __construct(
35  ObjectManager $objectManager,
36  EventManagerInterface $eventManager,
37  ShipmentIndex $shipmentIndex
38  ) {
39  parent::__construct($objectManager, $eventManager);
40  $this->shipmentPage = $shipmentIndex;
41  }
42 
52  public function processAssert(
53  SalesShipmentView $orderShipmentView,
54  OrderInjectable $order,
55  array $ids,
56  array $data = null
57  ) {
58  $this->shipmentPage->open();
59  $this->assert($order, $ids, $orderShipmentView, $data);
60  }
61 
71  protected function assert(
72  OrderInjectable $order,
73  array $ids,
74  SalesShipmentView $salesShipmentView,
75  array $data = null
76  ) {
77  $orderId = $order->getId();
78  $productsData = $this->prepareOrderProducts($order, $data['items_data']);
79  foreach ($ids['shipmentIds'] as $shipmentId) {
80  $filter = [
81  'order_id' => $orderId,
82  'id' => $shipmentId,
83  ];
84  $this->shipmentPage->getShipmentsGrid()->searchAndOpen($filter);
85  $itemsData = $this->preparePageItems($salesShipmentView->getItemsBlock()->getData());
86  $error = $this->verifyData($productsData, $itemsData);
87  \PHPUnit\Framework\Assert::assertEmpty($error, $error);
88  }
89  }
90 
96  public function toString()
97  {
98  return 'All shipment products are present in shipment page.';
99  }
100 }
$objectManager
Definition: bootstrap.php:17
$productsData
Definition: products.php:19
$order
Definition: order.php:55
assert(OrderInjectable $order, array $ids, SalesShipmentView $salesShipmentView, array $data=null)
processAssert(SalesShipmentView $orderShipmentView, OrderInjectable $order, array $ids, array $data=null)
verifyData(array $fixtureData, array $formData, $isStrict=false, $isPrepareError=true)
__construct(ObjectManager $objectManager, EventManagerInterface $eventManager, ShipmentIndex $shipmentIndex)