class UserInstallTest in Drupal 10
Same name and namespace in other branches
- 8 core/modules/user/tests/src/Kernel/UserInstallTest.php \Drupal\Tests\user\Kernel\UserInstallTest
- 9 core/modules/user/tests/src/Kernel/UserInstallTest.php \Drupal\Tests\user\Kernel\UserInstallTest
Tests user_install().
@group user
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \PHPUnit\Framework\TestCase implements ServiceProviderInterface uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, AssertContentTrait, ConfigTestTrait, ExtensionListTestTrait, RandomGeneratorTrait, TestRequirementsTrait, PhpUnitWarnings
- class \Drupal\Tests\user\Kernel\UserInstallTest
Expanded class hierarchy of UserInstallTest
File
- core/
modules/ user/ tests/ src/ Kernel/ UserInstallTest.php, line 12
Namespace
Drupal\Tests\user\KernelView source
class UserInstallTest extends KernelTestBase {
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'user',
];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->container
->get('module_handler')
->loadInclude('user', 'install');
$this
->installEntitySchema('user');
user_install();
}
/**
* Tests that the initial users have correct values.
*/
public function testUserInstall() {
$user_ids = \Drupal::entityQuery('user')
->sort('uid')
->accessCheck(FALSE)
->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
->assertEquals('en', $anon
->language()
->getId());
$this
->assertEquals('en', $admin
->language()
->getId());
// Test that the administrator is active.
$this
->assertTrue($admin
->isActive());
// Test that the anonymous user is blocked.
$this
->assertTrue($anon
->isBlocked());
}
}