diff --git a/InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesWithDifferentOrderIdentitiesTest.php b/InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesWithDifferentOrderIdentitiesTest.php new file mode 100644 index 000000000000..90e19761b489 --- /dev/null +++ b/InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesWithDifferentOrderIdentitiesTest.php @@ -0,0 +1,64 @@ +getSalableQuantityInconsistencies + = Bootstrap::getObjectManager()->get(GetSalableQuantityInconsistencies::class); + } + + /** + * Verify Reservation with only objectId in the metadata + * + * @magentoDataFixture Magento/Sales/_files/order.php + * @magentoDataFixture Magento_InventoryReservationCli::Test/Integration/_files/delete_reservations.php + * @magentoDataFixture Magento_InventoryReservationCli::Test/Integration/_files/reservation_with_order_id_only.php + * @magentoAppIsolation enabled + * @magentoDbIsolation disabled + * @throws \Magento\Framework\Validation\ValidationException + */ + public function testReservationWithObjectId(): void + { + $inconsistencies = $this->getSalableQuantityInconsistencies->execute(); + self::assertSame([], $inconsistencies); + } + + /** + * Verify Reservation with only objectIncrementId in the metadata + * + * @magentoDataFixture Magento/Sales/_files/order.php + * @magentoDataFixture Magento_InventoryReservationCli::Test/Integration/_files/delete_reservations.php + * @magentoDataFixture Magento_InventoryReservationCli::Test/Integration/_files/reservation_with_order_increment_id_only.php + * @magentoAppIsolation enabled + * @magentoDbIsolation disabled + * @throws \Magento\Framework\Validation\ValidationException + */ + public function testReservationWithObjectIncrementId(): void + { + $inconsistencies = $this->getSalableQuantityInconsistencies->execute(); + self::assertSame([], $inconsistencies); + } +} diff --git a/InventoryReservationCli/Test/Integration/_files/reservation_with_order_id_only.php b/InventoryReservationCli/Test/Integration/_files/reservation_with_order_id_only.php new file mode 100644 index 000000000000..13bdbc3fab99 --- /dev/null +++ b/InventoryReservationCli/Test/Integration/_files/reservation_with_order_id_only.php @@ -0,0 +1,32 @@ +create(Magento\Framework\App\ResourceConnection::class); + +/** @var \Magento\Sales\Model\Order $order */ +$order = $objectManager->create(Order::class)->loadByIncrementId('100000001'); + +$connection = $resourceConnection->getConnection(); +$tableName = $resourceConnection->getTableName('inventory_reservation'); + +$payload = [ + 'stock_id' => 1, + 'sku' => 'simple', + 'quantity' => -2, + 'metadata' => '{"event_type":"' . SalesEventInterface::EVENT_ORDER_PLACED + . '","object_type":"order","object_id":"' . (string)$order->getEntityId() . '","objectIncrementId":""}' +]; + +$qry = $connection->insert($tableName, $payload); diff --git a/InventoryReservationCli/Test/Integration/_files/reservation_with_order_id_only_rollback.php b/InventoryReservationCli/Test/Integration/_files/reservation_with_order_id_only_rollback.php new file mode 100644 index 000000000000..8cfd4b450ec7 --- /dev/null +++ b/InventoryReservationCli/Test/Integration/_files/reservation_with_order_id_only_rollback.php @@ -0,0 +1,25 @@ +create(Magento\Framework\App\ResourceConnection::class); + +$connection = $resourceConnection->getConnection(); +$tableName = $resourceConnection->getTableName('inventory_reservation'); + +$payload = [ + 'stock_id' => 1, + 'sku' => 'simple' +]; + +$qry = $connection->delete($tableName, $payload); diff --git a/InventoryReservationCli/Test/Integration/_files/reservation_with_order_increment_id_only.php b/InventoryReservationCli/Test/Integration/_files/reservation_with_order_increment_id_only.php new file mode 100644 index 000000000000..e25dc2a05f69 --- /dev/null +++ b/InventoryReservationCli/Test/Integration/_files/reservation_with_order_increment_id_only.php @@ -0,0 +1,28 @@ +create(Magento\Framework\App\ResourceConnection::class); + +$connection = $resourceConnection->getConnection(); +$tableName = $resourceConnection->getTableName('inventory_reservation'); + +$payload = [ + 'stock_id' => 1, + 'sku' => 'simple', + 'quantity' => -2, + 'metadata' => '{"event_type":"' . SalesEventInterface::EVENT_ORDER_PLACED + . '","object_type":"order","object_id":"","objectIncrementId":"100000001"}' +]; + +$qry = $connection->insert($tableName, $payload); diff --git a/InventoryReservationCli/Test/Integration/_files/reservation_with_order_increment_id_only_rollback.php b/InventoryReservationCli/Test/Integration/_files/reservation_with_order_increment_id_only_rollback.php new file mode 100644 index 000000000000..8cfd4b450ec7 --- /dev/null +++ b/InventoryReservationCli/Test/Integration/_files/reservation_with_order_increment_id_only_rollback.php @@ -0,0 +1,25 @@ +create(Magento\Framework\App\ResourceConnection::class); + +$connection = $resourceConnection->getConnection(); +$tableName = $resourceConnection->getTableName('inventory_reservation'); + +$payload = [ + 'stock_id' => 1, + 'sku' => 'simple' +]; + +$qry = $connection->delete($tableName, $payload);