lexer = new HTMLPurifier_Lexer_DirectLex(); $this->generator = new HTMLPurifier_Generator(); parent::HTMLPurifier_Harness(); } /** * Asserts a specific result from a one parameter + config/context function * @param $input Input parameter * @param $expect Expectation * @param $config Configuration array in form of Ns.Directive => Value. * Has no effect if $this->config is set. * @param $context_array Context array in form of Key => Value or an actual * context object. */ function assertResult($input, $expect = true, $config_array = array(), $context_array = array() ) { // setup config if ($this->config) { $config = HTMLPurifier_Config::create($this->config); $config->loadArray($config_array); } else { $config = HTMLPurifier_Config::create($config_array); } // setup context object. Note that we are operating on a copy of it! // When necessary, extend the test harness to allow post-tests // on the context object if (empty($this->context)) { $context = new HTMLPurifier_Context(); $context->loadArray($context_array); } else { $context =& $this->context; } if ($this->to_tokens && is_string($input)) { // $func may cause $input to change, so "clone" another copy // to sacrifice $input = $this->lexer->tokenizeHTML($s = $input, $config, $context); $input_c = $this->lexer->tokenizeHTML($s, $config, $context); } else { $input_c = $input; } // call the function $func = $this->func; $result = $this->obj->$func($input_c, $config, $context); // test a bool result if (is_bool($result)) { $this->assertIdentical($expect, $result); return; } elseif (is_bool($expect)) { $expect = $input; } if ($this->to_html) { $result = $this->generator-> generateFromTokens($result, $config, $context); if (is_array($expect)) { $expect = $this->generator-> generateFromTokens($expect, $config, $context); } } $this->assertIdentical($expect, $result); } }