Changeset 44546 for trunk/tests/phpunit/tests/rest-api/rest-controller.php
- Timestamp:
- 01/10/2019 09:05:50 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-controller.php
r43986 r44546 204 204 } 205 205 206 public function test_get_fields_for_response() { 206 /** 207 * @dataProvider data_get_fields_for_response, 208 */ 209 public function test_get_fields_for_response( $param, $expected ) { 207 210 $controller = new WP_REST_Test_Controller(); 208 211 $request = new WP_REST_Request( 'GET', '/wp/v2/testroute' ); … … 222 225 $fields 223 226 ); 224 $request->set_param( '_fields', 'somestring,someinteger');227 $request->set_param( '_fields', $param ); 225 228 $fields = $controller->get_fields_for_response( $request ); 226 $this->assertEquals( 227 array( 228 'somestring', 229 'someinteger', 229 $this->assertEquals( $expected, $fields ); 230 } 231 232 public function data_get_fields_for_response() { 233 return array( 234 array( 235 'somestring,someinteger', 236 array( 237 'somestring', 238 'someinteger', 239 ), 230 240 ), 231 $fields 241 array( 242 ',,', 243 array( 244 'somestring', 245 'someinteger', 246 'someboolean', 247 'someurl', 248 'somedate', 249 'someemail', 250 'someenum', 251 'someargoptions', 252 'somedefault', 253 ), 254 ), 232 255 ); 233 256 }
Note: See TracChangeset
for help on using the changeset viewer.