You are here

public function FieldTest::testRewrite in Views (for Drupal 7) 8.3

Tests general rewriting of the output.

File

lib/Drupal/views/Tests/Handler/FieldTest.php, line 360
Definition of Drupal\views\Tests\Handler\FieldTest.

Class

FieldTest
Tests the generic field handler.

Namespace

Drupal\views\Tests\Handler

Code

public function testRewrite() {
  $view = $this
    ->getBasicView();
  $view
    ->initHandlers();
  $this
    ->executeView($view);
  $row = $view->result[0];
  $id_field = $view->field['id'];

  // Don't check the rewrite checkbox, so the text shouldn't appear.
  $id_field->options['alter']['text'] = $random_text = $this
    ->randomName();
  $output = $id_field
    ->theme($row);
  $this
    ->assertNotSubString($output, $random_text);
  $id_field->options['alter']['alter_text'] = TRUE;
  $output = $id_field
    ->theme($row);
  $this
    ->assertSubString($output, $random_text);
}