Skip to content

Commit a1cedf1

Browse files
committed
MC-18826: Increase test coverage for Cart & Checkout and Order Processing functional areas
- Integration test for MC-11299
1 parent cea3e79 commit a1cedf1

File tree

1 file changed

+35
-3
lines changed

1 file changed

+35
-3
lines changed

dev/tests/integration/testsuite/Magento/Sales/Model/Order/ShipmentTest.php

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,12 @@ public function testAddComment()
117117
$saved = $this->shipmentRepository->save($shipment);
118118

119119
$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+
);
123126
self::assertEquals(2, count($actual));
124127
self::assertEquals([$message1, $message2], $actual);
125128
}
@@ -144,4 +147,33 @@ private function getOrder(string $incrementId): OrderInterface
144147

145148
return array_pop($items);
146149
}
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+
}
147179
}

0 commit comments

Comments
 (0)