1.20.x field_views.test public FieldViewsFieldTest::_testFormatterSimpleFieldRender()

Tests that fields with formatters runs as expected.

File

modules/field/tests/field_views.test, line 335
Tests the Views integration with Field API.

Class

FieldViewsFieldTest
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

Code

public function _testFormatterSimpleFieldRender() {
  $view = $this->getFieldView();
  $view->display['default']->display_options['fields'][$this->fields[0]['field_name']]['type'] = 'text_trimmed';
  $view->display['default']->display_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 + 2, $this->fields[0]['field_name']);
    $this->assertEqual(strlen($rendered_field), 3);
  }
}