You are here

public function UserInstallTest::testUserInstall in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/user/src/Tests/UserInstallTest.php \Drupal\user\Tests\UserInstallTest::testUserInstall()

Test that the initial users have correct values.

File

core/modules/user/src/Tests/UserInstallTest.php, line 40
Contains \Drupal\user\Tests\UserInstallTest.

Class

UserInstallTest
Tests user_install().

Namespace

Drupal\user\Tests

Code

public function testUserInstall() {
  $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')
    ->fetchAllAssoc('uid');
  $anon = $result[0];
  $admin = $result[1];
  $this
    ->assertFalse(empty($anon->uuid), 'Anon user has a UUID');
  $this
    ->assertFalse(empty($admin->uuid), 'Admin user has a UUID');

  // Test that the anonymous and administrators languages are equal to the
  // site's default language.
  $this
    ->assertEqual($anon->langcode, \Drupal::languageManager()
    ->getDefaultLanguage()
    ->getId());
  $this
    ->assertEqual($admin->langcode, \Drupal::languageManager()
    ->getDefaultLanguage()
    ->getId());

  // Test that the administrator is active.
  $this
    ->assertEqual($admin->status, 1);

  // Test that the anonymous user is blocked.
  $this
    ->assertEqual($anon->status, 0);
}