You are here

public function UiRoleExpireTest::testRoleExpireAdminPageAction in Role Expire 2.x

Same name and namespace in other branches
  1. 8 tests/src/Functional/UiRoleExpireTest.php \Drupal\Tests\role_expire\Functional\UiRoleExpireTest::testRoleExpireAdminPageAction()

Tests that users can assign default roles to assign after each role expires.

File

tests/src/Functional/UiRoleExpireTest.php, line 89

Class

UiRoleExpireTest
Tests that the Role expire interface is available.

Namespace

Drupal\Tests\role_expire\Functional

Code

public function testRoleExpireAdminPageAction() {
  $account = $this
    ->drupalCreateUser([
    'administer permissions',
    'administer role expire',
  ]);
  $this
    ->drupalLogin($account);

  // Create two roles.
  $this
    ->createRoleWithOptionalExpirationUI('test role', 'test_role');
  $this
    ->createRoleWithOptionalExpirationUI('test role two', 'test_role_two');

  // We assign a role to assign after each role expires.
  $test_def = 'test_role_two';
  $test_two_def = 'test_role';
  $this
    ->drupalGet('admin/config/people/role-expire');
  $this
    ->getSession()
    ->getPage()
    ->selectFieldOption('edit-test-role', $test_def);
  $this
    ->getSession()
    ->getPage()
    ->selectFieldOption('edit-test-role-two', $test_two_def);
  $this
    ->getSession()
    ->getPage()
    ->pressButton('Save configuration');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->drupalGet('admin/config/people/role-expire');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $stored_value = $this
    ->getSession()
    ->getPage()
    ->findField('edit-test-role')
    ->getValue();
  $this
    ->assertEquals($test_def, $stored_value);
  $stored_value = $this
    ->getSession()
    ->getPage()
    ->findField('edit-test-role-two')
    ->getValue();
  $this
    ->assertEquals($test_two_def, $stored_value);
}