mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-12 16:38:40 +00:00
bb08f679f0
- Work around unnecessary DOMElement type-cast in PH5P that caused errors in PHP 5.1 - Work around PHP 4 SimpleTest lack-of-error complaining for one-time-only HTMLDefinition errors, this may indicate problems with error-collecting facilities in PHP 5 - Make ErrorCollectorEMock work in both PHP 4 and PHP 5 . tests/multitest.php allows you to test multiple versions by running tests/index.php through multiple interpreters using `phpv` shell script (you must provide this script!) . Minor cosmetic change to flush-definition-cache.php: trailing newline is outputted . Maintenance script for generating PH5P patch added, original PH5P source file also added under version control . Full unit test runner script title made more descriptive with PHP version git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1440 48356398-32a2-884e-a903-53898d9a118a
56 lines
1.5 KiB
PHP
56 lines
1.5 KiB
PHP
<?php
|
|
|
|
require_once 'HTMLPurifier/ErrorCollector.php';
|
|
|
|
generate_mock_once('HTMLPurifier_ErrorCollector');
|
|
|
|
/**
|
|
* Extended error collector mock that has the ability to expect context
|
|
*/
|
|
class HTMLPurifier_ErrorCollectorEMock extends HTMLPurifier_ErrorCollectorMock
|
|
{
|
|
|
|
var $_context;
|
|
var $_expected_context = array();
|
|
var $_expected_context_at = array();
|
|
|
|
function prepare(&$context) {
|
|
$this->_context =& $context;
|
|
}
|
|
|
|
function expectContext($key, $value) {
|
|
$this->_expected_context[$key] = $value;
|
|
}
|
|
function expectContextAt($step, $key, $value) {
|
|
$this->_expected_context_at[$step][$key] = $value;
|
|
}
|
|
|
|
function send() {
|
|
// test for context
|
|
$context =& SimpleTest::getContext();
|
|
$test =& $context->getTest();
|
|
|
|
// compat
|
|
if (empty($this->_mock)) {
|
|
$mock =& $this;
|
|
} else {
|
|
$mock =& $this->_mock;
|
|
}
|
|
|
|
foreach ($this->_expected_context as $key => $value) {
|
|
$test->assertEqual($value, $this->_context->get($key));
|
|
}
|
|
$step = $mock->getCallCount('send');
|
|
if (isset($this->_expected_context_at[$step])) {
|
|
foreach ($this->_expected_context_at[$step] as $key => $value) {
|
|
$test->assertEqual($value, $this->_context->get($key));
|
|
}
|
|
}
|
|
// boilerplate mock code, does not have return value or references
|
|
$args = func_get_args();
|
|
$mock->_invoke('send', $args);
|
|
}
|
|
|
|
}
|
|
|