Make WordPress Core


Ignore:
Timestamp:
04/15/2021 01:10:18 AM (5 years ago)
Author:
desrosj
Message:

Grouped merges for 5.0.12.

  • REST API: Allow authors to read their own password protected posts.
  • About page update.

Merges [50717] to the 5.0 branch.

Location:
branches/5.0
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0

  • branches/5.0/tests/phpunit/tests/rest-api/rest-posts-controller.php

    r43930 r50731  
    12221222
    12231223        $this->assertErrorResponse( 'rest_forbidden', $response, 401 );
     1224    }
     1225
     1226    public function test_get_post_draft_edit_context() {
     1227        $post_content = 'Hello World!';
     1228        $this->factory->post->create(
     1229            array(
     1230                'post_title'    => 'Hola',
     1231                'post_password' => 'password',
     1232                'post_content'  => $post_content,
     1233                'post_excerpt'  => $post_content,
     1234                'post_author'   => self::$editor_id,
     1235            )
     1236        );
     1237        $draft_id = $this->factory->post->create(
     1238            array(
     1239                'post_status'  => 'draft',
     1240                'post_author'  => self::$contributor_id,
     1241                'post_content' => '<!-- wp:latest-posts {"displayPostContent":true} /--> <!-- wp:latest-posts {"displayPostContent":true,"displayPostContentRadio":"full_post"} /-->',
     1242            )
     1243        );
     1244        wp_set_current_user( self::$contributor_id );
     1245        $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', $draft_id ) );
     1246        $request->set_param( 'context', 'edit' );
     1247        $response = rest_get_server()->dispatch( $request );
     1248        $data     = $response->get_data();
     1249        $this->assertNotContains( $post_content, $data['content']['rendered'] );
    12241250    }
    12251251
Note: See TracChangeset for help on using the changeset viewer.