function GeshiFilterTest::assertGeshiFilterHighlighting in GeSHi Filter for syntax highlighting 7
Same name and namespace in other branches
- 5.2 tests/geshifilter.test \GeshiFilterTest::assertGeshiFilterHighlighting()
- 6 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 257 - Tests for the GeSHi filter module.
Class
- GeshiFilterTest
- Funcional tests for the GeSHi filter node content.
Code
function assertGeshiFilterHighlighting($body, $check_list, $description, $invert = false) {
// Create content.
$edit = array(
'title' => $this
->randomName(32, 'simpletest_pagetitle_'),
'body[und][0][value]' => $body . "\n" . $this
->randomName(100),
'body[und][0][format]' => $this->input_format_id,
);
// Post node
$this
->drupalPost('node/add/page', $edit, t('Save'));
// check posted node
$query = new EntityFieldQuery();
$entities = $query
->entityCondition('entity_type', 'node')
->propertyCondition('title', $edit['title'])
->execute();
$node = node_load(current(array_keys($entities['node'])));
$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);
}
}
}