2006-07-23 00:11:03 +00:00
|
|
|
<?php
|
|
|
|
|
2007-01-19 03:54:55 +00:00
|
|
|
// call one file using /?f=FileTest.php , see $test_files array for
|
|
|
|
// valid values
|
|
|
|
|
2006-07-23 00:11:03 +00:00
|
|
|
error_reporting(E_ALL);
|
2007-01-19 23:26:15 +00:00
|
|
|
define('HTMLPurifierTest', 1);
|
2006-07-23 00:11:03 +00:00
|
|
|
|
2006-08-02 02:24:03 +00:00
|
|
|
// wishlist: automated calling of this file from multiple PHP versions so we
|
|
|
|
// don't have to constantly switch around
|
|
|
|
|
2007-01-19 23:26:15 +00:00
|
|
|
// default settings (protect against register_globals)
|
2007-01-19 23:02:28 +00:00
|
|
|
$GLOBALS['HTMLPurifierTest'] = array();
|
2006-08-10 12:41:39 +00:00
|
|
|
$GLOBALS['HTMLPurifierTest']['PEAR'] = false; // do PEAR tests
|
2007-01-19 23:26:15 +00:00
|
|
|
$simpletest_location = 'simpletest/'; // reasonable guess
|
2006-08-10 12:41:39 +00:00
|
|
|
|
2007-01-19 23:26:15 +00:00
|
|
|
// load SimpleTest
|
|
|
|
@include '../test-settings.php'; // don't mind if it isn't there
|
2006-08-10 12:22:55 +00:00
|
|
|
require_once $simpletest_location . 'unit_tester.php';
|
|
|
|
require_once $simpletest_location . 'reporter.php';
|
|
|
|
require_once $simpletest_location . 'mock_objects.php';
|
2007-01-19 23:26:15 +00:00
|
|
|
require_once 'HTMLPurifier/SimpleTest/Reporter.php';
|
|
|
|
|
|
|
|
// load Debugger
|
|
|
|
require_once 'Debugger.php';
|
2006-07-23 00:11:03 +00:00
|
|
|
|
2007-01-19 23:26:15 +00:00
|
|
|
// load convenience functions
|
|
|
|
require_once 'generate_mock_once.func.php';
|
|
|
|
require_once 'path2class.func.php';
|
2007-01-21 04:37:02 +00:00
|
|
|
require_once 'tally_errors.func.php'; // compat
|
2007-01-19 23:26:15 +00:00
|
|
|
|
|
|
|
// initialize PEAR (optional)
|
2006-08-10 12:41:39 +00:00
|
|
|
if ( is_string($GLOBALS['HTMLPurifierTest']['PEAR']) ) {
|
2007-01-19 23:26:15 +00:00
|
|
|
// if PEAR is true, we assume that there's no need to
|
|
|
|
// add it to the path
|
2006-08-10 12:41:39 +00:00
|
|
|
set_include_path($GLOBALS['HTMLPurifierTest']['PEAR'] . PATH_SEPARATOR .
|
|
|
|
get_include_path());
|
|
|
|
}
|
|
|
|
|
2007-01-19 23:26:15 +00:00
|
|
|
// initialize and load HTML Purifier
|
2007-05-28 02:29:48 +00:00
|
|
|
require_once '../library/HTMLPurifier.auto.php';
|
2006-08-11 20:23:41 +00:00
|
|
|
|
2007-01-19 23:26:15 +00:00
|
|
|
// load tests
|
2006-08-05 02:28:35 +00:00
|
|
|
$test_files = array();
|
2007-01-19 23:26:15 +00:00
|
|
|
require 'test_files.php'; // populates $test_files array
|
|
|
|
sort($test_files); // for the SELECT
|
|
|
|
$GLOBALS['HTMLPurifierTest']['Files'] = $test_files; // for the reporter
|
2006-08-05 02:28:35 +00:00
|
|
|
$test_file_lookup = array_flip($test_files);
|
|
|
|
|
2007-01-19 23:26:15 +00:00
|
|
|
// determine test file
|
2007-01-19 03:54:55 +00:00
|
|
|
if (isset($_GET['f']) && isset($test_file_lookup[$_GET['f']])) {
|
2007-01-19 23:02:28 +00:00
|
|
|
$GLOBALS['HTMLPurifierTest']['File'] = $_GET['f'];
|
2007-02-15 00:17:23 +00:00
|
|
|
} elseif (isset($argv[1]) && isset($test_file_lookup[$argv[1]])) {
|
|
|
|
// command-line
|
|
|
|
$GLOBALS['HTMLPurifierTest']['File'] = $argv[1];
|
2007-01-19 23:02:28 +00:00
|
|
|
} else {
|
|
|
|
$GLOBALS['HTMLPurifierTest']['File'] = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// we can't use addTestFile because SimpleTest chokes on E_STRICT warnings
|
|
|
|
if ($test_file = $GLOBALS['HTMLPurifierTest']['File']) {
|
2006-08-05 02:28:35 +00:00
|
|
|
|
2007-05-28 02:29:48 +00:00
|
|
|
$test = new GroupTest($test_file);
|
|
|
|
require_once $test_file;
|
|
|
|
$test->addTestClass(path2class($test_file));
|
2006-08-05 02:28:35 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2007-05-28 02:29:48 +00:00
|
|
|
$test = new GroupTest('All Tests');
|
2006-08-05 02:28:35 +00:00
|
|
|
|
|
|
|
foreach ($test_files as $test_file) {
|
2007-05-28 02:29:48 +00:00
|
|
|
require_once $test_file;
|
|
|
|
$test->addTestClass(path2class($test_file));
|
2006-08-05 02:28:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2006-07-23 00:11:03 +00:00
|
|
|
|
2006-08-01 00:18:22 +00:00
|
|
|
if (SimpleReporter::inCli()) $reporter = new TextReporter();
|
2007-01-19 23:02:28 +00:00
|
|
|
else $reporter = new HTMLPurifier_SimpleTest_Reporter('UTF-8');
|
2006-08-01 00:18:22 +00:00
|
|
|
|
|
|
|
$test->run($reporter);
|
2006-07-23 00:11:03 +00:00
|
|
|
|
2006-08-11 20:23:41 +00:00
|
|
|
?>
|