From 02a08e9e3bc75c4b675d753517edcf63e03783fe Mon Sep 17 00:00:00 2001 From: Vedanshu Jain Date: Wed, 14 Jun 2023 15:17:52 +0530 Subject: [PATCH] Add unit test for checking that status has the correct value. --- .../Orders/OrdersTableDataStoreTests.php | 16 ++++++++++++++++ 1 file changed, 16 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 23bcd9e8483..056b1c394ba 100644 --- a/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableDataStoreTests.php +++ b/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableDataStoreTests.php @@ -2132,4 +2132,20 @@ class OrdersTableDataStoreTests extends WC_Unit_Test_Case { $this->assertEquals( 1, $result ); } + + /** + * @testDox When saving an order, status is automatically prefixed even if it was not earlier. + */ + public function test_get_db_row_from_order_only_prefixed_status_is_written_to_db() { + $order = wc_create_order(); + + $order->set_status( 'completed' ); + $db_row_callback = function ( $order, $only_changes ) { + return $this->get_db_row_from_order( $order, $this->order_column_mapping, $only_changes ); + }; + + $db_row = $db_row_callback->call( $this->sut, $order, false ); + + $this->assertEquals( 'wc-completed', $db_row['data']['status'] ); + } }