function GeshiFilterTest::assertGeshiFilterHighlighting in GeSHi Filter for syntax highlighting 6
Same name and namespace in other branches
- 5.2 tests/geshifilter.test \GeshiFilterTest::assertGeshiFilterHighlighting()
- 7 geshifilter.test \GeshiFilterTest::assertGeshiFilterHighlighting()
Assert function for testing if GeSHi highlighting works
Parameters
string $body the body text of the node:
array $check_list list of items that should be in rendered output (assertRaw): an item is something like array($source_code, $lang, $line_numbering, $linenumbers_start, $inline_mode) if $lang is set, GeSHifilter syntax highlighting is applied to $sourcecode if $lang is false, $sourcecode is directly looked for
string $description description of the assertion:
boolean $invert if assertNoRaw should be used instead of assertRaw:
11 calls to GeshiFilterTest::assertGeshiFilterHighlighting()
- GeshiFilterTest::testBracketsOnlyAngle in ./
geshifilter.test - GeshiFilterTest::testBracketsOnlyDoubleSquare in ./
geshifilter.test - GeshiFilterTest::testBracketsOnlyPhpCodeBlock in ./
geshifilter.test - GeshiFilterTest::testBracketsOnlySquare in ./
geshifilter.test - GeshiFilterTest::testDoNothingMode in ./
geshifilter.test
File
- ./
geshifilter.test, line 260 - Tests for the GeSHi filter module.
Class
Code
function assertGeshiFilterHighlighting($body, $check_list, $description, $invert = false) {
// Create content.
$edit = array(
'title' => $this
->randomName(32, 'simpletest_pagetitle_'),
'body' => $body . "\n" . $this
->randomName(100),
'format' => $this->input_format_id,
);
// Post node
$this
->drupalPost('node/add/page', $edit, t('Save'));
// check posted node
$node = node_load(array(
'title' => $edit['title'],
));
$this
->assertTrue($node, 'Node found in database. %s');
// check if highlighting succeeded
foreach ($check_list as $fragment) {
list($source_code, $lang, $line_numbering, $linenumbers_start, $inline_mode) = $fragment;
if ($lang) {
// apply syntax highlighting
$source_code = geshifilter_geshi_process($source_code, $lang, $line_numbering, $linenumbers_start, $inline_mode);
}
if ($invert) {
$this
->assertNoRaw($source_code, $description);
}
else {
$this
->assertRaw($source_code, $description);
}
}
}