1 user.test UserAutocompleteTestCase::testUserAutocomplete()

Tests access to user autocompletion and verify the correct results.

File

core/modules/user/tests/user.test, line 1773
Tests for user.module.

Class

UserAutocompleteTestCase
Test user autocompletion.

Code

function testUserAutocomplete() {
  // Check access from unprivileged user, should be denied.
  $this->backdropLogin($this->unprivileged_user);
  $this->backdropGet('user/autocomplete/' . $this->unprivileged_user->name[0]);
  $this->assertResponse(403, 'Autocompletion access denied to user without permission.');

  // Check access from privileged user.
  $this->backdropLogout();
  $this->backdropLogin($this->privileged_user);
  $this->backdropGet('user/autocomplete/' . $this->unprivileged_user->name[0]);
  $this->assertResponse(200, 'Autocompletion access allowed.');

  // Using first letter of the user's name, make sure the user's full name is in the results.
  $this->assertRaw($this->unprivileged_user->name, 'User name found in autocompletion results.');
}