You are here

function UserFieldsTest::testUserFields in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/user/src/Tests/UserFieldsTest.php \Drupal\user\Tests\UserFieldsTest::testUserFields()

Tests account's available fields.

File

core/modules/user/src/Tests/UserFieldsTest.php, line 44
Contains \Drupal\user\Tests\UserFieldsTest.

Class

UserFieldsTest
Tests available user fields in twig.

Namespace

Drupal\user\Tests

Code

function testUserFields() {

  // Create the user to test the user fields.
  $user = User::create([
    'name' => 'foobar',
    'mail' => 'foobar@example.com',
  ]);
  $build = 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");
}