function UserEditTest::testUserWith0Password

Same name in other branches
  1. 9 core/modules/user/tests/src/Functional/UserEditTest.php \Drupal\Tests\user\Functional\UserEditTest::testUserWith0Password()
  2. 8.9.x core/modules/user/tests/src/Functional/UserEditTest.php \Drupal\Tests\user\Functional\UserEditTest::testUserWith0Password()
  3. 11.x core/modules/user/tests/src/Functional/UserEditTest.php \Drupal\Tests\user\Functional\UserEditTest::testUserWith0Password()

Tests setting the password to "0".

We discovered in https://www.drupal.org/node/2563751 that logging in with a password that is literally "0" was not possible. This test ensures that this regression can't happen again.

File

core/modules/user/tests/src/Functional/UserEditTest.php, line 150

Class

UserEditTest
Tests user edit page.

Namespace

Drupal\Tests\user\Functional

Code

public function testUserWith0Password() : void {
    $admin = $this->drupalCreateUser([
        'administer users',
    ]);
    $this->drupalLogin($admin);
    // Create a regular user.
    $user1 = $this->drupalCreateUser([]);
    $edit = [
        'pass[pass1]' => '0',
        'pass[pass2]' => '0',
    ];
    $this->drupalGet("user/" . $user1->id() . "/edit");
    $this->submitForm($edit, 'Save');
    $this->assertSession()
        ->pageTextContains("The changes have been saved.");
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.