2006-07-23 00:11:03 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
error_reporting(E_ALL);
|
|
|
|
|
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
|
|
|
|
|
2006-08-10 12:41:39 +00:00
|
|
|
// configuration
|
|
|
|
$GLOBALS['HTMLPurifierTest']['PEAR'] = false; // do PEAR tests
|
|
|
|
|
2006-08-10 12:22:55 +00:00
|
|
|
$simpletest_location = 'simpletest/';
|
2006-08-28 20:28:19 +00:00
|
|
|
if (file_exists('../test-settings.php')) include_once '../test-settings.php';
|
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';
|
2006-07-23 00:11:03 +00:00
|
|
|
|
2006-08-10 12:41:39 +00:00
|
|
|
// configure PEAR if necessary
|
|
|
|
if ( is_string($GLOBALS['HTMLPurifierTest']['PEAR']) ) {
|
|
|
|
set_include_path($GLOBALS['HTMLPurifierTest']['PEAR'] . PATH_SEPARATOR .
|
|
|
|
get_include_path());
|
|
|
|
}
|
|
|
|
|
2006-08-10 12:22:55 +00:00
|
|
|
// debugger
|
2006-07-23 00:11:03 +00:00
|
|
|
require_once 'Debugger.php';
|
|
|
|
|
|
|
|
// emulates inserting a dir called HTMLPurifier into your class dir
|
2006-08-10 12:41:39 +00:00
|
|
|
set_include_path('../library' . PATH_SEPARATOR . get_include_path());
|
2006-07-23 00:11:03 +00:00
|
|
|
|
2006-07-29 17:38:28 +00:00
|
|
|
// since Mocks can't be called from within test files, we need to do
|
|
|
|
// a little jumping through hoops to generate them
|
|
|
|
function generate_mock_once($name) {
|
|
|
|
$mock_name = $name . 'Mock';
|
|
|
|
if (class_exists($mock_name)) return false;
|
|
|
|
Mock::generate($name, $mock_name);
|
|
|
|
}
|
|
|
|
|
2006-08-11 20:23:41 +00:00
|
|
|
// this has to be defined before we do any includes of library files
|
2006-08-28 02:25:19 +00:00
|
|
|
require_once 'HTMLPurifier.php';
|
2006-08-11 20:23:41 +00:00
|
|
|
|
2006-08-05 02:28:35 +00:00
|
|
|
// define callable test files
|
|
|
|
$test_files = array();
|
2006-08-11 20:23:41 +00:00
|
|
|
$test_files[] = 'ConfigTest.php';
|
2006-09-16 22:36:58 +00:00
|
|
|
$test_files[] = 'ConfigSchemaTest.php';
|
2006-08-05 02:28:35 +00:00
|
|
|
$test_files[] = 'LexerTest.php';
|
|
|
|
$test_files[] = 'Lexer/DirectLexTest.php';
|
2006-08-11 20:23:41 +00:00
|
|
|
$test_files[] = 'TokenTest.php';
|
2006-11-22 18:55:15 +00:00
|
|
|
$test_files[] = 'ChildDef/RequiredTest.php';
|
|
|
|
$test_files[] = 'ChildDef/OptionalTest.php';
|
|
|
|
$test_files[] = 'ChildDef/ChameleonTest.php';
|
|
|
|
$test_files[] = 'ChildDef/CustomTest.php';
|
|
|
|
$test_files[] = 'ChildDef/TableTest.php';
|
2006-11-23 03:23:35 +00:00
|
|
|
$test_files[] = 'ChildDef/StrictBlockquoteTest.php';
|
2006-08-05 02:28:35 +00:00
|
|
|
$test_files[] = 'GeneratorTest.php';
|
|
|
|
$test_files[] = 'EntityLookupTest.php';
|
|
|
|
$test_files[] = 'Strategy/RemoveForeignElementsTest.php';
|
|
|
|
$test_files[] = 'Strategy/MakeWellFormedTest.php';
|
|
|
|
$test_files[] = 'Strategy/FixNestingTest.php';
|
|
|
|
$test_files[] = 'Strategy/CompositeTest.php';
|
|
|
|
$test_files[] = 'Strategy/CoreTest.php';
|
|
|
|
$test_files[] = 'Strategy/ValidateAttributesTest.php';
|
|
|
|
$test_files[] = 'AttrDefTest.php';
|
|
|
|
$test_files[] = 'AttrDef/EnumTest.php';
|
|
|
|
$test_files[] = 'AttrDef/IDTest.php';
|
|
|
|
$test_files[] = 'AttrDef/ClassTest.php';
|
|
|
|
$test_files[] = 'AttrDef/TextTest.php';
|
|
|
|
$test_files[] = 'AttrDef/LangTest.php';
|
2006-08-06 01:03:48 +00:00
|
|
|
$test_files[] = 'AttrDef/PixelsTest.php';
|
2006-08-06 01:30:54 +00:00
|
|
|
$test_files[] = 'AttrDef/LengthTest.php';
|
2006-08-12 01:12:35 +00:00
|
|
|
$test_files[] = 'AttrDef/URITest.php';
|
2006-08-12 20:22:09 +00:00
|
|
|
$test_files[] = 'AttrDef/CSSTest.php';
|
2006-08-13 18:16:30 +00:00
|
|
|
$test_files[] = 'AttrDef/CompositeTest.php';
|
2006-08-13 21:23:57 +00:00
|
|
|
$test_files[] = 'AttrDef/ColorTest.php';
|
2006-08-13 21:59:52 +00:00
|
|
|
$test_files[] = 'AttrDef/IntegerTest.php';
|
2006-08-13 22:35:55 +00:00
|
|
|
$test_files[] = 'AttrDef/NumberTest.php';
|
2006-08-13 23:08:38 +00:00
|
|
|
$test_files[] = 'AttrDef/CSSLengthTest.php';
|
2006-08-14 02:08:45 +00:00
|
|
|
$test_files[] = 'AttrDef/PercentageTest.php';
|
2006-08-16 00:34:37 +00:00
|
|
|
$test_files[] = 'AttrDef/MultipleTest.php';
|
2006-08-16 15:12:48 +00:00
|
|
|
$test_files[] = 'AttrDef/TextDecorationTest.php';
|
2006-08-16 17:25:25 +00:00
|
|
|
$test_files[] = 'AttrDef/FontFamilyTest.php';
|
2006-08-17 01:05:35 +00:00
|
|
|
$test_files[] = 'AttrDef/HostTest.php';
|
|
|
|
$test_files[] = 'AttrDef/IPv4Test.php';
|
|
|
|
$test_files[] = 'AttrDef/IPv6Test.php';
|
2006-08-27 00:11:13 +00:00
|
|
|
$test_files[] = 'AttrDef/FontTest.php';
|
2006-08-27 00:49:34 +00:00
|
|
|
$test_files[] = 'AttrDef/BorderTest.php';
|
2006-08-29 02:01:58 +00:00
|
|
|
$test_files[] = 'AttrDef/ListStyleTest.php';
|
2006-11-08 03:10:43 +00:00
|
|
|
$test_files[] = 'AttrDef/Email/SimpleCheckTest.php';
|
2007-01-14 15:54:05 +00:00
|
|
|
$test_files[] = 'AttrDef/CSSURITest.php';
|
2006-08-05 02:28:35 +00:00
|
|
|
$test_files[] = 'IDAccumulatorTest.php';
|
|
|
|
$test_files[] = 'TagTransformTest.php';
|
|
|
|
$test_files[] = 'AttrTransform/LangTest.php';
|
2006-08-05 02:56:57 +00:00
|
|
|
$test_files[] = 'AttrTransform/TextAlignTest.php';
|
2006-08-14 23:11:28 +00:00
|
|
|
$test_files[] = 'AttrTransform/BdoDirTest.php';
|
|
|
|
$test_files[] = 'AttrTransform/ImgRequiredTest.php';
|
2006-08-12 03:56:27 +00:00
|
|
|
$test_files[] = 'URISchemeRegistryTest.php';
|
2006-08-12 18:58:54 +00:00
|
|
|
$test_files[] = 'URISchemeTest.php';
|
2006-08-29 19:36:40 +00:00
|
|
|
$test_files[] = 'EncoderTest.php';
|
2006-08-30 02:21:39 +00:00
|
|
|
$test_files[] = 'EntityParserTest.php';
|
2006-09-01 17:56:55 +00:00
|
|
|
$test_files[] = 'Test.php';
|
2006-10-01 18:14:08 +00:00
|
|
|
$test_files[] = 'ContextTest.php';
|
2006-11-07 17:15:28 +00:00
|
|
|
$test_files[] = 'PercentEncoderTest.php';
|
2006-08-05 02:28:35 +00:00
|
|
|
|
2006-08-15 20:19:16 +00:00
|
|
|
if (version_compare(PHP_VERSION, '5', '>=')) {
|
|
|
|
$test_files[] = 'TokenFactoryTest.php';
|
|
|
|
}
|
|
|
|
|
2006-08-05 02:28:35 +00:00
|
|
|
$test_file_lookup = array_flip($test_files);
|
|
|
|
|
2006-08-11 20:23:41 +00:00
|
|
|
function htmlpurifier_path2class($path) {
|
|
|
|
$temp = $path;
|
|
|
|
$temp = str_replace('./', '', $temp); // remove leading './'
|
|
|
|
$temp = str_replace('.\\', '', $temp); // remove leading '.\'
|
|
|
|
$temp = str_replace('\\', '_', $temp); // normalize \ to _
|
|
|
|
$temp = str_replace('/', '_', $temp); // normalize / to _
|
|
|
|
while(strpos($temp, '__') !== false) $temp = str_replace('__', '_', $temp);
|
|
|
|
$temp = str_replace('.php', '', $temp);
|
|
|
|
return $temp;
|
|
|
|
}
|
|
|
|
|
|
|
|
// we can't use addTestFile because SimpleTest chokes on E_STRICT warnings
|
|
|
|
|
2006-08-05 02:28:35 +00:00
|
|
|
if (isset($_GET['file']) && isset($test_file_lookup[$_GET['file']])) {
|
|
|
|
|
|
|
|
// execute only one test
|
|
|
|
$test_file = $_GET['file'];
|
|
|
|
|
2006-09-30 18:55:17 +00:00
|
|
|
$test = new GroupTest('HTML Purifier - ' . $test_file);
|
2006-08-11 20:23:41 +00:00
|
|
|
$path = 'HTMLPurifier/' . $test_file;
|
|
|
|
require_once $path;
|
|
|
|
$test->addTestClass(htmlpurifier_path2class($path));
|
2006-08-05 02:28:35 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
|
2006-09-30 18:55:17 +00:00
|
|
|
$test = new GroupTest('HTML Purifier');
|
2006-08-05 02:28:35 +00:00
|
|
|
|
|
|
|
foreach ($test_files as $test_file) {
|
2006-08-11 20:23:41 +00:00
|
|
|
$path = 'HTMLPurifier/' . $test_file;
|
|
|
|
require_once $path;
|
|
|
|
$test->addTestClass(htmlpurifier_path2class($path));
|
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();
|
2006-08-18 04:24:19 +00:00
|
|
|
else $reporter = new HTMLReporter('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
|
|
|
?>
|