public function RoleExpireApiTest::testRoleExpireSetGet in Role Expire 8
Same name and namespace in other branches
- 2.x tests/src/Functional/RoleExpireApiTest.php \Drupal\Tests\role_expire\Functional\RoleExpireApiTest::testRoleExpireSetGet()
Tests setter and getter for expiration of a role.
File
- tests/
src/ Functional/ RoleExpireApiTest.php, line 57
Class
- RoleExpireApiTest
- Tests that the Role expire API works.
Namespace
Drupal\Tests\role_expire\FunctionalCode
public function testRoleExpireSetGet() {
$account = $this
->drupalCreateUser([
'administer role expire',
]);
$this
->drupalLogin($account);
$account_id = $account
->id();
// New users have no expiration time.
$saved_expiration = $this->apiService
->getUserRoleExpiryTime($account_id, 'administrator');
$this
->assertEqual('', $saved_expiration);
// Check expiration date saving process.
$expiration = strtotime('+1 year');
$saved_expiration = $this
->setAndGetExpiration($account_id, 'administrator', $expiration);
$this
->assertEqual($expiration, $saved_expiration);
$expiration = strtotime('+1 month');
$saved_expiration = $this
->setAndGetExpiration($account_id, 'administrator', $expiration);
$this
->assertEqual($expiration, $saved_expiration);
$expiration = strtotime('12 hours');
$saved_expiration = $this
->setAndGetExpiration($account_id, 'administrator', $expiration);
$this
->assertEqual($expiration, $saved_expiration);
}