function GeshiFilterTest::testGenericTags in GeSHi Filter for syntax highlighting 7
Same name and namespace in other branches
- 6 geshifilter.test \GeshiFilterTest::testGenericTags()
Test the standard functionality of the generic tags
File
- ./
geshifilter.test, line 293 - Tests for the GeSHi filter module.
Class
- GeshiFilterTest
- Funcional tests for the GeSHi filter node content.
Code
function testGenericTags() {
variable_set('geshifilter_tags', 'code');
variable_set('geshifilter_language_enabled_c', TRUE);
variable_set('geshifilter_language_enabled_cpp', TRUE);
variable_set('geshifilter_language_enabled_csharp', TRUE);
variable_set('geshifilter_language_enabled_java', TRUE);
// 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}";
// check language argument
$this
->assertGeshiFilterHighlighting('<code type="cpp">' . $source_code . '</code>', array(
array(
$source_code,
'cpp',
0,
1,
FALSE,
),
), t('Checking type="..." argument'));
$this
->assertGeshiFilterHighlighting('<code lang="cpp">' . $source_code . '</code>', array(
array(
$source_code,
'cpp',
0,
1,
FALSE,
),
), t('Checking lang="..." argument'));
$this
->assertGeshiFilterHighlighting('<code language="cpp">' . $source_code . '</code>', array(
array(
$source_code,
'cpp',
0,
1,
FALSE,
),
), t('Checking language="..." argument'));
// check some languages
$languages = array(
'c',
'cpp',
'java',
);
foreach ($languages as $lang) {
$this
->assertGeshiFilterHighlighting('<code language="' . $lang . '">' . $source_code . '</code>', array(
array(
$source_code,
$lang,
0,
1,
FALSE,
),
), t('Checking language="@lang"', array(
'@lang' => $lang,
)));
}
// check line_numbering argument
$this
->assertGeshiFilterHighlighting('<code type="cpp" linenumbers="off">' . $source_code . '</code>', array(
array(
$source_code,
'cpp',
0,
1,
FALSE,
),
), t('Checking linenumbers="off" argument'));
$this
->assertGeshiFilterHighlighting('<code type="cpp" linenumbers="normal">' . $source_code . '</code>', array(
array(
$source_code,
'cpp',
1,
1,
FALSE,
),
), t('Checking linenumbers="normal" argument'));
$this
->assertGeshiFilterHighlighting('<code type="cpp" start="27">' . $source_code . '</code>', array(
array(
$source_code,
'cpp',
1,
27,
FALSE,
),
), t('Checking start="27" argument'));
$this
->assertGeshiFilterHighlighting('<code type="cpp" linenumbers="fancy">' . $source_code . '</code>', array(
array(
$source_code,
'cpp',
5,
1,
FALSE,
),
), t('Checking linenumbers="fancy" argument'));
$this
->assertGeshiFilterHighlighting('<code type="cpp" fancy="3">' . $source_code . '</code>', array(
array(
$source_code,
'cpp',
3,
1,
FALSE,
),
), t('Checking fancy="3" argument'));
}