mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-14 01:24:27 +00:00
REST API: Limit search_columns for users without list_users.
Props Vortfu, jorbin, joehoyle, timothyblynjacobs, peterwilsoncc, ehtis. git-svn-id: https://develop.svn.wordpress.org/trunk@56833 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -691,6 +691,25 @@ class WP_Test_REST_Users_Controller extends WP_Test_REST_Controller_Testcase {
|
||||
$this->assertSame( $adam_id, $data[0]['id'] );
|
||||
}
|
||||
|
||||
public function test_get_items_search_fields() {
|
||||
$request = new WP_REST_Request( 'GET', '/wp/v2/users' );
|
||||
$request->set_param( 'search', 'yololololo' );
|
||||
$response = rest_get_server()->dispatch( $request );
|
||||
$this->assertCount( 0, $response->get_data() );
|
||||
|
||||
$yolo_id = self::factory()->user->create( array( 'user_email' => 'yololololo@example.localhost' ) );
|
||||
|
||||
wp_set_current_user( self::$user );
|
||||
$request = new WP_REST_Request( 'GET', '/wp/v2/users' );
|
||||
$request->set_param( 'search', 'yololololo' );
|
||||
$response = rest_get_server()->dispatch( $request );
|
||||
$this->assertCount( 1, $response->get_data() );
|
||||
|
||||
wp_set_current_user( self::$editor );
|
||||
$response = rest_get_server()->dispatch( $request );
|
||||
$this->assertCount( 0, $response->get_data() );
|
||||
}
|
||||
|
||||
public function test_get_items_slug_query() {
|
||||
wp_set_current_user( self::$user );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user