File
- drupal/core/modules/user/lib/Drupal/user/Tests/UserSearchTest.php, line 32
- Definition of Drupal\user\Tests\UserSearchTest.
Class
- UserSearchTest
- Test user search.
Namespace
Drupal\user\Tests
Code
function testUserSearch() {
$user1 = $this
->drupalCreateUser(array(
'access user profiles',
'search content',
'use advanced search',
));
$this
->drupalLogin($user1);
$keys = $user1->mail;
$edit = array(
'keys' => $keys,
);
$this
->drupalPost('search/user/', $edit, t('Search'));
$this
->assertNoText($keys);
$this
->drupalLogout();
$user2 = $this
->drupalCreateUser(array(
'administer users',
'access user profiles',
'search content',
'use advanced search',
));
$this
->drupalLogin($user2);
$keys = $user2->mail;
$edit = array(
'keys' => $keys,
);
$this
->drupalPost('search/user/', $edit, t('Search'));
$this
->assertText($keys);
$blocked_user = $this
->drupalCreateUser();
$blocked_user->status = 0;
$blocked_user
->save();
$edit = array(
'keys' => $blocked_user->name,
);
$this
->drupalPost('search/user/', $edit, t('Search'));
$this
->assertText($blocked_user->name, 'Blocked users are listed on the user search results for users with the "administer users" permission.');
$this
->drupalLogin($user1);
$edit = array(
'keys' => $blocked_user->name,
);
$this
->drupalPost('search/user/', $edit, t('Search'));
$this
->assertNoText($blocked_user->name, 'Blocked users are hidden from the user search results.');
$this
->drupalLogout();
}