Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ShipmentCreateTest.php
Go to the documentation of this file.
1 <?php
8 
10 
15 {
16  const RESOURCE_PATH = '/V1/shipment';
17 
18  const SERVICE_READ_NAME = 'salesShipmentRepositoryV1';
19 
20  const SERVICE_VERSION = 'V1';
21 
25  protected $objectManager;
26 
27  protected function setUp()
28  {
30  }
31 
35  public function testInvoke()
36  {
38  $order = $this->objectManager->create(\Magento\Sales\Model\Order::class)->loadByIncrementId('100000001');
39  $orderItem = current($order->getAllItems());
40  $items = [
41  [
42  'order_item_id' => $orderItem->getId(),
43  'qty' => $orderItem->getQtyOrdered(),
44  'additional_data' => null,
45  'description' => null,
46  'entity_id' => 1,
47  'name' => null,
48  'parent_id' => null,
49  'price' => null,
50  'product_id' => null,
51  'row_total' => null,
52  'sku' => 'simple',
53  'weight' => null,
54  ],
55  ];
56  $serviceInfo = [
57  'rest' => [
58  'resourcePath' => self::RESOURCE_PATH,
60  ],
61  'soap' => [
62  'service' => self::SERVICE_READ_NAME,
63  'serviceVersion' => self::SERVICE_VERSION,
64  'operation' => self::SERVICE_READ_NAME . 'save',
65  ],
66  ];
67  $data = [
68  'order_id' => $order->getId(),
69  'entity_id' => null,
70  'store_id' => null,
71  'total_weight' => null,
72  'total_qty' => null,
73  'email_sent' => null,
74  'customer_id' => null,
75  'shipping_address_id' => null,
76  'billing_address_id' => null,
77  'shipment_status' => null,
78  'increment_id' => null,
79  'created_at' => null,
80  'updated_at' => null,
81  'shipping_label' => null,
82  'tracks' => [
83  [
84  'carrier_code' => 'UPS',
85  'order_id' => $order->getId(),
86  'title' => 'ground',
87  'description' => null,
88  'track_number' => '12345678',
89  'parent_id' => null,
90  'created_at' => null,
91  'updated_at' => null,
92  'qty' => null,
93  'weight' => null
94  ]
95  ],
96  'items' => $items,
97  'comments' => [
98  [
99  'comment' => 'Shipment-related comment.',
100  'is_customer_notified' => null,
101  'is_visible_on_front' => null,
102  'parent_id' => null
103  ]
104  ],
105  ];
106  $result = $this->_webApiCall($serviceInfo, ['entity' => $data]);
107  $this->assertNotEmpty($result);
108  }
109 }
_webApiCall( $serviceInfo, $arguments=[], $webApiAdapterCode=null, $storeCode=null, $integration=null)
$orderItem
Definition: order.php:30
$order
Definition: order.php:55
$items