Skip to content
Snippets Groups Projects
Unverified Commit 5ded5317 authored by Alex Pott's avatar Alex Pott
Browse files

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
parent 4babf62c
No related branches found
No related tags found
8 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1012Issue #3226887: Hreflang on non-canonical content pages,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10,!596Issue #3046532: deleting an entity reference field, used in a contextual view, makes the whole site unrecoverable,!496Issue #2463967: Use .user.ini file for PHP settings,!144Issue #2666286: Clean up menu_ui to conform to Drupal coding standards,!16Draft: Resolve #2081585 "History storage",!13Resolve #2903456
......@@ -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());
}
}
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