Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ShipmentAddTrackTest.php
Go to the documentation of this file.
1 <?php
7 
14 
19 {
23  const SERVICE_READ_NAME = 'salesShipmentTrackRepositoryV1';
24 
28  const SERVICE_VERSION = 'V1';
29 
33  const SHIPMENT_INCREMENT_ID = '100000001';
34 
38  private $objectManager;
39 
43  protected function setUp()
44  {
45  $this->objectManager = Bootstrap::getObjectManager();
46  }
47 
53  public function testShipmentAddTrack()
54  {
55  $shipmentCollection = $this->objectManager->get(Collection::class);
57  $shipment = $shipmentCollection->getFirstItem();
58 
59  $trackData = [
66  ShipmentTrackInterface::DESCRIPTION => 'Shipment description',
67  ShipmentTrackInterface::TITLE => 'Shipment title',
69  ];
70 
71  $result = $this->_webApiCall($this->getServiceInfo(), ['entity' => $trackData]);
72 
73  self::assertNotEmpty($result);
74  self::assertNotEmpty($result[ShipmentTrackInterface::ENTITY_ID]);
75  self::assertEquals($shipment->getId(), $result[ShipmentTrackInterface::PARENT_ID]);
76  }
82  private function getServiceInfo()
83  {
84  return [
85  'rest' => [
86  'resourcePath' => '/V1/shipment/track',
87  'httpMethod' => Request::HTTP_METHOD_POST,
88  ],
89  'soap' => [
90  'service' => self::SERVICE_READ_NAME,
91  'serviceVersion' => self::SERVICE_VERSION,
92  'operation' => self::SERVICE_READ_NAME . 'save',
93  ],
94  ];
95  }
96 }
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)
foreach($order->getItems() as $orderItem) $shipment