Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ShipmentAddCommentTest.php
Go to the documentation of this file.
1 <?php
7 
10 
15 {
19  const SERVICE_READ_NAME = 'salesShipmentCommentRepositoryV1';
20 
24  const SERVICE_VERSION = 'V1';
25 
29  const SHIPMENT_INCREMENT_ID = '100000001';
30 
34  protected $objectManager;
35 
36  protected function setUp()
37  {
39  }
40 
46  public function testShipmentAddComment()
47  {
49  $shipmentCollection = $this->objectManager->get(
50  \Magento\Sales\Model\ResourceModel\Order\Shipment\Collection::class
51  );
52  $shipment = $shipmentCollection->getFirstItem();
53 
54  $commentData = [
55  ShipmentCommentInterface::COMMENT => 'Hello world!',
61  ];
62 
63  $requestData = ['entity' => $commentData];
64  $serviceInfo = [
65  'rest' => [
66  'resourcePath' => '/V1/shipment/' . $shipment->getId() . '/comments',
68  ],
69  'soap' => [
70  'service' => self::SERVICE_READ_NAME,
71  'serviceVersion' => self::SERVICE_VERSION,
72  'operation' => self::SERVICE_READ_NAME . 'save',
73  ],
74  ];
75 
76  $result = $this->_webApiCall($serviceInfo, $requestData);
77  $this->assertNotEmpty($result);
78  }
79 }
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)
foreach($order->getItems() as $orderItem) $shipment