Skip to content

Commit 14d4016

Browse files
committed
MAGETWO-95429: ShipOrder API with No Tracking Number Error Message
- Changed class to use existing collection - Added api test
1 parent 840a7aa commit 14d4016

File tree

2 files changed

+33
-7
lines changed

2 files changed

+33
-7
lines changed

app/code/Magento/Sales/Model/Order/Shipment.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -574,13 +574,10 @@ public function setItems($items)
574574
public function getTracks()
575575
{
576576
if ($this->getData(ShipmentInterface::TRACKS) === null) {
577-
$collection = $this->_trackCollectionFactory->create()->setShipmentFilter($this->getId());
578-
if ($this->getId()) {
579-
foreach ($collection as $item) {
580-
$item->setShipment($this);
581-
}
582-
$this->setData(ShipmentInterface::TRACKS, $collection->getItems());
577+
foreach ($this->getTracksCollection() as $item) {
578+
$item->setShipment($this);
583579
}
580+
$this->setData(ShipmentInterface::TRACKS, $this->getTracksCollection()->getItems());
584581
}
585582
return $this->getData(ShipmentInterface::TRACKS);
586583
}

dev/tests/api-functional/testsuite/Magento/Sales/Service/V1/ShipOrderTest.php

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ class ShipOrderTest extends \Magento\TestFramework\TestCase\WebapiAbstract
2525

2626
protected function setUp()
2727
{
28-
$this->markTestIncomplete('https://github.com/magento-engcom/msi/issues/1335');
2928
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
3029

3130
$this->shipmentRepository = $this->objectManager->get(
@@ -38,6 +37,7 @@ protected function setUp()
3837
*/
3938
public function testConfigurableShipOrder()
4039
{
40+
$this->markTestIncomplete('https://github.com/magento-engcom/msi/issues/1335');
4141
$productsQuantity = 1;
4242

4343
/** @var \Magento\Sales\Model\Order $existingOrder */
@@ -132,6 +132,35 @@ public function testShipOrder()
132132
);
133133
}
134134

135+
/**
136+
* Tests that not providing a tracking number produces the correct error. See MAGETWO-95429
137+
* @expectedException \Exception
138+
* @expectedExceptionMessageRegExp /Shipment Document Validation Error\(s\):(?:\n|\\n)Please enter a tracking number./
139+
* @magentoApiDataFixture Magento/Sales/_files/order_new.php
140+
*/
141+
public function testShipOrderWithoutTrackingNumberReturnsError()
142+
{
143+
/** @var \Magento\Sales\Model\Order $existingOrder */
144+
$existingOrder = $this->objectManager->create(\Magento\Sales\Model\Order::class)
145+
->loadByIncrementId('100000001');
146+
147+
$requestData = [
148+
'orderId' => $existingOrder->getId(),
149+
'comment' => [
150+
'comment' => 'Test Comment',
151+
'is_visible_on_front' => 1,
152+
],
153+
'tracks' => [
154+
[
155+
'title' => 'Simple shipment track',
156+
'carrier_code' => 'UPS'
157+
]
158+
]
159+
];
160+
161+
$this->_webApiCall($this->getServiceInfo($existingOrder), $requestData);
162+
}
163+
135164
/**
136165
* @magentoApiDataFixture Magento/Bundle/_files/order_with_bundle_shipped_separately.php
137166
*/

0 commit comments

Comments
 (0)