public function HandlerFieldFieldTest::_testFormatterSimpleFieldRender

Tests that fields with formatters runs as expected.

1 call to HandlerFieldFieldTest::_testFormatterSimpleFieldRender()
HandlerFieldFieldTest::testFieldRender in drupal/core/modules/views/lib/Drupal/views/Tests/Field/HandlerFieldFieldTest.php

File

drupal/core/modules/views/lib/Drupal/views/Tests/Field/HandlerFieldFieldTest.php, line 116
Definition of Drupal\views\Test\Field\HandlerFieldFieldTest.

Class

HandlerFieldFieldTest
Tests the field_field handler. @TODO Check a entity-type with bundles Check a entity-type without bundles Check locale:disabled, locale:enabled and locale:enabled with another language Check revisions

Namespace

Drupal\views\Tests\Field

Code

public function _testFormatterSimpleFieldRender() {
  $view = views_get_view('test_view_fieldapi');
  $this
    ->prepareView($view);
  $view->displayHandlers['default']->options['fields'][$this->fields[0]['field_name']]['type'] = 'text_trimmed';
  $view->displayHandlers['default']->options['fields'][$this->fields[0]['field_name']]['settings'] = array(
    'trim_length' => 3,
  );
  $this
    ->executeView($view);

  // Take 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
      ->get_field($i, $this->fields[0]['field_name']);
    $this
      ->assertEqual(strlen($rendered_field), 3);
  }
}