diff --git a/core/modules/user/lib/Drupal/user/Tests/UserInstallTest.php b/core/modules/user/lib/Drupal/user/Tests/UserInstallTest.php new file mode 100644 index 0000000000000000000000000000000000000000..3c86a305fb4b9e279cf1fc5592b98a9642ad23f3 --- /dev/null +++ b/core/modules/user/lib/Drupal/user/Tests/UserInstallTest.php @@ -0,0 +1,61 @@ +<?php + +/** + * @file + * Contains \Drupal\user\Tests\UserInstallTest. + */ + +namespace Drupal\user\Tests; + +use Drupal\simpletest\DrupalUnitTestBase; + +/** + * Tests user_install(). + */ +class UserInstallTest extends DrupalUnitTestBase { + + /** + * Modules to enable. + * + * @var array + */ + public static $modules = array('user'); + + /** + * {@inheritdoc} + */ + public static function getInfo() { + return array( + 'name' => 'User install tests', + 'description' => 'Tests user_install().', + 'group' => 'User' + ); + } + + /** + * {@inheritdoc} + */ + protected function setUp() { + parent::setUp(); + $this->installSchema('user', array('users')); + } + + + /** + * Test that the initial users have correct values. + */ + public function testUserInstall() { + user_install(); + $anon = db_query('SELECT * FROM {users} WHERE uid = 0')->fetchObject(); + $admin = db_query('SELECT * FROM {users} WHERE uid = 1')->fetchObject(); + $this->assertFalse(empty($anon->uuid), 'Anon user has a UUID'); + $this->assertFalse(empty($admin->uuid), 'Admin user has a UUID'); + + $this->assertEqual($anon->langcode, language_default()->id, 'Anon user language is the default.'); + $this->assertEqual($admin->langcode, language_default()->id, 'Admin user language is the default.'); + + $this->assertEqual($admin->status, 1, 'Admin user is active.'); + $this->assertEqual($anon->status, 0, 'Anon user is blocked.'); + } + +} diff --git a/core/modules/user/user.install b/core/modules/user/user.install index e659970679cb4c755d075154e202746b5ae35b96..67c9fcca43812485e6e992f26b3d8a88a1901a07 100644 --- a/core/modules/user/user.install +++ b/core/modules/user/user.install @@ -231,18 +231,19 @@ function user_install() { db_insert('users') ->fields(array( 'uid' => 0, + 'uuid' => \Drupal::service('uuid')->generate(), 'name' => '', 'mail' => '', 'langcode' => language_default()->id, )) ->execute(); - // We need some placeholders here as name and mail are uniques and data is - // presumed to be a serialized array. This will be changed by the settings - // form in the installer. + // We need some placeholders here as name and mail are uniques. + // This will be changed by the settings form in the installer. db_insert('users') ->fields(array( 'uid' => 1, + 'uuid' => \Drupal::service('uuid')->generate(), 'name' => 'placeholder-for-uid-1', 'mail' => 'placeholder-for-uid-1', 'created' => REQUEST_TIME,