You are here

function GeshiFilterTest::testPrefixTags in GeSHi Filter for syntax highlighting 7

Same name and namespace in other branches
  1. 5.2 tests/geshifilter.test \GeshiFilterTest::testPrefixTags()
  2. 6 geshifilter.test \GeshiFilterTest::testPrefixTags()

Test if tags like [cpp], [css], [csharp] aren't highjacked by [c]

File

./geshifilter.test, line 462
Tests for the GeSHi filter module.

Class

GeshiFilterTest
Funcional tests for the GeSHi filter node content.

Code

function testPrefixTags() {

  // enabled the tags
  variable_set('geshifilter_language_enabled_c', TRUE);
  variable_set('geshifilter_language_tags_c', 'c');
  variable_set('geshifilter_language_enabled_cpp', TRUE);
  variable_set('geshifilter_language_tags_cpp', 'cpp');
  variable_set('geshifilter_language_enabled_csharp', TRUE);
  variable_set('geshifilter_language_tags_csharp', 'csharp');

  // body material
  $source_code = "//C++-ish source code\nfor (int i=0; i<10; ++i) {\n  fun(i);\n  bar.foo(x, y);\n server->start(&pool); \n}";

  // Test the tags
  $this
    ->assertGeshiFilterHighlighting('<cpp>' . $source_code . '</cpp>', array(
    array(
      $source_code,
      'cpp',
      0,
      1,
      FALSE,
    ),
  ), t('Source code in <cpp>...</cpp> should work when <c>...</c> is also enabled'));
  $this
    ->assertGeshiFilterHighlighting('<csharp>' . $source_code . '</csharp>', array(
    array(
      $source_code,
      'csharp',
      0,
      1,
      FALSE,
    ),
  ), t('Source code in <csharp>...</csharp> should work when <c>...</c> is also enabled'));
}