protected function UserProtectCreationTrait::createProtectedUser in User protect 8
Creates a protected user.
Parameters
array $protections: (optional) The active protections. Defaults to an empty array.
Return value
object The created user.
11 calls to UserProtectCreationTrait::createProtectedUser()
- FieldAccessTest::testMailAccess in tests/
src/ Kernel/ FieldAccessTest.php - Tests field access for the user's mail address.
- FieldAccessTest::testNameAccess in tests/
src/ Kernel/ FieldAccessTest.php - Tests field access for the user's name.
- FieldAccessTest::testPassAccess in tests/
src/ Kernel/ FieldAccessTest.php - Tests field access for the user's password.
- FieldAccessTest::testRolesAccess in tests/
src/ Kernel/ FieldAccessTest.php - Tests field access for the user's roles.
- FieldAccessTest::testStatusAccess in tests/
src/ Kernel/ FieldAccessTest.php - Tests field access for the user's status.
File
- tests/
src/ Traits/ UserProtectCreationTrait.php, line 48
Class
- UserProtectCreationTrait
- Provides methods to create protection rules.
Namespace
Drupal\Tests\userprotect\TraitsCode
protected function createProtectedUser(array $protections = []) {
// Create a user.
$account = $this
->drupalCreateUser();
// Protect this user.
$protection_rule = $this
->createProtectionRule($account
->id(), $protections, 'user');
$protection_rule
->save();
// Reset available permissions.
drupal_static_reset('checkPermissions');
return $account;
}