You are here

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

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

File

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

Class

GeshiFilterTest

Code

function testBracketsOnlySquare() {
  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 square brackets
  variable_set('geshifilter_tag_styles', array(
    GESHIFILTER_BRACKETS_SQUARE => GESHIFILTER_BRACKETS_SQUARE,
  ));

  // This should be filtered.
  $this
    ->assertGeshiFilterHighlighting('[code language="cpp"]' . $source_code . '[/code]', array(
    array(
      $source_code,
      'cpp',
      0,
      1,
      FALSE,
    ),
  ), t('Checking [foo] brackets style in GESHIFILTER_BRACKETS_SQUARE 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_SQUARE 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_SQUARE mode'));
  $this
    ->assertGeshiFilterHighlighting('<?php' . $source_code . '?>', array(
    array(
      $source_code,
      NULL,
      0,
      1,
      FALSE,
    ),
  ), t('Checking php code blocks in GESHIFILTER_BRACKETS_SQUARE mode'));
}