From ba3bac293f423faa2930163cd37be422db418a4b Mon Sep 17 00:00:00 2001 From: Jorge Torres Date: Wed, 13 Mar 2024 18:26:52 -0300 Subject: [PATCH] Enhance unit test --- .../DataStores/Orders/LegacyDataHandlerTests.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/LegacyDataHandlerTests.php b/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/LegacyDataHandlerTests.php index d14f3509eec1..9e4aec22efab 100644 --- a/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/LegacyDataHandlerTests.php +++ b/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/LegacyDataHandlerTests.php @@ -208,7 +208,9 @@ public function test_datastore_partial_backfill() { $order_hpos = $this->sut->get_order_from_datastore( $order->get_id(), 'hpos' ); $order_hpos->set_status( 'completed' ); $order_hpos->set_billing_first_name( 'Mr. HPOS' ); + $order_hpos->set_billing_address_1( 'HPOS Street' ); $order_hpos->update_meta_data( 'my_meta', 'hpos' ); + $order_hpos->update_meta_data( 'other_meta', 'hpos' ); $order_hpos->save(); // Fetch the posts version and make sure it's different. @@ -232,6 +234,7 @@ public function test_datastore_partial_backfill() { // Update the CPT version now. $order_cpt->set_billing_first_name( 'Mr. Post' ); + $order_cpt->set_billing_address_1( 'CPT Street' ); $order_cpt->save(); // Re-load the HPOS version and confirm billing first name is different. @@ -243,6 +246,13 @@ public function test_datastore_partial_backfill() { $order_hpos = $this->sut->get_order_from_datastore( $order->get_id(), 'hpos' ); $this->assertEquals( $order_hpos->get_billing_first_name(), $order_cpt->get_billing_first_name() ); $this->assertEquals( $order_hpos->get_status(), $order_cpt->get_status() ); + + // Re-enable sync, trigger an order sync and confirm that meta/props that we didn't partially backfill already are correctly synced. + $this->enable_cot_sync(); + wc_get_container()->get( DataSynchronizer::class )->process_batch( array( $order_cpt->get_id() ) ); + $order_cpt = $this->sut->get_order_from_datastore( $order->get_id(), 'posts' ); + $this->assertEquals( $order_cpt->get_billing_address_1(), $order_hpos->get_billing_address_1() ); + $this->assertEquals( $order_cpt->get_meta( 'other_meta', true, 'edit' ), $order_hpos->get_meta( 'other_meta', true, 'edit' ) ); } }