function TextPlainUnitTest::testPlainText

Tests text_plain formatter output.

File

drupal/core/modules/text/lib/Drupal/text/Tests/Formatter/TextPlainUnitTest.php, line 295
Contains \Drupal\text\Tests\Formatter\TextPlainUnitTest.

Class

TextPlainUnitTest
Tests the text_plain field formatter.

Namespace

Drupal\text\Tests\Formatter

Code

function testPlainText() {
  $value = $this
    ->randomString();
  $value .= "\n\n<strong>" . $this
    ->randomString() . '</strong>';
  $value .= "\n\n" . $this
    ->randomString();
  $entity = $this
    ->createEntity(array());
  $entity->{$this->field_name}->value = $value;

  // Verify that all HTML is escaped and newlines are retained.
  $this
    ->renderEntityFields($entity, $this->display);
  $this
    ->assertText($value);
  $this
    ->assertNoRaw($value);
  $this
    ->assertRaw(nl2br(check_plain($value)));
}