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);
|
|
|
|
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;
|
|
|
|
$aliases = array(
|
|
|
|
'f' => 'file',
|
|
|
|
'q' => 'quiet',
|
|
|
|
);
|
|
|
|
htmlpurifier_parse_args($AC, $aliases);
|
2007-11-05 05:01:51 +00:00
|
|
|
|
2008-02-10 23:05:28 +00:00
|
|
|
// Calls generate-includes.php automatically
|
2008-01-07 00:17:49 +00:00
|
|
|
shell_exec("php ../maintenance/merge-library.php");
|
2008-02-10 23:05:28 +00:00
|
|
|
|
|
|
|
// Not strictly necessary, but its a good idea
|
|
|
|
shell_exec("php ../maintenance/generate-schema-cache.php");
|
2008-01-07 00:17:49 +00:00
|
|
|
shell_exec('php ../maintenance/flush-definition-cache.php');
|
2007-11-06 03:34:45 +00:00
|
|
|
|
2008-01-07 00:17:49 +00:00
|
|
|
$test = new TestSuite('HTML Purifier Multiple Versions Test');
|
|
|
|
$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 {
|
|
|
|
echo "Invalid file passed\n";
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
}
|
2008-01-21 20:27:26 +00:00
|
|
|
// This allows us to get out of having to do dry runs.
|
|
|
|
$size = count($test_files);
|
|
|
|
|
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-01-21 20:27:26 +00:00
|
|
|
if (!$AC['exclude-normal']) $test->addTestCase(new CliTestCase("$phpv $version index.php --xml $flush $file", $AC['quiet'], $size));
|
|
|
|
if (!$AC['exclude-standalone']) $test->addTestCase(new CliTestCase("$phpv $version index.php --xml --standalone $file", $AC['quiet'], $size));
|
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.
|
|
|
|
$test->addTestCase(new RemoteTestCase('http://localhost/htmlpurifier/tests/?xml', 'http://localhost/htmlpurifier/tests/?xml&dry'));
|
|
|
|
|
2008-01-07 00:17:49 +00:00
|
|
|
if ($AC['xml']) {
|
|
|
|
$reporter = new XmlReporter();
|
|
|
|
} else {
|
|
|
|
$reporter = new TextReporter();
|
|
|
|
}
|
|
|
|
$test->run($reporter);
|
|
|
|
|
|
|
|
shell_exec('php ../maintenance/flush-definition-cache.php');
|