mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2025-08-06 14:16:32 +02:00
[1.2.0]
- All important classes that use Context were migrated. Todo: Classes that currently use $config but not $context are AttrTransform (done in r493) and URIScheme+Registry (done in r500). There may be more classes, incl TagTransform (done in r497) that should have both $config and $context added. - Strategy unit tests now migrated to use HTMLPurifier_Harness git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@485 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
@@ -1,41 +1,14 @@
|
||||
<?php
|
||||
|
||||
require_once 'HTMLPurifier/Lexer/DirectLex.php';
|
||||
require_once 'HTMLPurifier/Harness.php';
|
||||
|
||||
class HTMLPurifier_StrategyHarness extends UnitTestCase
|
||||
class HTMLPurifier_StrategyHarness extends HTMLPurifier_Harness
|
||||
{
|
||||
|
||||
var $lex, $gen;
|
||||
|
||||
function HTMLPurifier_StrategyHarness() {
|
||||
$this->UnitTestCase();
|
||||
|
||||
// we can't use the DOM lexer since it does too much stuff
|
||||
// automatically, however, we should be able to use it
|
||||
// interchangeably if we wanted to...
|
||||
|
||||
if (true) {
|
||||
$this->lex = new HTMLPurifier_Lexer_DirectLex();
|
||||
} else {
|
||||
require_once 'HTMLPurifier/Lexer/DOMLex.php';
|
||||
$this->lex = new HTMLPurifier_Lexer_DOMLex();
|
||||
}
|
||||
|
||||
$this->gen = new HTMLPurifier_Generator();
|
||||
}
|
||||
|
||||
function assertStrategyWorks($strategy, $inputs, $expect, $config = array()) {
|
||||
$context = new HTMLPurifier_Context();
|
||||
foreach ($inputs as $i => $input) {
|
||||
if (!isset($config[$i])) {
|
||||
$config[$i] = HTMLPurifier_Config::createDefault();
|
||||
}
|
||||
$tokens = $this->lex->tokenizeHTML($input, $config[$i], $context);
|
||||
$result_tokens = $strategy->execute($tokens, $config[$i], $context);
|
||||
$result = $this->gen->generateFromTokens($result_tokens, $config[$i]);
|
||||
$this->assertEqual($expect[$i], $result, "Test $i: %s");
|
||||
paintIf($result, $result != $expect[$i]);
|
||||
}
|
||||
function setUp() {
|
||||
$this->func = 'execute';
|
||||
$this->to_tokens = true;
|
||||
$this->to_html = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user