mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-07-30 19:00:10 +02:00
Rename Lexer, separate files. Also augmented benchmarks and benchmarker,
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@79 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@@ -11,7 +11,7 @@ class Test_HTMLPurifier_ChildDef extends UnitTestCase
|
||||
var $gen;
|
||||
|
||||
function Test_HTMLPurifier_ChildDef() {
|
||||
$this->lex = new HTMLPurifier_Lexer();
|
||||
$this->lex = HTMLPurifier_Lexer::create();
|
||||
$this->gen = new HTMLPurifier_Generator();
|
||||
parent::UnitTestCase();
|
||||
}
|
||||
@@ -81,7 +81,7 @@ class Test_HTMLPurifier_ChildDef extends UnitTestCase
|
||||
|
||||
$def = new HTMLPurifier_ChildDef_Required('dt | dd');
|
||||
|
||||
$inputs[0] = array();
|
||||
$inputs[0] = '';
|
||||
$expect[0] = false;
|
||||
|
||||
$inputs[1] = '<dt>Term</dt>Text in an illegal location'.
|
||||
|
@@ -1,24 +1,21 @@
|
||||
<?php
|
||||
|
||||
/* TODO
|
||||
* Benchmark the SAX parser with my homemade one
|
||||
*/
|
||||
|
||||
require_once 'HTMLPurifier/Lexer.php';
|
||||
require_once 'HTMLPurifier/Lexer/DirectLex.php';
|
||||
require_once 'HTMLPurifier/Lexer/PEARSax3.php';
|
||||
|
||||
class Test_HTMLPurifier_Lexer extends UnitTestCase
|
||||
{
|
||||
|
||||
var $HTMLPurifier_Lexer;
|
||||
var $HTMLPurifier_Lexer_Sax;
|
||||
var $DirectLex;
|
||||
var $PEARSax3;
|
||||
|
||||
function setUp() {
|
||||
$this->HTMLPurifier_Lexer =& new HTMLPurifier_Lexer();
|
||||
$this->HTMLPurifier_Lexer_Sax =& new HTMLPurifier_Lexer_Sax();
|
||||
$this->DirectLex =& new HTMLPurifier_Lexer_DirectLex();
|
||||
$this->PEARSax3 =& new HTMLPurifier_Lexer_PEARSax3();
|
||||
}
|
||||
|
||||
function test_nextWhiteSpace() {
|
||||
$HP =& $this->HTMLPurifier_Lexer;
|
||||
$HP =& $this->DirectLex;
|
||||
$this->assertIdentical(false, $HP->nextWhiteSpace('asdf'));
|
||||
$this->assertIdentical(0, $HP->nextWhiteSpace(' asdf'));
|
||||
$this->assertIdentical(0, $HP->nextWhiteSpace("\nasdf"));
|
||||
@@ -28,7 +25,7 @@ class Test_HTMLPurifier_Lexer extends UnitTestCase
|
||||
}
|
||||
|
||||
function test_parseData() {
|
||||
$HP =& $this->HTMLPurifier_Lexer;
|
||||
$HP =& $this->DirectLex;
|
||||
$this->assertIdentical('asdf', $HP->parseData('asdf'));
|
||||
$this->assertIdentical('&', $HP->parseData('&'));
|
||||
$this->assertIdentical('"', $HP->parseData('"'));
|
||||
@@ -146,12 +143,12 @@ class Test_HTMLPurifier_Lexer extends UnitTestCase
|
||||
// SAX chokes on this? We do have entity parsing on, so it should work!
|
||||
|
||||
foreach($input as $i => $discard) {
|
||||
$result = $this->HTMLPurifier_Lexer->tokenizeHTML($input[$i]);
|
||||
$result = $this->DirectLex->tokenizeHTML($input[$i]);
|
||||
$this->assertEqual($expect[$i], $result);
|
||||
paintIf($result, $expect[$i] != $result);
|
||||
|
||||
// assert unless I say otherwise
|
||||
$sax_result = $this->HTMLPurifier_Lexer_Sax->tokenizeHTML($input[$i]);
|
||||
$sax_result = $this->PEARSax3->tokenizeHTML($input[$i]);
|
||||
if (!isset($sax_expect[$i])) {
|
||||
// by default, assert with normal result
|
||||
$this->assertEqual($expect[$i], $sax_result);
|
||||
@@ -193,7 +190,7 @@ class Test_HTMLPurifier_Lexer extends UnitTestCase
|
||||
|
||||
$size = count($input);
|
||||
for($i = 0; $i < $size; $i++) {
|
||||
$result = $this->HTMLPurifier_Lexer->tokenizeAttributeString($input[$i]);
|
||||
$result = $this->DirectLex->tokenizeAttributeString($input[$i]);
|
||||
$this->assertEqual($expect[$i], $result);
|
||||
paintIf($result, $expect[$i] != $result);
|
||||
}
|
||||
|
@@ -5,8 +5,6 @@ load_simpletest(); // includes all relevant simpletest files
|
||||
// emulates inserting a dir called HTMLPurifier into your class dir
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . '../../');
|
||||
|
||||
require_once 'XML/HTMLSax3.php'; // optional PEAR class
|
||||
|
||||
$test = new GroupTest('HTMLPurifier');
|
||||
|
||||
$test->addTestFile('HTMLPurifier.php');
|
||||
|
Reference in New Issue
Block a user