From b9fd1b8129c2de4cfd4b31e342efdf9f37dc51d5 Mon Sep 17 00:00:00 2001 From: Vedanshu Jain Date: Mon, 2 Jan 2023 17:03:06 +0530 Subject: [PATCH] Add test for upshifting child orders. --- .../Orders/OrdersTableDataStoreTests.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableDataStoreTests.php b/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableDataStoreTests.php index 765095fe095..3b4a8a856af 100644 --- a/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableDataStoreTests.php +++ b/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableDataStoreTests.php @@ -1899,6 +1899,25 @@ class OrdersTableDataStoreTests extends WC_Unit_Test_Case { $this->assertFalse( $should_sync_callable->call( $this->sut, $order ) ); } + /** + * @testDox When parent order is deleted, child orders should be upshifted. + */ + public function test_child_orders_are_promoted_when_parent_is_deleted() { + $this->toggle_cot( true ); + $order = new WC_Order(); + $order->save(); + + $child_order = new WC_Order(); + $child_order->set_parent_id( $order->get_id() ); + $child_order->save(); + + $this->assertEquals( $order->get_id(), $child_order->get_parent_id() ); + $this->sut->delete( $order, array( 'force_delete' => true ) ); + $child_order = wc_get_order( $child_order->get_id() ); + + $this->assertEquals( 0, $child_order->get_parent_id() ); + } + /** * @testDox Make sure get_order return false when checking an order of different order types without warning. */