AssertRoleExpireTrait.php in Role Expire 2.x
File
tests/src/Traits/AssertRoleExpireTrait.php
View source
<?php
namespace Drupal\Tests\role_expire\Traits;
trait AssertRoleExpireTrait {
protected function setAndGetExpiration($account_id, $rid, $expiration) {
$this->apiService
->writeRecord($account_id, $rid, $expiration);
$saved_expiration = $this->apiService
->getUserRoleExpiryTime($account_id, $rid);
return $saved_expiration;
}
protected function createRoleWithOptionalExpirationUI($roleName, $rid, $expiration = '') {
$this
->drupalGet('admin/people/roles/add');
$this
->getSession()
->getPage()
->fillField('Role name', $roleName);
$this
->getSession()
->getPage()
->fillField('Machine-readable name', $rid);
if (!empty($expiration)) {
$this
->getSession()
->getPage()
->fillField('Default duration for the role', $expiration);
}
$this
->getSession()
->getPage()
->pressButton('Save');
$this
->assertSession()
->statusCodeEquals(200);
}
}