- Timestamp:
- 12/17/2018 01:14:17 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/5.0 merged: 43908
- Property svn:mergeinfo changed
-
trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php
r44127 r44254 3762 3762 } 3763 3763 3764 /** 3765 * @ticket 45220 3766 */ 3767 public function test_get_additional_field_registration_null_schema() { 3768 register_rest_field( 3769 'post', 3770 'my_custom_int', 3771 array( 3772 'schema' => null, 3773 'get_callback' => array( $this, 'additional_field_get_callback' ), 3774 'update_callback' => null, 3775 ) 3776 ); 3777 $post_id = $this->factory->post->create(); 3778 3779 // 'my_custom_int' should appear because ?_fields= isn't set. 3780 $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . $post_id ); 3781 $response = $this->server->dispatch( $request ); 3782 $this->assertArrayHasKey( 'my_custom_int', $response->data ); 3783 3784 // 'my_custom_int' should appear because it's present in ?_fields=. 3785 $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . $post_id ); 3786 $request->set_param( '_fields', 'title,my_custom_int' ); 3787 $response = $this->server->dispatch( $request ); 3788 $this->assertArrayHasKey( 'my_custom_int', $response->data ); 3789 3790 // 'my_custom_int' should not appear because it's not present in ?_fields=. 3791 $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . $post_id ); 3792 $request->set_param( '_fields', 'title' ); 3793 $response = $this->server->dispatch( $request ); 3794 $this->assertArrayNotHasKey( 'my_custom_int', $response->data ); 3795 3796 global $wp_rest_additional_fields; 3797 $wp_rest_additional_fields = array(); 3798 } 3799 3764 3800 public function test_additional_field_update_errors() { 3765 3801 $schema = array(
Note: See TracChangeset
for help on using the changeset viewer.