123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- <?php
- class HTMLPurifier_ComplexHarness extends HTMLPurifier_Harness
- {
-
- protected $obj;
-
- protected $func;
-
- protected $to_tokens = false;
-
- protected $to_html = false;
-
- protected $lexer;
- public function __construct() {
- $this->lexer = new HTMLPurifier_Lexer_DirectLex();
- parent::__construct();
- }
-
- protected function assertResult($input, $expect = true) {
- if ($this->to_tokens && is_string($input)) {
-
-
- $input = $this->tokenize($temp = $input);
- $input_c = $this->tokenize($temp);
- } else {
- $input_c = $input;
- }
-
- $func = $this->func;
- $result = $this->obj->$func($input_c, $this->config, $this->context);
-
- if (is_bool($result)) {
- $this->assertIdentical($expect, $result);
- return;
- } elseif (is_bool($expect)) {
- $expect = $input;
- }
- if ($this->to_html) {
- $result = $this->generate($result);
- if (is_array($expect)) {
- $expect = $this->generate($expect);
- }
- }
- $this->assertIdentical($expect, $result);
- if ($expect !== $result) {
- echo '<pre>' . var_dump($result) . '</pre>';
- }
- }
-
- protected function tokenize($html) {
- return $this->lexer->tokenizeHTML($html, $this->config, $this->context);
- }
-
- protected function generate($tokens) {
- $generator = new HTMLPurifier_Generator($this->config, $this->context);
- return $generator->generateFromTokens($tokens);
- }
- }
|