1
0
mirror of https://github.com/ezyang/htmlpurifier.git synced 2025-07-12 18:26:19 +02:00

[2.0.1] Rather than pass line number by parameter, have it be retrieved via Context. Add $ignore_error boolean to get().

git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1228 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
Edward Z. Yang
2007-06-25 01:08:57 +00:00
parent 8ae2604440
commit 728088f2ba
5 changed files with 59 additions and 37 deletions

View File

@ -11,9 +11,6 @@ class HTMLPurifier_ErrorCollectorTest extends UnitTestCase
function test() {
$tok = new HTMLPurifier_Token_Start('a'); // also caused error
$tok->line = 3;
$language = new HTMLPurifier_LanguageMock();
$language->setReturnValue('getErrorName', 'Error', array(E_ERROR));
$language->setReturnValue('getErrorName', 'Warning', array(E_WARNING));
@ -22,9 +19,19 @@ class HTMLPurifier_ErrorCollectorTest extends UnitTestCase
$language->setReturnValue('formatMessage', ' at line 23', array('ErrorCollector: At line', array('line' => 23)));
$language->setReturnValue('formatMessage', ' at line 3', array('ErrorCollector: At line', array('line' => 3)));
$collector = new HTMLPurifier_ErrorCollector($language);
$collector->send(23, E_ERROR, 'message-1');
$collector->send($tok, E_WARNING, 'message-2', 'param');
$line = false;
$context = new HTMLPurifier_Context();
$context->register('Locale', $language);
$context->register('CurrentLine', $line);
$collector = new HTMLPurifier_ErrorCollector($context);
$line = 23;
$collector->send(E_ERROR, 'message-1');
$line = 3;
$collector->send(E_WARNING, 'message-2', 'param');
$result = array(
0 => array(23, E_ERROR, 'Message 1'),
@ -46,25 +53,30 @@ class HTMLPurifier_ErrorCollectorTest extends UnitTestCase
function testNoErrors() {
$language = new HTMLPurifier_LanguageMock();
$language->setReturnValue('getMessage', 'No errors', array('ErrorCollector: No errors'));
$collector = new HTMLPurifier_ErrorCollector($language);
$context = new HTMLPurifier_Context();
$context->register('Locale', $language);
$collector = new HTMLPurifier_ErrorCollector($context);
$formatted_result = '<p>No errors</p>';
$config = HTMLPurifier_Config::createDefault();
$this->assertIdentical($collector->getHTMLFormatted($config), $formatted_result);
}
function testNoLineNumbers() {
$token = new HTMLPurifier_Token_Start('a'); // no line number!
$language = new HTMLPurifier_LanguageMock();
$language->setReturnValue('getMessage', 'Message 1', array('message-1'));
$language->setReturnValue('getMessage', 'Message 2', array('message-2'));
$language->setReturnValue('getErrorName', 'Error', array(E_ERROR));
$collector = new HTMLPurifier_ErrorCollector($language);
$collector->send(false, E_ERROR, 'message-1');
$collector->send($token, E_ERROR, 'message-2');
$context = new HTMLPurifier_Context();
$context->register('Locale', $language);
$collector = new HTMLPurifier_ErrorCollector($context);
$collector->send(E_ERROR, 'message-1');
$collector->send(E_ERROR, 'message-2');
$result = array(
0 => array(false, E_ERROR, 'Message 1'),
1 => array(false, E_ERROR, 'Message 2')
0 => array(null, E_ERROR, 'Message 1'),
1 => array(null, E_ERROR, 'Message 2')
);
$this->assertIdentical($collector->getRaw(), $result);