You are here

protected function AssertRoleExpireTrait::createRoleWithOptionalExpirationUI in Role Expire 8

Same name and namespace in other branches
  1. 2.x tests/src/Traits/AssertRoleExpireTrait.php \Drupal\Tests\role_expire\Traits\AssertRoleExpireTrait::createRoleWithOptionalExpirationUI()

Creates a role with optional expiration via UI.

Parameters

$rid: Role ID.

$roleName: Role name.

string $expiration: The strtotime-compatible duration string.

4 calls to AssertRoleExpireTrait::createRoleWithOptionalExpirationUI()
UiRoleExpireTest::testRoleExpireAdminPageAction in tests/src/Functional/UiRoleExpireTest.php
Tests that users can assign default roles to assign after each role expires.
UiRoleExpireTest::testRoleExpireAdminPageActionDisable in tests/src/Functional/UiRoleExpireTest.php
Tests that users can disable expiration for specific roles.
UiRoleExpireTest::testRoleExpireEditRoleFieldsAction in tests/src/Functional/UiRoleExpireTest.php
Tests that users can create a role with default expiration date/time.
UiRoleExpireTest::testRoleExpireEditUserFieldsAction in tests/src/Functional/UiRoleExpireTest.php
Tests that we can add a role with default expiration and assign it to a new user.

File

tests/src/Traits/AssertRoleExpireTrait.php, line 40

Class

AssertRoleExpireTrait
Adds helper functions.

Namespace

Drupal\Tests\role_expire\Traits

Code

protected function createRoleWithOptionalExpirationUI($roleName, $rid, $expiration = '') {
  $this
    ->drupalGet('admin/people/roles/add');
  $this
    ->getSession()
    ->getPage()
    ->fillField('Role name', $roleName);
  $this
    ->getSession()
    ->getPage()
    ->fillField('Machine-readable name', $rid);
  if (!empty($expiration)) {
    $this
      ->getSession()
      ->getPage()
      ->fillField('Default duration for the role', $expiration);
  }
  $this
    ->getSession()
    ->getPage()
    ->pressButton('Save');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
}