public function UserFieldsTest::testUserFields in Drupal 9
Same name and namespace in other branches
- 8 core/modules/user/tests/src/Kernel/UserFieldsTest.php \Drupal\Tests\user\Kernel\UserFieldsTest::testUserFields()
Tests account's available fields.
File
- core/
modules/ user/ tests/ src/ Kernel/ UserFieldsTest.php, line 39
Class
- UserFieldsTest
- Tests available user fields in twig.
Namespace
Drupal\Tests\user\KernelCode
public function testUserFields() {
// Create the user to test the user fields.
$user = User::create([
'name' => 'foobar',
'mail' => 'foobar@example.com',
]);
$build = \Drupal::entityTypeManager()
->getViewBuilder('user')
->view($user);
$output = \Drupal::service('renderer')
->renderRoot($build);
$this
->setRawContent($output);
$userEmail = $user
->getEmail();
$this
->assertText($userEmail, "User's mail field is found in the twig template");
}