From ad6f0944a893c4b071290264a73361793d349976 Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Fri, 28 Aug 2020 12:14:03 -0500 Subject: [PATCH 1/8] Add missed test coverage for inventory inconsistencies cli command --- .../GetSalableQuantityInconsistenciesTest.php | 14 ++++++++ .../_files/reservation_with_order_id_only.php | 32 +++++++++++++++++++ ...eservation_with_order_id_only_rollback.php | 25 +++++++++++++++ 3 files changed, 71 insertions(+) create mode 100644 InventoryReservationCli/Test/Integration/_files/reservation_with_order_id_only.php create mode 100644 InventoryReservationCli/Test/Integration/_files/reservation_with_order_id_only_rollback.php diff --git a/InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesTest.php b/InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesTest.php index 116f2b5204b9..1416d51266dd 100644 --- a/InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesTest.php +++ b/InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesTest.php @@ -125,4 +125,18 @@ public function testFindMissingReservationConfigurableProductCustomStock(): void $items = reset($inconsistencies)->getItems(); self::assertEquals(3, $items['simple_10']); } + + /** + * Verify Reservation with only object_id in metadata + * + * @magentoDataFixture Magento/Sales/_files/order_with_shipping_and_invoice.php + * @magentoDataFixture Magento_InventoryReservationCli::Test/Integration/_files/delete_reservations.php + * @magentoDataFixture Magento_InventoryReservationCli::Test/Integration/_files/reservation_with_order_id_only.php + * @throws \Magento\Framework\Validation\ValidationException + */ + public function testReservationWithObjectId(): 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..9d73519035d5 --- /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); From f74a76d7904aa9e9e9c5e9385cc50ca9e3c23b6b Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Fri, 28 Aug 2020 16:50:13 -0500 Subject: [PATCH 2/8] Add missed test coverage for inventory inconsistencies cli command --- .../Collector.php | 2 +- .../GetSalableQuantityInconsistenciesTest.php | 16 ++++++++++- .../_files/reservation_with_order_id_only.php | 2 +- ...servation_with_order_increment_id_only.php | 28 +++++++++++++++++++ ..._with_order_increment_id_only_rollback.php | 25 +++++++++++++++++ 5 files changed, 70 insertions(+), 3 deletions(-) create mode 100644 InventoryReservationCli/Test/Integration/_files/reservation_with_order_increment_id_only.php create mode 100644 InventoryReservationCli/Test/Integration/_files/reservation_with_order_increment_id_only_rollback.php diff --git a/InventoryReservationCli/Model/SalableQuantityInconsistency/Collector.php b/InventoryReservationCli/Model/SalableQuantityInconsistency/Collector.php index fc4cb4132f77..53c16e53aca4 100644 --- a/InventoryReservationCli/Model/SalableQuantityInconsistency/Collector.php +++ b/InventoryReservationCli/Model/SalableQuantityInconsistency/Collector.php @@ -66,7 +66,7 @@ public function __construct( /** * Add reservation to collectors items * - * @param ReservationInterface $reservation + * @param ReservationInterface $reservationMagento\CatalogInventory\Helper\Stock */ public function addReservation(ReservationInterface $reservation): void { diff --git a/InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesTest.php b/InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesTest.php index 1416d51266dd..c896fd08b68c 100644 --- a/InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesTest.php +++ b/InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesTest.php @@ -127,7 +127,7 @@ public function testFindMissingReservationConfigurableProductCustomStock(): void } /** - * Verify Reservation with only object_id in metadata + * Verify Reservation with only objectId in the metadata * * @magentoDataFixture Magento/Sales/_files/order_with_shipping_and_invoice.php * @magentoDataFixture Magento_InventoryReservationCli::Test/Integration/_files/delete_reservations.php @@ -139,4 +139,18 @@ public function testReservationWithObjectId(): void $inconsistencies = $this->getSalableQuantityInconsistencies->execute(); self::assertSame([], $inconsistencies); } + + /** + * Verify Reservation with only objectIncrementId in the metadata + * + * @magentoDataFixture Magento/Sales/_files/order_with_shipping_and_invoice.php + * @magentoDataFixture Magento_InventoryReservationCli::Test/Integration/_files/delete_reservations.php + * @magentoDataFixture Magento_InventoryReservationCli::Test/Integration/_files/reservation_with_order_increment_id_only.php + * @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 index 9d73519035d5..13bdbc3fab99 100644 --- a/InventoryReservationCli/Test/Integration/_files/reservation_with_order_id_only.php +++ b/InventoryReservationCli/Test/Integration/_files/reservation_with_order_id_only.php @@ -24,7 +24,7 @@ $payload = [ 'stock_id' => 1, 'sku' => 'simple', - 'quantity' => 2, + 'quantity' => -2, 'metadata' => '{"event_type":"' . SalesEventInterface::EVENT_ORDER_PLACED . '","object_type":"order","object_id":"' . (string)$order->getEntityId() . '","objectIncrementId":""}' ]; 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); From 12bdaf4b3b21909c69ede786b581efbcf2c787e0 Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Mon, 31 Aug 2020 09:24:25 -0500 Subject: [PATCH 3/8] Add missed test coverage for inventory inconsistencies cli command --- .../Model/GetSalableQuantityInconsistenciesTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesTest.php b/InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesTest.php index c896fd08b68c..7665bc919e85 100644 --- a/InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesTest.php +++ b/InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesTest.php @@ -129,7 +129,7 @@ public function testFindMissingReservationConfigurableProductCustomStock(): void /** * Verify Reservation with only objectId in the metadata * - * @magentoDataFixture Magento/Sales/_files/order_with_shipping_and_invoice.php + * @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 * @throws \Magento\Framework\Validation\ValidationException @@ -143,7 +143,7 @@ public function testReservationWithObjectId(): void /** * Verify Reservation with only objectIncrementId in the metadata * - * @magentoDataFixture Magento/Sales/_files/order_with_shipping_and_invoice.php + * @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 * @throws \Magento\Framework\Validation\ValidationException From 80fb005dd8233687430b16a9db5c9ee0fbeb3f3c Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Thu, 1 Oct 2020 09:05:23 -0500 Subject: [PATCH 4/8] Add missed test coverage for inventory inconsistencies cli command --- .../Model/SalableQuantityInconsistency/Collector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/InventoryReservationCli/Model/SalableQuantityInconsistency/Collector.php b/InventoryReservationCli/Model/SalableQuantityInconsistency/Collector.php index 53c16e53aca4..fc4cb4132f77 100644 --- a/InventoryReservationCli/Model/SalableQuantityInconsistency/Collector.php +++ b/InventoryReservationCli/Model/SalableQuantityInconsistency/Collector.php @@ -66,7 +66,7 @@ public function __construct( /** * Add reservation to collectors items * - * @param ReservationInterface $reservationMagento\CatalogInventory\Helper\Stock + * @param ReservationInterface $reservation */ public function addReservation(ReservationInterface $reservation): void { From 0ca7ee31abc24558f105434c60e490225c80370f Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Thu, 1 Oct 2020 10:33:27 -0500 Subject: [PATCH 5/8] Add missed test coverage for inventory inconsistencies cli command --- ...enciesWithDifferentOrderIdentitiesTest.php | 64 +++++++++++++++++++ .../GetSalableQuantityInconsistenciesTest.php | 28 -------- 2 files changed, 64 insertions(+), 28 deletions(-) create mode 100644 InventoryReservationCli/Test/Integration/Model/GetSalabaleInconsistenciesWithDifferentOrderIdentitiesTest.php diff --git a/InventoryReservationCli/Test/Integration/Model/GetSalabaleInconsistenciesWithDifferentOrderIdentitiesTest.php b/InventoryReservationCli/Test/Integration/Model/GetSalabaleInconsistenciesWithDifferentOrderIdentitiesTest.php new file mode 100644 index 000000000000..90e19761b489 --- /dev/null +++ b/InventoryReservationCli/Test/Integration/Model/GetSalabaleInconsistenciesWithDifferentOrderIdentitiesTest.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/Model/GetSalableQuantityInconsistenciesTest.php b/InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesTest.php index 7665bc919e85..116f2b5204b9 100644 --- a/InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesTest.php +++ b/InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesTest.php @@ -125,32 +125,4 @@ public function testFindMissingReservationConfigurableProductCustomStock(): void $items = reset($inconsistencies)->getItems(); self::assertEquals(3, $items['simple_10']); } - - /** - * 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 - * @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 - * @throws \Magento\Framework\Validation\ValidationException - */ - public function testReservationWithObjectIncrementId(): void - { - $inconsistencies = $this->getSalableQuantityInconsistencies->execute(); - self::assertSame([], $inconsistencies); - } } From 336b5f330ead8fb304676cbb4a615cf2a6493f83 Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Thu, 1 Oct 2020 11:41:07 -0500 Subject: [PATCH 6/8] Add missed test coverage for inventory inconsistencies cli command --- ...leQuantityInconsistenciesWithDifferentOrderIdentitiesTest.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename InventoryReservationCli/Test/Integration/Model/{GetSalabaleInconsistenciesWithDifferentOrderIdentitiesTest.php => GetSalableQuantityInconsistenciesWithDifferentOrderIdentitiesTest.php} (100%) diff --git a/InventoryReservationCli/Test/Integration/Model/GetSalabaleInconsistenciesWithDifferentOrderIdentitiesTest.php b/InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesWithDifferentOrderIdentitiesTest.php similarity index 100% rename from InventoryReservationCli/Test/Integration/Model/GetSalabaleInconsistenciesWithDifferentOrderIdentitiesTest.php rename to InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesWithDifferentOrderIdentitiesTest.php From b4223a86e016c36412ac77084bce9808e098f496 Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Thu, 1 Oct 2020 14:50:53 -0500 Subject: [PATCH 7/8] Add missed test coverage for inventory inconsistencies cli command --- ...uantityInconsistenciesWithDifferentOrderIdentitiesTest.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesWithDifferentOrderIdentitiesTest.php b/InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesWithDifferentOrderIdentitiesTest.php index 90e19761b489..ff746e266c73 100644 --- a/InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesWithDifferentOrderIdentitiesTest.php +++ b/InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesWithDifferentOrderIdentitiesTest.php @@ -36,8 +36,6 @@ protected function setUp(): void * @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 @@ -52,8 +50,6 @@ public function testReservationWithObjectId(): void * @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 From 21d96f7f5703c746c7f67f82cfb2eb50021f19ad Mon Sep 17 00:00:00 2001 From: Oleksandr Iegorov Date: Fri, 2 Oct 2020 09:04:59 -0500 Subject: [PATCH 8/8] Add missed test coverage for inventory inconsistencies cli command --- ...uantityInconsistenciesWithDifferentOrderIdentitiesTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesWithDifferentOrderIdentitiesTest.php b/InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesWithDifferentOrderIdentitiesTest.php index ff746e266c73..90e19761b489 100644 --- a/InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesWithDifferentOrderIdentitiesTest.php +++ b/InventoryReservationCli/Test/Integration/Model/GetSalableQuantityInconsistenciesWithDifferentOrderIdentitiesTest.php @@ -36,6 +36,8 @@ protected function setUp(): void * @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 @@ -50,6 +52,8 @@ public function testReservationWithObjectId(): void * @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