| 433 | * Ensure that nested fields may be whitelisted with request['_fields']. |
| 434 | */ |
| 435 | public function test_rest_filter_response_fields_nested_field_filter() { |
| 436 | $response = new WP_REST_Response(); |
| 437 | |
| 438 | $response->set_data( array( |
| 439 | 'a' => 0, |
| 440 | 'b' => array( |
| 441 | '1' => 1, |
| 442 | '2' => 2, |
| 443 | ), |
| 444 | 'c' => 3, |
| 445 | 'd' => array( |
| 446 | '4' => 4, |
| 447 | '5' => 5, |
| 448 | ), |
| 449 | ) ); |
| 450 | $request = array( |
| 451 | '_fields' => array( 'b.1', 'c', 'd.5' ) |
| 452 | ); |
| 453 | |
| 454 | $response = rest_filter_response_fields( $response, null, $request ); |
| 455 | $this->assertEquals( array( |
| 456 | 'b' => array( |
| 457 | '1' => 1, |
| 458 | ), |
| 459 | 'c' => 3, |
| 460 | 'd' => array( |
| 461 | '5' => 5, |
| 462 | ), |
| 463 | ), $response->get_data() ); |
| 464 | } |
| 465 | |
| 466 | /** |