Skip to content
Snippets Groups Projects
Commit b7fc0553 authored by Angie Byron's avatar Angie Byron
Browse files

Issue #2050843 by Berdir, sun, Vasiliy Grotov: Users 0 and 1 are created without a UUID.

parent ae4177b8
No related branches found
No related tags found
No related merge requests found
<?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.');
}
}
......@@ -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,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment