You are here

public function GeshiFilterTest::testDoNothingMode 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::testDoNothingMode()

Test for do nothing mode.

File

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

Class

GeshiFilterTest
Tests for GeshiFilter in node content.

Namespace

Drupal\Tests\geshifilter\Functional

Code

public function testDoNothingMode() {

  // Enable C++.
  $this->config
    ->set('language.cpp.enabled', TRUE);
  $this->config
    ->set('language.cpp.tags', 'cpp');

  // Set default highlighting mode to "do nothing".
  $this->config
    ->set('default_highlighting', GeshiFilter::DEFAULT_DONOTHING);
  $this->config
    ->save();

  // Body material with some characters ('<' and '&') that would be escaped
  // Except in "do nothing" mode.
  $source_code = "//C++-ish source code\nfor (int i=0; i!=10; ++i) {\n  fun(i);\n  bar.foo(x, y);\n}";

  // Tests.
  $this
    ->assertGeshiFilterHighlighting('<code>' . $source_code . '</code>', [
    [
      '<code>' . $source_code . '</code>',
      FALSE,
      0,
      1,
      FALSE,
    ],
  ], t('Do nothing mode should not touch given source code'));
  $this
    ->assertGeshiFilterHighlighting('<code language="cpp">' . $source_code . '</code>', [
    [
      $source_code,
      'cpp',
      0,
      1,
      FALSE,
    ],
  ], t('Highlighting with language="cpp" should work when default is "do nothing"'));
  $this
    ->assertGeshiFilterHighlighting('<cpp>' . $source_code . '</cpp>', [
    [
      $source_code,
      'cpp',
      0,
      1,
      FALSE,
    ],
  ], t('Highlighting with <cpp>...</cpp> should work when default is "do nothing"'));
}