From b7fc0553d84d460caeb3f62254e0ad02c91c8457 Mon Sep 17 00:00:00 2001
From: webchick <webchick@24967.no-reply.drupal.org>
Date: Mon, 23 Dec 2013 12:55:44 -0800
Subject: [PATCH] Issue #2050843 by Berdir, sun, Vasiliy Grotov: Users 0 and 1
 are created without a UUID.

---
 .../lib/Drupal/user/Tests/UserInstallTest.php | 61 +++++++++++++++++++
 core/modules/user/user.install                |  7 ++-
 2 files changed, 65 insertions(+), 3 deletions(-)
 create mode 100644 core/modules/user/lib/Drupal/user/Tests/UserInstallTest.php

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 000000000000..3c86a305fb4b
--- /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 e659970679cb..67c9fcca4381 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,
-- 
GitLab