public function FormTest::testUserLoginForm in No Autocomplete 8
Tests the log in form.
File
- tests/src/ Functional/ FormTest.php, line 29 
Class
- FormTest
- Test the form elements.
Namespace
Drupal\Tests\no_autocomplete\FunctionalCode
public function testUserLoginForm() {
  // Going to the log in.
  $this
    ->drupalGet('/user/login');
  // Checking that the autocomplete is not present.
  $this
    ->assertSession()
    ->elementNotExists('css', '#edit-pass[autocomplete]');
  // Creating a user with the module permission.
  $account = $this
    ->drupalCreateUser([
    'administer no_autocomplete',
  ]);
  // Log in.
  $this
    ->drupalLogin($account);
  // Going to the config page.
  $this
    ->drupalGet('/admin/config/people/no_autocomplete');
  // Form values to send (checking checked checkboxes).
  $edit = [
    'no_autocomplete_login_form' => 1,
  ];
  // Sending the form.
  $this
    ->drupalPostForm(NULL, $edit, 'op');
  // Log out.
  $this
    ->drupalLogout();
  // Going to the log in.
  $this
    ->drupalGet('/user/login');
  // Checking that the autocomplete is set off.
  $this
    ->assertSession()
    ->elementAttributeContains('css', '#edit-pass', 'autocomplete', 'off');
}