Changeset 42427
- Timestamp:
- 01/06/2018 07:28:44 PM (7 years ago)
- Location:
- branches/4.9
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.9
-
branches/4.9/tests/phpunit/tests/rest-api/rest-attachments-controller.php
r40306 r42427 469 469 } 470 470 471 public function test_get_item_private_post () {471 public function test_get_item_private_post_not_authenticated() { 472 472 wp_set_current_user( 0 ); 473 473 $draft_post = $this->factory->post->create( array( 'post_status' => 'draft' ) ); … … 478 478 $request = new WP_REST_Request( 'GET', '/wp/v2/media/' . $id1 ); 479 479 $response = $this->server->dispatch( $request ); 480 $this->assertEquals( 40 3, $response->get_status() );480 $this->assertEquals( 401, $response->get_status() ); 481 481 } 482 482 … … 494 494 } 495 495 496 public function test_get_item_auto_status_with_invalid_parent_ returns_error() {496 public function test_get_item_auto_status_with_invalid_parent_not_authenticated_returns_error() { 497 497 $attachment_id = $this->factory->attachment->create_object( $this->test_file, REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, array( 498 498 'post_mime_type' => 'image/jpeg', … … 503 503 $response = $this->server->dispatch( $request ); 504 504 505 $this->assertErrorResponse( 'rest_forbidden', $response, 40 3);505 $this->assertErrorResponse( 'rest_forbidden', $response, 401 ); 506 506 } 507 507 -
branches/4.9/tests/phpunit/tests/rest-api/rest-posts-controller.php
r42056 r42427 1130 1130 } 1131 1131 1132 public function test_get_post_ without_permission() {1132 public function test_get_post_draft_status_not_authenicated() { 1133 1133 $draft_id = $this->factory->post->create( array( 1134 1134 'post_status' => 'draft', … … 1139 1139 $response = $this->server->dispatch( $request ); 1140 1140 1141 $this->assertErrorResponse( 'rest_forbidden', $response, 40 3);1141 $this->assertErrorResponse( 'rest_forbidden', $response, 401 ); 1142 1142 } 1143 1143 … … 1251 1251 } 1252 1252 1253 public function test_get_item_read_permission_custom_post_status () {1253 public function test_get_item_read_permission_custom_post_status_not_authenticated() { 1254 1254 register_post_status( 'testpubstatus', array( 'public' => true ) ); 1255 1255 register_post_status( 'testprivtatus', array( 'public' => false ) ); … … 1263 1263 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); 1264 1264 $response = $this->server->dispatch( $request ); 1265 $this->assertEquals( 40 3, $response->get_status() );1265 $this->assertEquals( 401, $response->get_status() ); 1266 1266 } 1267 1267 -
branches/4.9/tests/phpunit/tests/rest-api/rest-settings-controller.php
r42000 r42427 11 11 */ 12 12 class WP_Test_REST_Settings_Controller extends WP_Test_REST_Controller_Testcase { 13 13 14 protected static $administrator; 15 protected static $author; 14 16 15 17 public static function wpSetUpBeforeClass( $factory ) { … … 17 19 'role' => 'administrator', 18 20 ) ); 21 22 self::$author = $factory->user->create( 23 array( 24 'role' => 'author', 25 ) 26 ); 19 27 } 20 28 21 29 public static function wpTearDownAfterClass() { 22 30 self::delete_user( self::$administrator ); 31 self::delete_user( self::$author ); 23 32 } 24 33 … … 44 53 } 45 54 46 public function test_get_item_is_not_public() { 47 $request = new WP_REST_Request( 'GET', '/wp/v2/settings' ); 55 public function test_get_item_is_not_public_not_authenticated() { 56 $request = new WP_REST_Request( 'GET', '/wp/v2/settings' ); 57 $response = $this->server->dispatch( $request ); 58 $this->assertEquals( 401, $response->get_status() ); 59 } 60 61 public function test_get_item_is_not_public_no_permission() { 62 wp_set_current_user( self::$author ); 63 $request = new WP_REST_Request( 'GET', '/wp/v2/settings' ); 48 64 $response = $this->server->dispatch( $request ); 49 65 $this->assertEquals( 403, $response->get_status() ); -
branches/4.9/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php
r41176 r42427 11 11 */ 12 12 class WP_Test_REST_Taxonomies_Controller extends WP_Test_REST_Controller_Testcase { 13 14 protected static $contributor_id; 15 16 public static function wpSetUpBeforeClass( $factory ) { 17 self::$contributor_id = $factory->user->create( 18 array( 19 'role' => 'contributor', 20 ) 21 ); 22 } 23 24 public static function wpTearDownAfterClass() { 25 self::delete_user( self::$contributor_id ); 26 } 13 27 14 28 public function test_register_routes() { … … 102 116 } 103 117 104 public function test_get_non_public_taxonomy () {118 public function test_get_non_public_taxonomy_not_authenticated() { 105 119 register_taxonomy( 'api-private', 'post', array( 'public' => false ) ); 106 120 107 121 $request = new WP_REST_Request( 'GET', '/wp/v2/taxonomies/api-private' ); 122 $response = $this->server->dispatch( $request ); 123 $this->assertErrorResponse( 'rest_forbidden', $response, 401 ); 124 } 125 126 public function test_get_non_public_taxonomy_no_permission() { 127 wp_set_current_user( self::$contributor_id ); 128 register_taxonomy( 'api-private', 'post', array( 'public' => false ) ); 129 130 $request = new WP_REST_Request( 'GET', '/wp/v2/taxonomies/api-private' ); 108 131 $response = $this->server->dispatch( $request ); 109 132 $this->assertErrorResponse( 'rest_forbidden', $response, 403 );
Note: See TracChangeset
for help on using the changeset viewer.