mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-01-03 05:11:52 +00:00
Standardize test-cases with the prefix Test_. Add framework for HTML_Purifier, its unit test will really only be for regression testing from integration issues. It's more important to test the components.
git-svn-id: http://htmlpurifier.org/svnroot/html_purifier/trunk@35 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
69da034570
commit
1a3887de1b
@ -3,7 +3,23 @@
|
|||||||
class HTML_Purifier
|
class HTML_Purifier
|
||||||
{
|
{
|
||||||
|
|
||||||
|
var $lexer;
|
||||||
|
var $definition;
|
||||||
|
var $generator;
|
||||||
|
|
||||||
|
function HTML_Purifier() {
|
||||||
|
$this->lexer = new HTML_Lexer();
|
||||||
|
$this->definition = new PureHTMLDefinition();
|
||||||
|
$this->generator = new HTML_Generator();
|
||||||
|
}
|
||||||
|
|
||||||
|
function purify($html) {
|
||||||
|
|
||||||
|
$tokens = $this->lexer->tokenizeHTML($html);
|
||||||
|
$tokens = $this->definition->purifyTokens($tokens);
|
||||||
|
return $this->generator->generateFromTokens($tokens);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class UnitTest_HTML_Generator extends UnitTestCase
|
class Test_HTML_Generator extends UnitTestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
var $gen;
|
var $gen;
|
||||||
|
|
||||||
function UnitTest_HTML_Generator() {
|
function Test_HTML_Generator() {
|
||||||
$this->UnitTestCase();
|
$this->UnitTestCase();
|
||||||
$this->gen = new HTML_Generator();
|
$this->gen = new HTML_Generator();
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
* Benchmark the SAX parser with my homemade one
|
* Benchmark the SAX parser with my homemade one
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class TestCase_HTML_Lexer extends UnitTestCase
|
class Test_HTML_Lexer extends UnitTestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
var $HTML_Lexer;
|
var $HTML_Lexer;
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class TestCase_HTML_Purifier extends UnitTestCase
|
class Test_HTML_Purifier extends UnitTestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
|
function Test_HTML_Purifier() {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class UnitTest_PureHTMLDefinition extends UnitTestCase
|
class Test_PureHTMLDefinition extends UnitTestCase
|
||||||
{
|
{
|
||||||
|
|
||||||
var $def;
|
var $def;
|
||||||
|
|
||||||
function UnitTest_PureHTMLDefinition() {
|
function Test_PureHTMLDefinition() {
|
||||||
$this->UnitTestCase();
|
$this->UnitTestCase();
|
||||||
$this->def = new PureHTMLDefinition();
|
$this->def = new PureHTMLDefinition();
|
||||||
$this->def->loadData();
|
$this->def->loadData();
|
||||||
|
Loading…
Reference in New Issue
Block a user