You are here

function GeshiFilterTest::testDoNothingMode in GeSHi Filter for syntax highlighting 6

Same name and namespace in other branches
  1. 7 geshifilter.test \GeshiFilterTest::testDoNothingMode()

File

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

Class

GeshiFilterTest

Code

function testDoNothingMode() {

  // Enable C++.
  variable_set('geshifilter_language_enabled_cpp', TRUE);
  variable_set('geshifilter_language_tags_cpp', 'cpp');

  // Set default highlighting mode to "do nothing".
  variable_set('geshifilter_default_highlighting', GESHIFILTER_DEFAULT_DONOTHING);

  // 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>', array(
    array(
      '<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>', array(
    array(
      $source_code,
      'cpp',
      0,
      1,
      FALSE,
    ),
  ), t('Highlighting with language="cpp" should work when default is "do nothing"'));
  $this
    ->assertGeshiFilterHighlighting('<cpp>' . $source_code . '</cpp>', array(
    array(
      $source_code,
      'cpp',
      0,
      1,
      FALSE,
    ),
  ), t('Highlighting with <cpp>...</cpp> should work when default is "do nothing"'));
}