Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ShipmentCommentsListTest.php
Go to the documentation of this file.
1 <?php
7 
9 
14 {
15  const SERVICE_NAME = 'salesShipmentManagementV1';
16 
17  const SERVICE_VERSION = 'V1';
18 
22  public function testShipmentCommentsList()
23  {
24  $comment = 'Test comment';
26 
28  $shipmentCollection = $objectManager->get(\Magento\Sales\Model\ResourceModel\Order\Shipment\Collection::class);
29  $shipment = $shipmentCollection->getFirstItem();
30  $shipmentComment = $objectManager->get(\Magento\Sales\Model\Order\Shipment\Comment::class);
31  $shipmentComment->setComment($comment);
32  $shipmentComment->setParentId($shipment->getId());
33  $shipmentComment->save();
34 
35  $serviceInfo = [
36  'rest' => [
37  'resourcePath' => '/V1/shipment/' . $shipment->getId() . '/comments',
39  ],
40  'soap' => [
41  'service' => self::SERVICE_NAME,
42  'serviceVersion' => self::SERVICE_VERSION,
43  'operation' => self::SERVICE_NAME . 'getCommentsList',
44  ],
45  ];
46  $requestData = ['id' => $shipment->getId()];
47  $result = $this->_webApiCall($serviceInfo, $requestData);
48  // TODO Test fails, due to the inability of the framework API to handle data collection
49  foreach ($result['items'] as $item) {
51  $shipmentHistoryStatus = $objectManager->get(\Magento\Sales\Model\Order\Shipment\Comment::class)
52  ->load($item['entity_id']);
53  $this->assertEquals($shipmentHistoryStatus->getComment(), $item['comment']);
54  }
55  }
56 }
$objectManager
Definition: bootstrap.php:17
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)
foreach($order->getItems() as $orderItem) $shipment