- Timestamp:
- 09/30/2025 05:05:21 PM (12 months ago)
- Location:
- branches/5.2
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
tests/phpunit/tests/rest-api/rest-posts-controller.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/5.2
- Property svn:mergeinfo changed
/trunk merged: 60814-60816
- Property svn:mergeinfo changed
-
branches/5.2/tests/phpunit/tests/rest-api/rest-posts-controller.php
r50729 r60834 4314 4314 4315 4315 /** 4316 * @group 1018470 4317 */ 4318 public function test_cannot_get_other_users_single_post_with_edit_context_if_disallowed() { 4319 $author_post = self::factory()->post->create( 4320 array( 4321 'post_password' => 'test', 4322 'post_author' => self::$author_id, 4323 ) 4324 ); 4325 4326 wp_set_current_user( self::$contributor_id ); 4327 4328 $request = new WP_REST_Request( 'GET', '/wp/v2/posts/' . $author_post ); 4329 $request->set_query_params( array( 'context' => 'edit' ) ); 4330 $response = rest_do_request( $request ); 4331 4332 $this->assertErrorResponse( 'rest_forbidden_context', $response, 403, 'Contributor should not be able to access Author post with edit context' ); 4333 } 4334 4335 /** 4336 * @group 1018470 4337 */ 4338 public function test_cannot_see_other_users_post_in_collection_with_edit_context_if_disallowed() { 4339 $author_post = self::factory()->post->create( 4340 array( 4341 'post_password' => 'test', 4342 'post_author' => self::$author_id, 4343 ) 4344 ); 4345 4346 wp_set_current_user( self::$contributor_id ); 4347 4348 $request = new WP_REST_Request( 'GET', '/wp/v2/posts' ); 4349 $request->set_query_params( 4350 array( 4351 'context' => 'edit', 4352 'include' => $author_post, 4353 ) 4354 ); 4355 $response = rest_do_request( $request ); 4356 $data = $response->get_data(); 4357 4358 $this->assertIsArray( $data ); 4359 $this->assertEmpty( $data ); 4360 } 4361 4362 /** 4316 4363 * Internal function used to disable an insert query which 4317 4364 * will trigger a wpdb error for testing purposes.
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)