diff --git a/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableQueryTests.php b/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableQueryTests.php index ea9c31eef4a..4a741e9556a 100644 --- a/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableQueryTests.php +++ b/plugins/woocommerce/tests/php/src/Internal/DataStores/Orders/OrdersTableQueryTests.php @@ -351,16 +351,22 @@ class OrdersTableQueryTests extends WC_Unit_Test_Case { * @testdox A regular query will still work even if the pre-query escape hook returns null for the whole 3-tuple. */ public function test_pre_query_escape_hook_return_null() { + add_filter( 'woocommerce_hpos_pre_query', '__return_null', 10, 3 ); + + // Query with no results. + $query = new OrdersTableQuery(); + $this->assertNotNull( $query->orders ); + $this->assertNotNull( $query->found_orders ); + $this->assertNotNull( $query->max_num_pages ); + $this->assertCount( 0, $query->orders ); + $this->assertEquals( 0, $query->found_orders ); + $this->assertEquals( 0, $query->max_num_pages ); + + // Query with 1 result. $order1 = new \WC_Order(); $order1->set_date_created( time() - HOUR_IN_SECONDS ); $order1->save(); - $callback = function( $result, $query_object, $sql ) use ( $order1 ) { - // Just return null. - return null; - }; - add_filter( 'woocommerce_hpos_pre_query', $callback, 10, 3 ); - $query = new OrdersTableQuery(); $this->assertCount( 1, $query->orders ); $this->assertEquals( 1, $query->found_orders );