You are here

public function HandlerFieldFieldTest::_testFormatterSimpleFieldRender in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php \Drupal\field\Tests\Views\HandlerFieldFieldTest::_testFormatterSimpleFieldRender()

Tests that fields with formatters runs as expected.

1 call to HandlerFieldFieldTest::_testFormatterSimpleFieldRender()
HandlerFieldFieldTest::testFieldRender in core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php

File

core/modules/field/src/Tests/Views/HandlerFieldFieldTest.php, line 174
Contains \Drupal\field\Tests\Views\HandlerFieldFieldTest.

Class

HandlerFieldFieldTest
Tests the field itself of the Field integration.

Namespace

Drupal\field\Tests\Views

Code

public function _testFormatterSimpleFieldRender() {
  $view = Views::getView('test_view_fieldapi');
  $this
    ->prepareView($view);
  $view->displayHandlers
    ->get('default')->options['fields'][$this->fieldStorages[5]
    ->getName()]['type'] = 'text_trimmed';
  $view->displayHandlers
    ->get('default')->options['fields'][$this->fieldStorages[5]
    ->getName()]['settings'] = array(
    'trim_length' => 3,
  );
  $this
    ->executeView($view);

  // Make sure that the formatter works as expected.
  // @TODO: actually there should be a specific formatter.
  for ($i = 0; $i < 2; $i++) {
    $rendered_field = $view->style_plugin
      ->getField($i, $this->fieldStorages[5]
      ->getName());
    $this
      ->assertEqual(strlen(html_entity_decode($rendered_field)), 3);
  }
}