public function GeshiFilterTest::testBracketsOnlyDoubleSquare in GeSHi Filter for syntax highlighting 8
Same name and namespace in other branches
- 8.2 tests/src/Functional/GeshiFilterTest.php \Drupal\Tests\geshifilter\Functional\GeshiFilterTest::testBracketsOnlyDoubleSquare()
 
Test with brackets only double square.
File
- tests/
src/ Functional/ GeshiFilterTest.php, line 292  
Class
- GeshiFilterTest
 - Tests for GeshiFilter in node content.
 
Namespace
Drupal\Tests\geshifilter\FunctionalCode
public function testBracketsOnlyDoubleSquare() {
  $this->config
    ->set('tags', 'code');
  $this->config
    ->set('language.cpp.enabled', TRUE);
  $source_code = "//C++ source code\nfor (int i=0; i<10; ++i) {\n  fun(i);\n  bar.foo(x, y);\n server->start(&pool); \n}";
  // Enable only double square brackets.
  $this->config
    ->set('tag_styles', [
    GeshiFilter::BRACKETS_DOUBLESQUARE => GeshiFilter::BRACKETS_DOUBLESQUARE,
  ]);
  $this->config
    ->save();
  // This should be filtered.
  $this
    ->assertGeshiFilterHighlighting('[[code language="cpp"]]' . $source_code . '[[/code]]', [
    [
      $source_code,
      'cpp',
      0,
      1,
      FALSE,
    ],
  ], t('Checking [[foo]] brackets style in GeshiFilter::BRACKETS_DOUBLESQUARE mode'));
  // This should not be filtered.
  $this
    ->assertGeshiFilterHighlighting('<code language="cpp">' . $source_code . '</code>', [
    [
      $source_code,
      NULL,
      0,
      1,
      FALSE,
    ],
  ], t('Checking angle brackets style in GeshiFilter::BRACKETS_DOUBLESQUARE mode'));
  $this
    ->assertGeshiFilterHighlighting('[code language="cpp"]' . $source_code . '[/code]', [
    [
      $source_code,
      NULL,
      0,
      1,
      FALSE,
    ],
  ], t('Checking [foo] brackets style in GeshiFilter::BRACKETS_DOUBLESQUARE mode'));
  $this
    ->assertGeshiFilterHighlighting('<?php' . $source_code . '?>', [
    [
      $source_code,
      NULL,
      0,
      1,
      FALSE,
    ],
  ], t('Checking php code blocks in GeshiFilter::BRACKETS_DOUBLESQUARE mode'));
}