2007-11-05 05:01:51 +00:00
|
|
|
<?php
|
|
|
|
|
2008-01-05 00:10:43 +00:00
|
|
|
/** @file
|
|
|
|
* Multiple PHP Versions test
|
|
|
|
*
|
2008-01-07 00:17:49 +00:00
|
|
|
* This file tests HTML Purifier in all versions of PHP. Arguments
|
|
|
|
* are specified like --arg=opt, allowed arguments are:
|
|
|
|
* - exclude-normal, excludes normal tests
|
|
|
|
* - exclude-standalone, excludes standalone tests
|
|
|
|
* - file (f), specifies a single file to test for all versions
|
|
|
|
* - xml, if specified output is XML
|
|
|
|
* - quiet (q), if specified no informative messages are enabled (please use
|
|
|
|
* this if you're outputting XML)
|
|
|
|
*
|
|
|
|
* @note
|
|
|
|
* It requires a script called phpv that takes an extra argument (the
|
|
|
|
* version number of PHP) before all other arguments. Contact me if you'd
|
|
|
|
* like to set up a similar script. The name of the script can be
|
|
|
|
* edited with $phpv
|
|
|
|
*
|
|
|
|
* @note
|
|
|
|
* Also, configuration must be set up with a variable called
|
|
|
|
* $versions_to_test specifying version numbers to pass to $phpv
|
2008-01-05 00:10:43 +00:00
|
|
|
*/
|
|
|
|
|
2008-01-07 00:17:49 +00:00
|
|
|
define('HTMLPurifierTest', 1);
|
2008-04-15 03:33:09 +00:00
|
|
|
$php = 'php'; // for safety
|
|
|
|
|
2008-01-07 00:17:49 +00:00
|
|
|
require_once 'common.php';
|
2007-11-05 05:01:51 +00:00
|
|
|
|
2008-01-07 00:17:49 +00:00
|
|
|
if (!SimpleReporter::inCli()) {
|
|
|
|
echo 'Multitest only available from command line';
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
$AC = array(); // parameters
|
|
|
|
$AC['exclude-normal'] = false;
|
|
|
|
$AC['exclude-standalone'] = false;
|
2008-01-21 20:27:26 +00:00
|
|
|
$AC['file'] = '';
|
|
|
|
$AC['xml'] = false;
|
2008-01-07 00:17:49 +00:00
|
|
|
$AC['quiet'] = false;
|
2008-04-15 03:33:09 +00:00
|
|
|
$AC['php'] = $php;
|
2008-02-17 01:12:30 +00:00
|
|
|
$AC['disable-phpt'] = false;
|
|
|
|
$AC['only-phpt'] = false;
|
2008-01-07 00:17:49 +00:00
|
|
|
$aliases = array(
|
|
|
|
'f' => 'file',
|
|
|
|
'q' => 'quiet',
|
|
|
|
);
|
|
|
|
htmlpurifier_parse_args($AC, $aliases);
|
2007-11-05 05:01:51 +00:00
|
|
|
|
2008-04-03 21:24:16 +00:00
|
|
|
if ($AC['xml']) {
|
|
|
|
$reporter = new XmlReporter();
|
|
|
|
} else {
|
|
|
|
$reporter = new TextReporter();
|
|
|
|
}
|
|
|
|
|
2008-02-24 05:06:39 +00:00
|
|
|
// Regenerate any necessary files
|
2008-04-03 21:24:16 +00:00
|
|
|
htmlpurifier_flush($AC['php'], $reporter);
|
2007-11-06 03:34:45 +00:00
|
|
|
|
2008-01-07 00:17:49 +00:00
|
|
|
$file = '';
|
2008-01-21 20:27:26 +00:00
|
|
|
|
|
|
|
$test_files = array();
|
|
|
|
require 'test_files.php';
|
2008-01-07 00:17:49 +00:00
|
|
|
if ($AC['file']) {
|
|
|
|
$test_files_lookup = array_flip($test_files);
|
|
|
|
if (isset($test_files_lookup[$AC['file']])) {
|
|
|
|
$file = '--file=' . $AC['file'];
|
|
|
|
} else {
|
2008-04-03 21:24:16 +00:00
|
|
|
throw new Exception("Invalid file passed");
|
2008-01-07 00:17:49 +00:00
|
|
|
}
|
|
|
|
}
|
2008-01-21 20:27:26 +00:00
|
|
|
// This allows us to get out of having to do dry runs.
|
|
|
|
$size = count($test_files);
|
|
|
|
|
2008-04-03 21:24:16 +00:00
|
|
|
// Setup the test
|
|
|
|
$test = new TestSuite('HTML Purifier Multiple Versions Test');
|
2007-11-05 05:01:51 +00:00
|
|
|
foreach ($versions_to_test as $version) {
|
2008-01-07 00:17:49 +00:00
|
|
|
$flush = '';
|
|
|
|
if (is_array($version)) {
|
|
|
|
$version = $version[0];
|
|
|
|
$flush = '--flush';
|
2007-11-05 05:25:59 +00:00
|
|
|
}
|
2008-02-17 01:12:30 +00:00
|
|
|
if (!$AC['only-phpt']) {
|
|
|
|
if (!$AC['exclude-normal']) {
|
2008-04-15 03:33:09 +00:00
|
|
|
$test->add(
|
2008-02-17 01:12:30 +00:00
|
|
|
new CliTestCase(
|
|
|
|
"$phpv $version index.php --xml $flush --disable-phpt $file",
|
|
|
|
$AC['quiet'], $size
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (!$AC['exclude-standalone']) {
|
2008-04-15 03:33:09 +00:00
|
|
|
$test->add(
|
2008-02-17 01:12:30 +00:00
|
|
|
new CliTestCase(
|
|
|
|
"$phpv $version index.php --xml $flush --standalone --disable-phpt $file",
|
|
|
|
$AC['quiet'], $size
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
2008-02-16 18:03:51 +00:00
|
|
|
}
|
2008-02-17 01:12:30 +00:00
|
|
|
if (!$AC['disable-phpt']) { // naming is not consistent
|
2008-04-15 03:33:09 +00:00
|
|
|
$test->add(
|
2008-02-16 18:03:51 +00:00
|
|
|
new CliTestCase(
|
2008-02-16 23:23:45 +00:00
|
|
|
$AC['php'] . " index.php --xml --php \"$phpv $version\" --only-phpt",
|
2008-02-16 18:03:51 +00:00
|
|
|
$AC['quiet'], $size
|
|
|
|
)
|
|
|
|
);
|
2008-02-17 01:12:30 +00:00
|
|
|
}
|
2007-11-05 05:01:51 +00:00
|
|
|
}
|
2008-01-07 00:17:49 +00:00
|
|
|
|
2008-01-21 20:27:26 +00:00
|
|
|
// This is the HTML Purifier website's test XML file. We could
|
|
|
|
// add more websites, i.e. more configurations to test.
|
2008-04-15 03:33:09 +00:00
|
|
|
// $test->add(new RemoteTestCase('http://htmlpurifier.org/dev/tests/?xml=1', 'http://htmlpurifier.org/dev/tests/?xml=1&dry=1&flush=1'));
|
2008-01-21 20:27:26 +00:00
|
|
|
|
2008-01-07 00:17:49 +00:00
|
|
|
$test->run($reporter);
|