public function UserDataTest::testDataField

Tests field handler.

File

drupal/core/modules/user/lib/Drupal/user/Tests/Views/UserDataTest.php, line 42
Contains \Drupal\user\Tests\Views\UserDataTest.

Class

UserDataTest
Tests the user data service field handler.

Namespace

Drupal\user\Tests\Views

Code

public function testDataField() {

  // But some random values into the user data service.
  $this->userData = $this->container
    ->get('user.data');
  $random_value = $this
    ->randomName();
  $this->userData
    ->set('views_test_config', $this->users[0]
    ->id(), 'test_value_name', $random_value);
  $view = views_get_view('test_user_data');
  $this
    ->executeView($view);
  $output = $view->field['data']
    ->render($view->result[0]);
  $this
    ->assertEqual($output, $random_value, 'A valid user data got rendered.');
  $view->field['data']->options['name'] = $this
    ->randomName();
  $output = $view->field['data']
    ->render($view->result[0]);
  $this
    ->assertFalse($output, 'An invalid configuration does not return anything');
}