mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-05 13:47:24 +02:00
[1.7.0] Wire in Language and ErrorCollector to main class, now, the only thing to do is actually implement the stuff
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1157 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
42
tests/HTMLPurifier/ErrorCollectorTest.php
Normal file
42
tests/HTMLPurifier/ErrorCollectorTest.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
require_once 'HTMLPurifier/ErrorCollector.php';
|
||||
|
||||
class HTMLPurifier_ErrorCollectorTest extends UnitTestCase
|
||||
{
|
||||
|
||||
function test() {
|
||||
|
||||
$tok1 = new HTMLPurifier_Token_Text('Token that caused error');
|
||||
$tok1->line = 23;
|
||||
$tok2 = new HTMLPurifier_Token_Start('a'); // also caused error
|
||||
$tok2->line = 3;
|
||||
$tok3 = new HTMLPurifier_Token_Text('Context before'); // before $tok2
|
||||
$tok3->line = 3;
|
||||
$tok4 = new HTMLPurifier_Token_Text('Context after'); // after $tok2
|
||||
$tok4->line = 3;
|
||||
|
||||
$collector = new HTMLPurifier_ErrorCollector();
|
||||
$collector->send('Big fat error', $tok1);
|
||||
$collector->send('Another <error>', $tok2, array($tok3, true, $tok4));
|
||||
|
||||
$result = array(
|
||||
0 => array('Big fat error', $tok1, array(true)),
|
||||
1 => array('Another <error>', $tok2, array($tok3, true, $tok4))
|
||||
);
|
||||
|
||||
$this->assertIdentical($collector->getRaw(), $result);
|
||||
|
||||
$formatted_result = array(
|
||||
0 => 'Another <error> at line 3 (<code>Context before<strong><a></strong>Context after</code>)',
|
||||
1 => 'Big fat error at line 23 (<code><strong>Token that caused error</strong></code>)'
|
||||
);
|
||||
|
||||
$config = HTMLPurifier_Config::create(array('Core.MaintainLineNumbers' => true));
|
||||
$this->assertIdentical($collector->getHTMLFormatted($config), $formatted_result);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
Reference in New Issue
Block a user