You are here

trait UserCreationTrait in Drupal 8

Same name in this branch
  1. 8 core/modules/simpletest/src/UserCreationTrait.php \Drupal\simpletest\UserCreationTrait
  2. 8 core/modules/user/tests/src/Traits/UserCreationTrait.php \Drupal\Tests\user\Traits\UserCreationTrait

Provides methods to create additional test users and switch the currently logged in one.

This trait is meant to be used only by test classes extending \Drupal\simpletest\TestBase.

Hierarchy

Deprecated

in drupal:8.4.0 and is removed from drupal:9.0.0. Use Drupal\Tests\user\Traits\UserCreationTrait instead.

See also

https://www.drupal.org/node/2884454

File

core/modules/simpletest/src/UserCreationTrait.php, line 21

Namespace

Drupal\simpletest
View source
trait UserCreationTrait {
  use BaseUserCreationTrait;

}

Members

Namesort descending Modifiers Type Description Overrides
UserCreationTrait::checkPermissions protected function Checks whether a given list of permission names is valid.
UserCreationTrait::createAdminRole protected function Creates an administrative role.
UserCreationTrait::createRole protected function Creates a role with specified permissions.
UserCreationTrait::createUser protected function Create a user with a given set of permissions.
UserCreationTrait::grantPermissions protected function Grant permissions to a user role.
UserCreationTrait::setCurrentUser protected function Switch the current logged in user.
UserCreationTrait::setUpCurrentUser protected function Creates a random user account and sets it as current user.