Skip to content

Commit d3b5044

Browse files
anzinandrewbess
authored andcommitted
Fixed Integration Test CreateShipmentForOrderTest
1 parent 8cf07a9 commit d3b5044

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ protected function prepareItems(
136136
}
137137
} else {
138138
if (isset($items[$orderItem->getId()])) {
139+
if (!is_numeric($items[$orderItem->getId()])) {
140+
throw new \Magento\Framework\Exception\LocalizedException(
141+
__('The specified qty is not valid.')
142+
);
143+
}
144+
139145
$qty = min($items[$orderItem->getId()], $orderItem->getQtyToShip());
140146
} elseif (!count($items)) {
141147
$qty = $orderItem->getQtyToShip();

dev/tests/integration/testsuite/Magento/ImportExport/Model/Export/ConsumerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function testProcess(): void
9494
$data = $this->csvReader->getData($this->directory->getAbsolutePath($this->filePath));
9595
$this->assertCount(2, $data);
9696
$skuPosition = $this->getSkuPosition($data);
97-
$this->assertNotFalse($skuPosition);
97+
$this->assertNotNull($skuPosition);
9898
$this->assertEquals('simple2', $data[1][$skuPosition]);
9999
}
100100

@@ -103,9 +103,9 @@ public function testProcess(): void
103103
*
104104
* @param array $csvFileData
105105
*
106-
* @return bool|int
106+
* @return int|null
107107
*/
108-
private function getSkuPosition(array $csvFileData)
108+
private function getSkuPosition(array $csvFileData): ?int
109109
{
110110
foreach ($csvFileData as $data) {
111111
$skuPosition = array_search(ProductInterface::SKU, $data);
@@ -115,6 +115,6 @@ private function getSkuPosition(array $csvFileData)
115115
}
116116
}
117117

118-
return false;
118+
return null;
119119
}
120120
}

dev/tests/integration/testsuite/Magento/Shipping/Controller/Adminhtml/Order/Shipment/Save/CreateShipmentForOrderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public function testCreateOrderShipmentWithAlphabetQty(): void
234234
$postData = $this->createPostData($dataToSend);
235235
$this->performShipmentCreationRequest($postData);
236236
$this->assertCreateShipmentRequestWithError(
237-
"Shipment Document Validation Error(s):\nYou can't create a shipment without products.",
237+
"The specified qty is not valid.",
238238
"admin/order_shipment/new/order_id/{$postData['order_id']}"
239239
);
240240
}

0 commit comments

Comments
 (0)