You are here

public function GeshiFilterTest::testSpecialChars in GeSHi Filter for syntax highlighting 8.2

Same name and namespace in other branches
  1. 8 tests/src/Functional/GeshiFilterTest.php \Drupal\Tests\geshifilter\Functional\GeshiFilterTest::testSpecialChars()

Issue https://www.drupal.org/node/2047021.

File

tests/src/Functional/GeshiFilterTest.php, line 533

Class

GeshiFilterTest
Tests for GeshiFilter in node content.

Namespace

Drupal\Tests\geshifilter\Functional

Code

public function testSpecialChars() {
  $this->config
    ->set('tags', 'code');
  $this->config
    ->set('language.php.enabled', TRUE);
  $this->config
    ->set('decode_entities', TRUE);
  $this->config
    ->save();
  $source = '<code language="php"><?php echo("&lt;b&gt;Hi&lt;/b&gt;"); ?></code>';

  // Create a node.
  $node = [
    'title' => 'Test for Custom Filter',
    'body' => [
      [
        'value' => $source,
        'format' => 'geshifilter_text_format',
      ],
    ],
    'type' => 'geshifilter_content_type',
  ];
  $this
    ->drupalCreateNode($node);
  $this
    ->drupalGet('node/1');

  // The same string must be on page, not double encoded.
  $this
    ->assertRaw('&quot;&lt;b&gt;Hi&lt;/b&gt;&quot;', 'The code is not double encoded.');
}