From 64f09329dd29fb871fbd741c77a3f7d591401e58 Mon Sep 17 00:00:00 2001 From: Rodrigo Primo Date: Wed, 8 Jan 2020 15:33:42 -0300 Subject: [PATCH] Add unit test to test filtering by field when getting system status --- unit-tests/Tests/Version3/system-status.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/unit-tests/Tests/Version3/system-status.php b/unit-tests/Tests/Version3/system-status.php index ead97dd1c77..52da1e6c165 100644 --- a/unit-tests/Tests/Version3/system-status.php +++ b/unit-tests/Tests/Version3/system-status.php @@ -106,6 +106,26 @@ class WC_Tests_REST_System_Status extends WC_REST_Unit_Test_Case { $this->assertEquals( WC()->version, $environment['version'] ); } + /** + * Test to make sure that it is possible to filter + * the environment fields returned in the response. + */ + public function test_get_system_status_info_environment_filtered_by_field() { + $expected_data = array( + 'environment' => array( + 'version' => WC()->version + ) + ); + + $request = new WP_REST_Request( 'GET', '/wc/v3/system_status' ); + $request->set_query_params( array( '_fields' => 'environment.version' ) ); + + $response = $this->server->dispatch( $request ); + $data = $response->get_data(); + + $this->assertEquals( $expected_data, $data ); + } + /** * Test to make sure database response is correct. *