REST API: Set `orderby` parameter in tax relation unit tests added in [46646].

The default value of `date` caused a race condition resulting in random test failures.

See #44326.

git-svn-id: https://develop.svn.wordpress.org/trunk@46648 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov 2019-11-04 12:34:35 +00:00
parent ec5f1035fe
commit c04078ac9d
1 changed files with 4 additions and 2 deletions

View File

@ -978,6 +978,7 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te
$request->set_param( 'tax_relation', 'OR' ); $request->set_param( 'tax_relation', 'OR' );
$request->set_param( 'tags', array( $tag['term_id'] ) ); $request->set_param( 'tags', array( $tag['term_id'] ) );
$request->set_param( 'categories', array( $category['term_id'] ) ); $request->set_param( 'categories', array( $category['term_id'] ) );
$request->set_param( 'orderby', 'id' );
$response = rest_get_server()->dispatch( $request ); $response = rest_get_server()->dispatch( $request );
$data = $response->get_data(); $data = $response->get_data();
@ -1032,12 +1033,13 @@ class WP_Test_REST_Posts_Controller extends WP_Test_REST_Post_Type_Controller_Te
$request->set_param( 'tags', array( $tag['term_id'] ) ); $request->set_param( 'tags', array( $tag['term_id'] ) );
$request->set_param( 'categories_exclude', array( $category['term_id'] ) ); $request->set_param( 'categories_exclude', array( $category['term_id'] ) );
$request->set_param( 'tax_relation', 'OR' ); $request->set_param( 'tax_relation', 'OR' );
$request->set_param( 'orderby', 'id' );
$response = rest_get_server()->dispatch( $request ); $response = rest_get_server()->dispatch( $request );
$data = $response->get_data(); $data = $response->get_data();
$this->assertCount( 3, $data ); $this->assertCount( 3, $data );
$this->assertEquals( $id2, $data[0]['id'] ); $this->assertEquals( $id4, $data[0]['id'] );
$this->assertEquals( $id4, $data[1]['id'] ); $this->assertEquals( $id2, $data[1]['id'] );
$this->assertEquals( $id1, $data[2]['id'] ); $this->assertEquals( $id1, $data[2]['id'] );
} }