Merge pull request #21164 from woocommerce/fix/21144-2
Added test for _fields query param for system_status endpoint.
This commit is contained in:
commit
33a5337397
|
@ -376,4 +376,36 @@ class WC_Tests_REST_System_Status extends WC_REST_Unit_Test_Case {
|
|||
$this->assertNotEmpty( get_post_meta( $order2->get_id(), '_shipping_address_index', true ) );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Test system_status _filter query parameter.
|
||||
*/
|
||||
public function test_get_system_status_info_filtered() {
|
||||
wp_set_current_user( $this->user );
|
||||
$query_params = array(
|
||||
'_fields' => 'theme,settings,nonexisting',
|
||||
);
|
||||
$request = new WP_REST_Request( 'GET', '/wc/v3/system_status' );
|
||||
$request->set_query_params( $query_params );
|
||||
$response = $this->server->dispatch( $request );
|
||||
$data = $response->get_data();
|
||||
|
||||
$this->assertEquals( 200, $response->get_status() );
|
||||
$this->assertEquals( 2, count( $data ) );
|
||||
|
||||
// Selected fields returned in the response.
|
||||
$this->assertArrayHasKey( 'theme', $data );
|
||||
$this->assertArrayHasKey( 'settings', $data );
|
||||
|
||||
// Fields not selected omitted from response.
|
||||
$this->assertArrayNotHasKey( 'environment', $data );
|
||||
$this->assertArrayNotHasKey( 'database', $data );
|
||||
$this->assertArrayNotHasKey( 'active_plugins', $data );
|
||||
$this->assertArrayNotHasKey( 'security', $data );
|
||||
$this->assertArrayNotHasKey( 'pages', $data );
|
||||
|
||||
// Non existing field is ignored.
|
||||
$this->assertArrayNotHasKey( 'nonexisting', $data );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue