diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUnitTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUnitTestBase.php index 9e6b987..0fed4c8 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUnitTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUnitTestBase.php @@ -33,7 +33,9 @@ public function setUp() { * Creates a user. * * @param array $values - * (optional) The values used to create the entity. + * (optional) The values used to create the entity. To perform access checks + * and prevent the new user from becoming uid 1 (which exempts from all user + * access conditions), pass a unique value other than 1 as 'uid' in $values. * * @return \Drupal\user\Plugin\Core\Entity\User * The created user entity. @@ -42,9 +44,10 @@ protected function createUser($values = array()) { $account = entity_create('user', $values + array( 'name' => $this->randomName(), )); - // Allow to create a new user entity with a specific user id, make sure it - // it will be saved as a new entity instead of trying to update the - // non-existing entity with that id. + // Force the entity to be new, so that callers are able to specify + // a 'uid' in $values to skip over uid 1. If no uid is provided explicitly, + // \Drupal\user\UserStorageController will automatically choose and insert + // the next available ID. $account->enforceIsNew(); $account->save(); return $account;