You are here

public function HandlerFieldFieldTest::doTestSimpleFieldRender in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/field/tests/src/Kernel/Views/HandlerFieldFieldTest.php \Drupal\Tests\field\Kernel\Views\HandlerFieldFieldTest::doTestSimpleFieldRender()
  2. 10 core/modules/field/tests/src/Kernel/Views/HandlerFieldFieldTest.php \Drupal\Tests\field\Kernel\Views\HandlerFieldFieldTest::doTestSimpleFieldRender()

Tests simple field rendering.

1 call to HandlerFieldFieldTest::doTestSimpleFieldRender()
HandlerFieldFieldTest::testFieldRender in core/modules/field/tests/src/Kernel/Views/HandlerFieldFieldTest.php
Tests fields rendering in views.

File

core/modules/field/tests/src/Kernel/Views/HandlerFieldFieldTest.php, line 107

Class

HandlerFieldFieldTest
Tests the field rendering in views.

Namespace

Drupal\Tests\field\Kernel\Views

Code

public function doTestSimpleFieldRender() {
  $view = Views::getView('test_view_fieldapi');
  $this
    ->prepareView($view);
  $view
    ->preview();

  // Tests that the rendered fields match the actual value of the fields.
  for ($i = 0; $i < 3; $i++) {
    for ($key = 0; $key < 2; $key++) {
      $field_name = $this->fieldStorages[$key]
        ->getName();
      $rendered_field = $view->style_plugin
        ->getField($i, $field_name);
      $expected_field = $this->nodes[$i]->{$field_name}->value;
      $this
        ->assertEquals($expected_field, $rendered_field);
    }
  }
}