Changeset 54396
- Timestamp:
- 10/05/2022 02:47:07 PM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php
r54090 r54396 1955 1955 } 1956 1956 1957 /** 1958 * Tests that authenticated users are only allowed to read password protected content 1959 * if they have the 'edit_post' meta capability for the post. 1960 */ 1957 1961 public function test_get_post_draft_edit_context() { 1958 1962 $post_content = 'Hello World!'; 1963 1964 // Create a password protected post as an Editor. 1959 1965 self::factory()->post->create( 1960 1966 array( … … 1966 1972 ) 1967 1973 ); 1974 1975 // Create a draft with the Latest Posts block as a Contributor. 1968 1976 $draft_id = self::factory()->post->create( 1969 1977 array( … … 1973 1981 ) 1974 1982 ); 1983 1984 // Set the current user to Contributor and request the draft for editing. 1975 1985 wp_set_current_user( self::$contributor_id ); 1976 1986 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', $draft_id ) ); … … 1978 1988 $response = rest_get_server()->dispatch( $request ); 1979 1989 $data = $response->get_data(); 1990 1991 /* 1992 * Verify that the content of a password protected post created by an Editor 1993 * is not viewable by a Contributor. 1994 */ 1980 1995 $this->assertStringNotContainsString( $post_content, $data['content']['rendered'] ); 1981 1996 }
Note: See TracChangeset
for help on using the changeset viewer.