You are here

public function PermissionTest::testPermission in Create user permission 8

Tests password strength widget.

File

tests/src/FunctionalJavascript/PermissionTest.php, line 21

Class

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

Namespace

Drupal\Tests\create_user_permission\FunctionalJavascript

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);
}