be3336f78027845d637e013dc9c190582b060ef2
[yaffs-website] / web / core / modules / user / tests / src / Kernel / UserInstallTest.php
1 <?php
2
3 namespace Drupal\Tests\user\Kernel;
4
5 use Drupal\KernelTests\KernelTestBase;
6
7 /**
8  * Tests user_install().
9  *
10  * @group user
11  */
12 class UserInstallTest extends KernelTestBase {
13
14   /**
15    * Modules to enable.
16    *
17    * @var array
18    */
19   public static $modules = ['user'];
20
21   /**
22    * {@inheritdoc}
23    */
24   protected function setUp() {
25     parent::setUp();
26     $this->container->get('module_handler')->loadInclude('user', 'install');
27     $this->installEntitySchema('user');
28     user_install();
29   }
30
31   /**
32    * Test that the initial users have correct values.
33    */
34   public function testUserInstall() {
35     $result = db_query('SELECT u.uid, u.uuid, u.langcode, uf.status FROM {users} u INNER JOIN {users_field_data} uf ON u.uid=uf.uid ORDER BY u.uid')
36       ->fetchAllAssoc('uid');
37     $anon = $result[0];
38     $admin = $result[1];
39     $this->assertFalse(empty($anon->uuid), 'Anon user has a UUID');
40     $this->assertFalse(empty($admin->uuid), 'Admin user has a UUID');
41
42     // Test that the anonymous and administrators languages are equal to the
43     // site's default language.
44     $this->assertEqual($anon->langcode, \Drupal::languageManager()->getDefaultLanguage()->getId());
45     $this->assertEqual($admin->langcode, \Drupal::languageManager()->getDefaultLanguage()->getId());
46
47     // Test that the administrator is active.
48     $this->assertEqual($admin->status, 1);
49     // Test that the anonymous user is blocked.
50     $this->assertEqual($anon->status, 0);
51   }
52
53 }