Add test for upshifting child orders.

This commit is contained in:
Vedanshu Jain 2023-01-02 17:03:06 +05:30
parent 69629aca0b
commit b9fd1b8129
1 changed files with 19 additions and 0 deletions

View File

@ -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.
*/