Make WordPress Core


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

Grouped merges for 5.2.10.

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

Merges [50717] to the 5.2 branch.

Location:
branches/5.2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/5.2

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

    r44933 r50729  
    14521452
    14531453        $this->assertErrorResponse( 'rest_forbidden', $response, 401 );
     1454    }
     1455
     1456    public function test_get_post_draft_edit_context() {
     1457        $post_content = 'Hello World!';
     1458        $this->factory->post->create(
     1459            array(
     1460                'post_title'    => 'Hola',
     1461                'post_password' => 'password',
     1462                'post_content'  => $post_content,
     1463                'post_excerpt'  => $post_content,
     1464                'post_author'   => self::$editor_id,
     1465            )
     1466        );
     1467        $draft_id = $this->factory->post->create(
     1468            array(
     1469                'post_status'  => 'draft',
     1470                'post_author'  => self::$contributor_id,
     1471                'post_content' => '<!-- wp:latest-posts {"displayPostContent":true} /--> <!-- wp:latest-posts {"displayPostContent":true,"displayPostContentRadio":"full_post"} /-->',
     1472            )
     1473        );
     1474        wp_set_current_user( self::$contributor_id );
     1475        $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', $draft_id ) );
     1476        $request->set_param( 'context', 'edit' );
     1477        $response = rest_get_server()->dispatch( $request );
     1478        $data     = $response->get_data();
     1479        $this->assertNotContains( $post_content, $data['content']['rendered'] );
    14541480    }
    14551481
Note: See TracChangeset for help on using the changeset viewer.