Skip to content

Commit

Permalink
Enhance unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgeatorres committed Mar 13, 2024
1 parent adc383d commit ba3bac2
Showing 1 changed file with 10 additions and 0 deletions.
Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -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' ) );
}

}

0 comments on commit ba3bac2

Please sign in to comment.