Creates an user with admin permissions and log in.
array $additional_permissions: Additional permissions that will be granted to admin user.
bool $reset_permissions: Flag to determine if default admin permissions will be replaced by $additional_permissions.
object Newly created and logged in user object.
function loginAsAdmin($additional_permissions = [], $reset_permissions = FALSE) {
$permissions = $this->admin_permissions;
if ($reset_permissions) {
$permissions = $additional_permissions;
}
elseif (!empty($additional_permissions)) {
$permissions = array_merge($permissions, $additional_permissions);
}
$this->admin_user = $this
->drupalCreateUser($permissions);
$this
->drupalLogin($this->admin_user);
return $this->admin_user;
}