Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
OrderCommentsListTest.php
Go to the documentation of this file.
1 <?php
7 
9 
11 {
12  const SERVICE_NAME = 'salesOrderManagementV1';
13 
14  const SERVICE_VERSION = 'V1';
15 
19  public function testOrderCommentsList()
20  {
21  $comment = 'Test comment';
23 
25  $order = $objectManager->get(\Magento\Sales\Model\Order::class)->loadByIncrementId('100000001');
26  $history = $order->addStatusHistoryComment($comment, $order->getStatus());
27  $history->save();
28 
29  $serviceInfo = [
30  'rest' => [
31  'resourcePath' => '/V1/orders/' . $order->getId() . '/comments',
33  ],
34  'soap' => [
35  'service' => self::SERVICE_NAME,
36  'serviceVersion' => self::SERVICE_VERSION,
37  'operation' => self::SERVICE_NAME . 'getCommentsList',
38  ],
39  ];
40  $requestData = ['id' => $order->getId()];
41  $result = $this->_webApiCall($serviceInfo, $requestData);
42  foreach ($result['items'] as $history) {
43  $orderHistoryStatus = $objectManager->get(\Magento\Sales\Model\Order\Status\History::class)
44  ->load($history['entity_id']);
45  $this->assertEquals($orderHistoryStatus->getComment(), $history['comment']);
46  $this->assertEquals($orderHistoryStatus->getStatus(), $history['status']);
47  }
48  }
49 }
$objectManager
Definition: bootstrap.php:17
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)
$order
Definition: order.php:55