You are here

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

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

File

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

Class

GeshiFilterTest
Funcional tests for the GeSHi filter node content.

Code

function testBracketsOnlyPhpCodeBlock() {
  variable_set('geshifilter_tags', 'code');
  variable_set('geshifilter_language_enabled_cpp', 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
  variable_set('geshifilter_tag_styles', array(
    GESHIFILTER_BRACKETS_PHPBLOCK => GESHIFILTER_BRACKETS_PHPBLOCK,
  ));

  // This should be filtered.
  $this
    ->assertGeshiFilterHighlighting('<?php' . $source_code . '?>', array(
    array(
      $source_code,
      'php',
      0,
      1,
      FALSE,
    ),
  ), t('Checking php code blocks in GESHIFILTER_BRACKETS_PHPBLOCK mode'));

  // This should not be filtered.
  $this
    ->assertGeshiFilterHighlighting('<code language="cpp">' . $source_code . '</code>', array(
    array(
      $source_code,
      NULL,
      0,
      1,
      FALSE,
    ),
  ), t('Checking angle brackets style in GESHIFILTER_BRACKETS_PHPBLOCK mode'));
  $this
    ->assertGeshiFilterHighlighting('[code language="cpp"]' . $source_code . '[/code]', array(
    array(
      $source_code,
      NULL,
      0,
      1,
      FALSE,
    ),
  ), t('Checking [foo] brackets style in GESHIFILTER_BRACKETS_PHPBLOCK mode'));
  $this
    ->assertGeshiFilterHighlighting('[[code language="cpp"]]' . $source_code . '[[/code]]', array(
    array(
      $source_code,
      NULL,
      0,
      1,
      FALSE,
    ),
  ), t('Checking [[foo]] brackets style in GESHIFILTER_BRACKETS_PHPBLOCK mode'));
}