- Timestamp:
- 01/01/2018 02:30:39 AM (7 years ago)
- Location:
- trunk/tests/phpunit/tests/rest-api
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-attachments-controller.php
r42343 r42423 525 525 } 526 526 527 public function test_get_item_private_post () {527 public function test_get_item_private_post_not_authenticated() { 528 528 wp_set_current_user( 0 ); 529 529 $draft_post = $this->factory->post->create( array( 'post_status' => 'draft' ) ); … … 536 536 $request = new WP_REST_Request( 'GET', '/wp/v2/media/' . $id1 ); 537 537 $response = $this->server->dispatch( $request ); 538 $this->assertEquals( 40 3, $response->get_status() );538 $this->assertEquals( 401, $response->get_status() ); 539 539 } 540 540 … … 554 554 } 555 555 556 public function test_get_item_auto_status_with_invalid_parent_ returns_error() {556 public function test_get_item_auto_status_with_invalid_parent_not_authenticated_returns_error() { 557 557 $attachment_id = $this->factory->attachment->create_object( 558 558 $this->test_file, REST_TESTS_IMPOSSIBLY_HIGH_NUMBER, array( … … 565 565 $response = $this->server->dispatch( $request ); 566 566 567 $this->assertErrorResponse( 'rest_forbidden', $response, 40 3);567 $this->assertErrorResponse( 'rest_forbidden', $response, 401 ); 568 568 } 569 569 -
trunk/tests/phpunit/tests/rest-api/rest-posts-controller.php
r42343 r42423 1328 1328 } 1329 1329 1330 public function test_get_post_ without_permission() {1330 public function test_get_post_draft_status_not_authenicated() { 1331 1331 $draft_id = $this->factory->post->create( 1332 1332 array( … … 1339 1339 $response = $this->server->dispatch( $request ); 1340 1340 1341 $this->assertErrorResponse( 'rest_forbidden', $response, 40 3);1341 $this->assertErrorResponse( 'rest_forbidden', $response, 401 ); 1342 1342 } 1343 1343 … … 1465 1465 } 1466 1466 1467 public function test_get_item_read_permission_custom_post_status () {1467 public function test_get_item_read_permission_custom_post_status_not_authenticated() { 1468 1468 register_post_status( 'testpubstatus', array( 'public' => true ) ); 1469 1469 register_post_status( 'testprivtatus', array( 'public' => false ) ); … … 1487 1487 $request = new WP_REST_Request( 'GET', sprintf( '/wp/v2/posts/%d', self::$post_id ) ); 1488 1488 $response = $this->server->dispatch( $request ); 1489 $this->assertEquals( 40 3, $response->get_status() );1489 $this->assertEquals( 401, $response->get_status() ); 1490 1490 } 1491 1491 -
trunk/tests/phpunit/tests/rest-api/rest-settings-controller.php
r42359 r42423 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 ) { … … 19 21 ) 20 22 ); 23 24 self::$author = $factory->user->create( 25 array( 26 'role' => 'author', 27 ) 28 ); 21 29 } 22 30 23 31 public static function wpTearDownAfterClass() { 24 32 self::delete_user( self::$administrator ); 33 self::delete_user( self::$author ); 25 34 } 26 35 … … 46 55 } 47 56 48 public function test_get_item_is_not_public() { 57 public function test_get_item_is_not_public_not_authenticated() { 58 $request = new WP_REST_Request( 'GET', '/wp/v2/settings' ); 59 $response = $this->server->dispatch( $request ); 60 $this->assertEquals( 401, $response->get_status() ); 61 } 62 63 public function test_get_item_is_not_public_no_permission() { 64 wp_set_current_user( self::$author ); 49 65 $request = new WP_REST_Request( 'GET', '/wp/v2/settings' ); 50 66 $response = $this->server->dispatch( $request ); -
trunk/tests/phpunit/tests/rest-api/rest-taxonomies-controller.php
r42343 r42423 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() { 119 register_taxonomy( 'api-private', 'post', array( 'public' => false ) ); 120 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 ); 105 128 register_taxonomy( 'api-private', 'post', array( 'public' => false ) ); 106 129
Note: See TracChangeset
for help on using the changeset viewer.