Unverified Commit da1bddfb authored by alexpott's avatar alexpott

Issue #3151520 by adityasingh, pavnish, daffie, alexpott: Replace the database...

Issue #3151520 by adityasingh, pavnish, daffie, alexpott: Replace the database query with an entity query in UserInstallTest

(cherry picked from commit 5ded5317)
parent a8324003
......@@ -2,7 +2,6 @@
namespace Drupal\Tests\user\Kernel;
use Drupal\Core\Database\Database;
use Drupal\KernelTests\KernelTestBase;
/**
......@@ -33,22 +32,22 @@ protected function setUp(): void {
* Test that the initial users have correct values.
*/
public function testUserInstall() {
$result = Database::getConnection()->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');
$user_ids = \Drupal::entityQuery('user')->sort('uid')->execute();
$users = \Drupal::entityTypeManager()->getStorage('user')->loadMultiple($user_ids);
$anon = $users[0];
$admin = $users[1];
$this->assertNotEmpty($anon->uuid(), 'Anon user has a UUID');
$this->assertNotEmpty($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());
$this->assertEquals('en', $anon->language()->getId());
$this->assertEquals('en', $admin->language()->getId());
// Test that the administrator is active.
$this->assertEqual($admin->status, 1);
$this->assertTrue($admin->isActive());
// Test that the anonymous user is blocked.
$this->assertEqual($anon->status, 0);
$this->assertTrue($anon->isBlocked());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment