Ensure order ordering in order filter unit test (#38680)
* Ensure order ordering in order filter unit test * remove unused variable, fix spacing --------- Co-authored-by: Ron Rennick <ronald.rennick@automattic.com>
This commit is contained in:
parent
90e4ddbf29
commit
42261ed77f
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
|
||||
Ensure order ordering in order filter unit test
|
|
@ -181,6 +181,7 @@ class OrdersTableQueryTests extends WC_Unit_Test_Case {
|
|||
*/
|
||||
public function test_query_filters() {
|
||||
$order1 = new \WC_Order();
|
||||
$order1->set_date_created( time() - HOUR_IN_SECONDS );
|
||||
$order1->save();
|
||||
|
||||
$order2 = new \WC_Order();
|
||||
|
@ -198,10 +199,10 @@ class OrdersTableQueryTests extends WC_Unit_Test_Case {
|
|||
$this->assertCount( 0, wc_get_orders( array() ) );
|
||||
remove_all_filters( 'woocommerce_orders_table_query_clauses' );
|
||||
|
||||
// Force a query that sorts orders by id DESC (as opposed to the default date ASC) if a query arg is present.
|
||||
$filter_callback = function( $clauses, $query, $query_args ) use ( $order1 ) {
|
||||
// Force a query that sorts orders by id ASC (as opposed to the default date DESC) if a query arg is present.
|
||||
$filter_callback = function( $clauses, $query, $query_args ) {
|
||||
if ( ! empty( $query_args['my_custom_arg'] ) ) {
|
||||
$clauses['orderby'] = $query->get_table_name( 'orders' ) . '.id DESC';
|
||||
$clauses['orderby'] = $query->get_table_name( 'orders' ) . '.id ASC';
|
||||
}
|
||||
|
||||
return $clauses;
|
||||
|
@ -211,7 +212,8 @@ class OrdersTableQueryTests extends WC_Unit_Test_Case {
|
|||
$this->assertEquals(
|
||||
wc_get_orders(
|
||||
array(
|
||||
'return' => 'ids',
|
||||
'return' => 'ids',
|
||||
'my_custom_arg' => true,
|
||||
)
|
||||
),
|
||||
array(
|
||||
|
@ -222,8 +224,7 @@ class OrdersTableQueryTests extends WC_Unit_Test_Case {
|
|||
$this->assertEquals(
|
||||
wc_get_orders(
|
||||
array(
|
||||
'return' => 'ids',
|
||||
'my_custom_arg' => true,
|
||||
'return' => 'ids',
|
||||
)
|
||||
),
|
||||
array(
|
||||
|
|
Loading…
Reference in New Issue