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
|
|
|
|
|
2007-01-19 23:26:15 +00:00
|
|
|
define('HTMLPurifierTest', 1);
|
2007-09-03 15:16:33 +00:00
|
|
|
define('HTMLPURIFIER_SCHEMA_STRICT', true); // validate schemas
|
2006-07-23 00:11:03 +00:00
|
|
|
|
2008-01-06 19:31:21 +00:00
|
|
|
require_once 'common.php';
|
2007-12-12 21:46:30 +00:00
|
|
|
|
2008-01-06 19:31:21 +00:00
|
|
|
// clean out cache if necessary
|
|
|
|
if (isset($_GET['flush'])) shell_exec('php ../maintenance/flush-definition-cache.php');
|
2006-08-10 12:41:39 +00:00
|
|
|
|
2007-01-19 23:26:15 +00:00
|
|
|
// initialize and load HTML Purifier
|
2007-07-30 16:56:50 +00:00
|
|
|
// use ?standalone to load the alterative standalone stub
|
|
|
|
if (isset($_GET['standalone']) || (isset($argv[1]) && $argv[1] == 'standalone')) {
|
|
|
|
set_include_path(realpath('blanks') . PATH_SEPARATOR . get_include_path());
|
|
|
|
require_once '../library/HTMLPurifier.standalone.php';
|
|
|
|
} else {
|
|
|
|
require_once '../library/HTMLPurifier.auto.php';
|
|
|
|
}
|
2007-08-02 01:12:27 +00:00
|
|
|
require_once 'HTMLPurifier/Harness.php';
|
2006-08-11 20:23:41 +00:00
|
|
|
|
2007-05-29 20:21:33 +00:00
|
|
|
// setup special DefinitionCacheFactory decorator
|
|
|
|
$factory =& HTMLPurifier_DefinitionCacheFactory::instance();
|
|
|
|
$factory->addDecorator('Memory'); // since we deal with a lot of config objects
|
|
|
|
|
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-11-05 05:01:51 +00:00
|
|
|
$test = new GroupTest('All HTML Purifier tests on PHP ' . PHP_VERSION);
|
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);
|