4 * Multiple PHP Versions test
6 * This file tests HTML Purifier in all versions of PHP. Arguments
7 * are specified like --arg=opt, allowed arguments are:
8 * - exclude-normal, excludes normal tests
9 * - exclude-standalone, excludes standalone tests
10 * - file (f), specifies a single file to test for all versions
11 * - xml, if specified output is XML
12 * - quiet (q), if specified no informative messages are enabled (please use
13 * this if you're outputting XML)
16 * It requires a script called phpv that takes an extra argument (the
17 * version number of PHP) before all other arguments. Contact me if you'd
18 * like to set up a similar script. The name of the script can be
22 * Also, configuration must be set up with a variable called
23 * $versions_to_test specifying version numbers to pass to $phpv
26 define('HTMLPurifierTest', 1);
27 $php = 'php'; // for safety
29 require_once 'common.php';
31 if (!SimpleReporter
::inCli()) {
32 echo 'Multitest only available from command line';
36 $AC = array(); // parameters
37 $AC['exclude-normal'] = false;
38 $AC['exclude-standalone'] = false;
43 $AC['disable-phpt'] = false;
44 $AC['only-phpt'] = false;
49 htmlpurifier_parse_args($AC, $aliases);
52 $reporter = new XmlReporter();
54 $reporter = new TextReporter();
57 // Regenerate any necessary files
58 htmlpurifier_flush($AC['php'], $reporter);
62 $test_files = array();
63 require 'test_files.php';
65 $test_files_lookup = array_flip($test_files);
66 if (isset($test_files_lookup[$AC['file']])) {
67 $file = '--file=' . $AC['file'];
69 throw new Exception("Invalid file passed");
72 // This allows us to get out of having to do dry runs.
73 $size = count($test_files);
76 $test = new TestSuite('HTML Purifier Multiple Versions Test');
77 foreach ($versions_to_test as $version) {
79 if (is_array($version)) {
80 $version = $version[0];
83 if (!$AC['only-phpt']) {
84 if (!$AC['exclude-normal']) {
87 "$phpv $version index.php --xml $flush --disable-phpt $file",
92 if (!$AC['exclude-standalone']) {
95 "$phpv $version index.php --xml $flush --standalone --disable-phpt $file",
101 if (!$AC['disable-phpt']) { // naming is not consistent
104 $AC['php'] . " index.php --xml --php \"$phpv $version\" --only-phpt",
111 // This is the HTML Purifier website's test XML file. We could
112 // add more websites, i.e. more configurations to test.
113 // $test->add(new RemoteTestCase('http://htmlpurifier.org/dev/tests/?xml=1', 'http://htmlpurifier.org/dev/tests/?xml=1&dry=1&flush=1'));
115 $test->run($reporter);