- Timestamp:
- 01/06/2018 07:28:44 PM (7 years ago)
- Location:
- branches/4.9
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.9
-
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.