You are here

public function RoleExpireApiTest::testRoleExpireDefaultDurationsSetGet in Role Expire 2.x

Same name and namespace in other branches
  1. 8 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\Functional

Code

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
    ->assertEquals('', $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
    ->assertEquals($default_duration, $saved_duration);
}