Chris@0: installEntitySchema('user'); Chris@0: Chris@0: // Set up a test theme that prints the user's mail field. Chris@0: \Drupal::service('theme_handler')->install(['user_test_theme']); Chris@0: \Drupal::theme()->setActiveTheme(\Drupal::service('theme.initialization')->initTheme('user_test_theme')); Chris@0: // Clear the theme registry. Chris@0: $this->container->set('theme.registry', NULL); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Tests account's available fields. Chris@0: */ Chris@0: public function testUserFields() { Chris@0: // Create the user to test the user fields. Chris@0: $user = User::create([ Chris@0: 'name' => 'foobar', Chris@0: 'mail' => 'foobar@example.com', Chris@0: ]); Chris@0: $build = user_view($user); Chris@0: $output = \Drupal::service('renderer')->renderRoot($build); Chris@0: $this->setRawContent($output); Chris@0: $userEmail = $user->getEmail(); Chris@0: $this->assertText($userEmail, "User's mail field is found in the twig template"); Chris@0: } Chris@0: Chris@0: }