- Timestamp:
- 11/03/2016 08:04:59 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/rest-users-controller.php
r39105 r39126 1155 1155 $this->assertEquals( 200, $response->get_status() ); 1156 1156 $data = $response->get_data(); 1157 $this->assertEquals( 'Deleted User', $data['name'] ); 1157 $this->assertTrue( $data['deleted'] ); 1158 $this->assertEquals( 'Deleted User', $data['previous']['name'] ); 1159 } 1160 1161 public function test_delete_item_no_trash() { 1162 $user_id = $this->factory->user->create( array( 'display_name' => 'Deleted User' ) ); 1163 1164 $this->allow_user_to_manage_multisite(); 1165 wp_set_current_user( self::$user ); 1166 1167 $userdata = get_userdata( $user_id ); // cache for later 1168 1169 $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) ); 1170 $response = $this->server->dispatch( $request ); 1171 $this->assertErrorResponse( 'rest_trash_not_supported', $response, 501 ); 1172 1173 $request->set_param( 'force', 'false' ); 1174 $response = $this->server->dispatch( $request ); 1175 $this->assertErrorResponse( 'rest_trash_not_supported', $response, 501 ); 1176 1177 // Ensure the user still exists 1178 $user = get_user_by( 'id', $user_id ); 1179 $this->assertNotEmpty( $user ); 1158 1180 } 1159 1181 … … 1171 1193 $this->assertEquals( 200, $response->get_status() ); 1172 1194 $data = $response->get_data(); 1173 $this->assertEquals( 'Deleted User', $data['name'] ); 1174 } 1175 1176 public function test_delete_item_no_trash() { 1177 $user_id = $this->factory->user->create( array( 'display_name' => 'Deleted User' ) ); 1178 1179 $this->allow_user_to_manage_multisite(); 1180 wp_set_current_user( self::$user ); 1181 1182 $userdata = get_userdata( $user_id ); // cache for later 1183 $request = new WP_REST_Request( 'DELETE', sprintf( '/wp/v2/users/%d', $user_id ) ); 1184 $response = $this->server->dispatch( $request ); 1185 $this->assertErrorResponse( 'rest_trash_not_supported', $response, 501 ); 1186 1187 // Ensure the user still exists 1188 $user = get_user_by( 'id', $user_id ); 1189 $this->assertNotEmpty( $user ); 1195 $this->assertTrue( $data['deleted'] ); 1196 $this->assertEquals( 'Deleted User', $data['previous']['name'] ); 1190 1197 } 1191 1198 1192 1199 public function test_delete_current_item_no_trash() { 1193 $user_id = $this->factory->user->create( array( 'role' => 'administrator' ) );1200 $user_id = $this->factory->user->create( array( 'role' => 'administrator', 'display_name' => 'Deleted User' ) ); 1194 1201 1195 1202 wp_set_current_user( $user_id ); … … 1197 1204 update_site_option( 'site_admins', array( $user->user_login ) ); 1198 1205 1199 $userdata = get_userdata( $user_id ); // cache for later1200 1206 $request = new WP_REST_Request( 'DELETE', '/wp/v2/users/me' ); 1207 $response = $this->server->dispatch( $request ); 1208 $this->assertErrorResponse( 'rest_trash_not_supported', $response, 501 ); 1209 1210 $request->set_param( 'force', 'false' ); 1201 1211 $response = $this->server->dispatch( $request ); 1202 1212 $this->assertErrorResponse( 'rest_trash_not_supported', $response, 501 );
Note: See TracChangeset
for help on using the changeset viewer.