public function UiRoleExpireTest::testRoleExpireAdminPageActionDisable in Role Expire 8
Same name and namespace in other branches
- 2.x tests/src/Functional/UiRoleExpireTest.php \Drupal\Tests\role_expire\Functional\UiRoleExpireTest::testRoleExpireAdminPageActionDisable()
Tests that users can disable expiration for specific roles.
File
- tests/
src/ Functional/ UiRoleExpireTest.php, line 119
Class
- UiRoleExpireTest
- Tests that the Role expire interface is available.
Namespace
Drupal\Tests\role_expire\FunctionalCode
public function testRoleExpireAdminPageActionDisable() {
$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');
// First role enabled and second one disabled.
$test_def = 1;
$test_two_def = 0;
$this
->drupalGet('admin/config/system/role-expire');
$this
->getSession()
->getPage()
->checkField('edit-disable-test-role');
$this
->getSession()
->getPage()
->uncheckField('edit-disable-test-role-two');
$this
->getSession()
->getPage()
->pressButton('Save configuration');
$this
->assertSession()
->statusCodeEquals(200);
$this
->drupalGet('admin/config/system/role-expire');
$this
->assertSession()
->statusCodeEquals(200);
$stored_value = $this
->getSession()
->getPage()
->findField('edit-disable-test-role')
->getValue();
$this
->assertEquals($test_def, $stored_value);
$stored_value = $this
->getSession()
->getPage()
->findField('edit-disable-test-role-two')
->getValue();
$this
->assertEquals($test_two_def, $stored_value);
// Assign both roles to our user.
$this
->drupalGet('user/' . $account
->id() . '/edit');
$this
->getSession()
->getPage()
->checkField('edit-roles-test-role');
$this
->getSession()
->getPage()
->checkField('edit-roles-test-role-two');
$this
->getSession()
->getPage()
->pressButton('Save');
// Check if role expiration disabling is working as expected.
$this
->drupalGet('user/' . $account
->id() . '/edit');
$this
->assertSession()
->pageTextNotContains('test role role expiration date/time');
$this
->assertSession()
->pageTextContains('test role two role expiration date/time');
}