Skip to content
This repository has been archived by the owner on Jun 15, 2022. It is now read-only.

Commit

Permalink
Merge pull request #84 from liquidweb/fix/migration-test-issues
Browse files Browse the repository at this point in the history
Set an explicit fallback ORDER BY for the migrate command
  • Loading branch information
bswatson authored Sep 24, 2018
2 parents 65c88ef + ddd4865 commit a4034b0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion includes/class-woocommerce-custom-orders-table-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function migrate( $args = array(), $assoc_args = array() ) {
"SELECT p.ID FROM {$wpdb->posts} p LEFT JOIN " . esc_sql( $order_table ) . ' o ON p.ID = o.order_id
WHERE p.post_type IN (' . implode( ', ', array_fill( 0, count( $order_types ), '%s' ) ) . ')
AND o.order_id IS NULL
ORDER BY p.post_date DESC
ORDER BY p.post_date DESC, p.ID DESC
LIMIT %d',
array_merge( $order_types, array( $assoc_args['batch-size'] ) )
);
Expand Down
6 changes: 3 additions & 3 deletions tests/test-cli.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,11 @@ public function test_migrate_with_duplicate_ids() {
$order = wc_get_order( $order_id );
$order->get_total();

$this->assertEquals( 1, $this->count_orders_in_table_with_ids( $order_id ));
$this->assertEquals( 1, $this->count_orders_in_table_with_ids( array( $order_id ) ) );

$this->cli->migrate();

$this->assertEquals( 1, $this->count_orders_in_table_with_ids( $order_id ));
$this->assertEquals( 1, $this->count_orders_in_table_with_ids( array( $order_id ) ) );
}

public function test_migrate_aborts_if_no_orders_require_migration() {
Expand Down Expand Up @@ -263,7 +263,7 @@ public function test_migrate_output_when_items_were_skipped() {

$this->assertEquals(
2,
$this->count_orders_in_table_with_ids( array( $order1->get_id(), $order3->get_id() ) ),
$this->count_orders_in_table_with_ids( array( $order2->get_id(), $order3->get_id() ) ),
'Expected to only see two orders in the custom table.'
);

Expand Down
6 changes: 3 additions & 3 deletions tests/test-order-data-store.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ public function test_loading_a_product_can_automatically_populate_from_meta() {
$order_id = WC_Helper_Order::create_order()->get_id();
$this->toggle_use_custom_table( true );

$this->assertEquals( 0, $this->count_orders_in_table_with_ids( $order_id ) );
$this->assertEquals( 0, $this->count_orders_in_table_with_ids( array( $order_id ) ) );

$order = wc_get_order( $order_id );

$this->assertEquals( 1, $this->count_orders_in_table_with_ids( $order->get_id() ) );
$this->assertEquals( 1, $this->count_orders_in_table_with_ids( array( $order->get_id() ) ) );
}

/**
Expand All @@ -34,7 +34,7 @@ public function test_wc_custom_order_table_automatic_migration_filter() {
$order = wc_get_order( $order_id );

$this->assertEmpty( $order->get_total() );
$this->assertEquals( 0, $this->count_orders_in_table_with_ids( $order_id ) );
$this->assertEquals( 0, $this->count_orders_in_table_with_ids( array( $order_id ) ) );
}

public function test_delete() {
Expand Down

0 comments on commit a4034b0

Please sign in to comment.