@@ -117,9 +117,12 @@ public function testAddComment()
117
117
$ saved = $ this ->shipmentRepository ->save ($ shipment );
118
118
119
119
$ comments = $ saved ->getComments ();
120
- $ actual = array_map (function (CommentInterface $ comment ) {
121
- return $ comment ->getComment ();
122
- }, $ comments );
120
+ $ actual = array_map (
121
+ function (CommentInterface $ comment ) {
122
+ return $ comment ->getComment ();
123
+ },
124
+ $ comments
125
+ );
123
126
self ::assertEquals (2 , count ($ actual ));
124
127
self ::assertEquals ([$ message1 , $ message2 ], $ actual );
125
128
}
@@ -144,4 +147,33 @@ private function getOrder(string $incrementId): OrderInterface
144
147
145
148
return array_pop ($ items );
146
149
}
150
+
151
+ /**
152
+ * Check that getTracksCollection() returns only order related tracks.
153
+ */
154
+ public function testGetTracksCollection ()
155
+ {
156
+ $ order = $ this ->getOrder ('100000001 ' );
157
+ $ items = [];
158
+ foreach ($ order ->getItems () as $ item ) {
159
+ $ items [$ item ->getId ()] = $ item ->getQtyOrdered ();
160
+ }
161
+ /** @var \Magento\Sales\Model\Order\Shipment $shipment */
162
+ $ shipment = $ this ->objectManager ->get (ShipmentFactory::class)
163
+ ->create ($ order , $ items );
164
+
165
+ $ tracks = $ shipment ->getTracksCollection ();
166
+ self ::assertTrue (empty ($ tracks ->getItems ()));
167
+
168
+ /** @var ShipmentTrackInterface $track */
169
+ $ track = $ this ->objectManager ->create (ShipmentTrackInterface::class);
170
+ $ track ->setNumber ('Test Number ' )
171
+ ->setTitle ('Test Title ' )
172
+ ->setCarrierCode ('Test CODE ' );
173
+
174
+ $ shipment ->addTrack ($ track );
175
+ $ this ->shipmentRepository ->save ($ shipment );
176
+ $ saved = $ shipment ->getTracksCollection ();
177
+ self ::assertTrue (in_array ($ track ->getId (), $ saved ->getColumnValues ('id ' )));
178
+ }
147
179
}
0 commit comments