You are here

public function PermissionTest::testPermission in Create user permission 2.x

Tests password strength widget.

File

tests/src/Functional/PermissionTest.php, line 29

Class

PermissionTest
Tests the JavaScript functionality of the Create user permission module.

Namespace

Drupal\Tests\create_user_permission\Functional

Code

public function testPermission() {
  $create_user = $this
    ->drupalCreateUser([
    'create users',
  ]);
  $admin_user = $this
    ->drupalCreateUser([
    'administer users',
  ]);

  // Log in the one with the "old" permission.
  $this
    ->drupalLogin($admin_user);
  $this
    ->drupalGet('admin/people/create');

  // Should now require another permission.
  $this
    ->assertSession()
    ->statusCodeEquals(403);
  $this
    ->drupalLogout();

  // Then log in the one that has the permission.
  $this
    ->drupalLogin($create_user);
  $this
    ->drupalGet('admin/people/create');

  // Should have access.
  $this
    ->assertSession()
    ->statusCodeEquals(200);
}