From 243e291028674def0b485b527b05f039424bd54a Mon Sep 17 00:00:00 2001 From: Alex Pott Date: Mon, 29 Jun 2020 09:57:39 +0100 Subject: [PATCH] Issue #3151520 by adityasingh, pavnish, daffie, alexpott: Replace the database query with an entity query in UserInstallTest (cherry picked from commit 5ded531763f04263b064ea3bf8fb135b53e80d8a) --- .../user/tests/src/Kernel/UserInstallTest.php | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/core/modules/user/tests/src/Kernel/UserInstallTest.php b/core/modules/user/tests/src/Kernel/UserInstallTest.php index 3e9282b5d9..e8f1620856 100644 --- a/core/modules/user/tests/src/Kernel/UserInstallTest.php +++ b/core/modules/user/tests/src/Kernel/UserInstallTest.php @@ -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() { * 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()); } } -- GitLab