function EntityKernelTestBase::createUser
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Entity/EntityKernelTestBase.php \Drupal\KernelTests\Core\Entity\EntityKernelTestBase::createUser()
- 8.9.x core/tests/Drupal/KernelTests/Core/Entity/EntityKernelTestBase.php \Drupal\KernelTests\Core\Entity\EntityKernelTestBase::createUser()
- 11.x core/tests/Drupal/KernelTests/Core/Entity/EntityKernelTestBase.php \Drupal\KernelTests\Core\Entity\EntityKernelTestBase::createUser()
Creates a user.
Parameters
array $permissions: Array of permission names to assign to user. Note that the user always has the default permissions derived from the "authenticated users" role.
string $name: The user name.
bool $admin: (optional) Whether the user should be an administrator with all the available permissions.
array $values: (optional) An array of initial user field values.
Return value
\Drupal\user\Entity\User The created user entity.
52 calls to EntityKernelTestBase::createUser()
- CommentDefaultFormatterCacheTagsTest::setUp in core/
modules/ comment/ tests/ src/ Kernel/ CommentDefaultFormatterCacheTagsTest.php - CommentDefaultFormatterCacheTagsTest::testCacheTags in core/
modules/ comment/ tests/ src/ Kernel/ CommentDefaultFormatterCacheTagsTest.php - Tests the bubbling of cache tags.
- CommentFieldAccessTest::testAccessToAdministrativeFields in core/
modules/ comment/ tests/ src/ Kernel/ CommentFieldAccessTest.php - Tests permissions on comment fields.
- ContentEntityChangedTest::testChanged in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ ContentEntityChangedTest.php - Tests basic EntityChangedInterface functionality.
- ContentEntityChangedTest::testRevisionChanged in core/
tests/ Drupal/ KernelTests/ Core/ Entity/ ContentEntityChangedTest.php - Tests revisionable EntityChangedInterface functionality.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Entity/ EntityKernelTestBase.php, line 111
Class
- EntityKernelTestBase
- Defines an abstract test base for entity kernel tests.
Namespace
Drupal\KernelTests\Core\EntityCode
protected function createUser(array $permissions = [], $name = NULL, bool $admin = FALSE, array $values = []) {
// Allow for the old signature of this method:
// createUser($values = [], $permissions = [])
if (!array_is_list($permissions)) {
// An array with keys is assumed to be entity values rather than
// permissions, since there is no point in an array of permissions having
// keys.
@trigger_error('Calling createUser() with $values as the first parameter is deprecated in drupal:10.1.0 and will be removed from drupal:11.0.0. Use createUser(array $permissions = [], $name = NULL, $admin = FALSE, array $values = []) instead. See https://www.drupal.org/node/3330762', E_USER_DEPRECATED);
$values = $permissions;
$permissions = [];
}
if (is_array($name)) {
// If $name is an array rather than a string, then the caller is intending
// to pass in $permissions.
@trigger_error('Calling createUser() with $permissions as the second parameter is deprecated in drupal:10.1.0 and will be removed from drupal:11.0.0. Use createUser(array $permissions = [], $name = NULL, $admin = FALSE, array $values = []) instead. See https://www.drupal.org/node/3330762', E_USER_DEPRECATED);
$permissions = $name;
$name = NULL;
}
return $this->drupalCreateUser($permissions, $name, $admin, $values);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.