public function RoleExpireApiTest::testRoleExpireDefaultDurationsSetGet in Role Expire 8
Same name and namespace in other branches
- 2.x tests/src/Functional/RoleExpireApiTest.php \Drupal\Tests\role_expire\Functional\RoleExpireApiTest::testRoleExpireDefaultDurationsSetGet()
Tests setter and getter for default durations of a role.
File
- tests/
src/ Functional/ RoleExpireApiTest.php, line 83
Class
- RoleExpireApiTest
- Tests that the Role expire API works.
Namespace
Drupal\Tests\role_expire\FunctionalCode
public function testRoleExpireDefaultDurationsSetGet() {
$account = $this
->drupalCreateUser([
'administer role expire',
]);
$this
->drupalLogin($account);
$account_id = $account
->id();
// Initially roles have no default duration time.
$saved_duration = $this->apiService
->getDefaultDuration('administrator');
$this
->assertEqual('', $saved_duration);
// Check default duration saving process.
$default_duration = 'last day of month';
$this->apiService
->setDefaultDuration('administrator', $default_duration);
$saved_duration = $this->apiService
->getDefaultDuration('administrator');
$this
->assertEqual($default_duration, $saved_duration);
}