mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-11-14 09:18:41 +00:00
Factor out includes to a "common.php" file, just to tidy up index.php
git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1481 48356398-32a2-884e-a903-53898d9a118a
This commit is contained in:
parent
38a59ef5b8
commit
562f53b54c
45
tests/common.php
Normal file
45
tests/common.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
if (!defined('HTMLPurifierTest')) exit;
|
||||||
|
|
||||||
|
// default settings (protect against register_globals)
|
||||||
|
$GLOBALS['HTMLPurifierTest'] = array();
|
||||||
|
$GLOBALS['HTMLPurifierTest']['PEAR'] = false; // do PEAR tests
|
||||||
|
$GLOBALS['HTMLPurifierTest']['PH5P'] = class_exists('DOMDocument');
|
||||||
|
|
||||||
|
// default library settings
|
||||||
|
$simpletest_location = 'simpletest/'; // reasonable guess
|
||||||
|
$csstidy_location = false;
|
||||||
|
|
||||||
|
// load configuration
|
||||||
|
if (file_exists('../conf/test-settings.php')) include '../conf/test-settings.php';
|
||||||
|
if (file_exists('../test-settings.php')) include '../test-settings.php';
|
||||||
|
|
||||||
|
// load SimpleTest
|
||||||
|
require_once $simpletest_location . 'unit_tester.php';
|
||||||
|
require_once $simpletest_location . 'reporter.php';
|
||||||
|
require_once $simpletest_location . 'mock_objects.php';
|
||||||
|
|
||||||
|
// load CSS Tidy
|
||||||
|
if ($csstidy_location !== false) {
|
||||||
|
require_once $csstidy_location . 'class.csstidy.php';
|
||||||
|
require_once $csstidy_location . 'class.csstidy_print.php';
|
||||||
|
}
|
||||||
|
|
||||||
|
// load PEAR to include path
|
||||||
|
if ( is_string($GLOBALS['HTMLPurifierTest']['PEAR']) ) {
|
||||||
|
// if PEAR is true, there's no need to add it to the path
|
||||||
|
set_include_path($GLOBALS['HTMLPurifierTest']['PEAR'] . PATH_SEPARATOR .
|
||||||
|
get_include_path());
|
||||||
|
}
|
||||||
|
|
||||||
|
// after external libraries are loaded, turn on compile time errors
|
||||||
|
error_reporting(E_ALL | E_STRICT);
|
||||||
|
|
||||||
|
// load SimpleTest addons
|
||||||
|
require_once 'HTMLPurifier/SimpleTest/Reporter.php';
|
||||||
|
require_once 'Debugger.php';
|
||||||
|
require_once 'generate_mock_once.func.php';
|
||||||
|
require_once 'path2class.func.php';
|
||||||
|
require_once 'tally_errors.func.php'; // compat
|
||||||
|
|
@ -6,49 +6,11 @@
|
|||||||
define('HTMLPurifierTest', 1);
|
define('HTMLPurifierTest', 1);
|
||||||
define('HTMLPURIFIER_SCHEMA_STRICT', true); // validate schemas
|
define('HTMLPURIFIER_SCHEMA_STRICT', true); // validate schemas
|
||||||
|
|
||||||
|
require_once 'common.php';
|
||||||
|
|
||||||
|
// clean out cache if necessary
|
||||||
if (isset($_GET['flush'])) shell_exec('php ../maintenance/flush-definition-cache.php');
|
if (isset($_GET['flush'])) shell_exec('php ../maintenance/flush-definition-cache.php');
|
||||||
|
|
||||||
// wishlist: automated calling of this file from multiple PHP versions so we
|
|
||||||
// don't have to constantly switch around
|
|
||||||
|
|
||||||
// default settings (protect against register_globals)
|
|
||||||
$GLOBALS['HTMLPurifierTest'] = array();
|
|
||||||
$GLOBALS['HTMLPurifierTest']['PEAR'] = false; // do PEAR tests
|
|
||||||
$GLOBALS['HTMLPurifierTest']['PH5P'] = version_compare(PHP_VERSION, "5", ">=") && class_exists('DOMDocument');
|
|
||||||
$simpletest_location = 'simpletest/'; // reasonable guess
|
|
||||||
$csstidy_location = false;
|
|
||||||
|
|
||||||
// load SimpleTest
|
|
||||||
if (file_exists('../conf/test-settings.php')) include '../conf/test-settings.php';
|
|
||||||
if (file_exists('../test-settings.php')) include '../test-settings.php';
|
|
||||||
require_once $simpletest_location . 'unit_tester.php';
|
|
||||||
require_once $simpletest_location . 'reporter.php';
|
|
||||||
require_once $simpletest_location . 'mock_objects.php';
|
|
||||||
|
|
||||||
if ($csstidy_location !== false) {
|
|
||||||
require_once $csstidy_location . 'class.csstidy.php';
|
|
||||||
require_once $csstidy_location . 'class.csstidy_print.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
error_reporting(E_ALL | E_STRICT); // after SimpleTest is loaded, turn on compile time errors
|
|
||||||
|
|
||||||
// load Debugger
|
|
||||||
require_once 'HTMLPurifier/SimpleTest/Reporter.php';
|
|
||||||
require_once 'Debugger.php';
|
|
||||||
|
|
||||||
// load convenience functions
|
|
||||||
require_once 'generate_mock_once.func.php';
|
|
||||||
require_once 'path2class.func.php';
|
|
||||||
require_once 'tally_errors.func.php'; // compat
|
|
||||||
|
|
||||||
// initialize PEAR (optional)
|
|
||||||
if ( is_string($GLOBALS['HTMLPurifierTest']['PEAR']) ) {
|
|
||||||
// if PEAR is true, we assume that there's no need to
|
|
||||||
// add it to the path
|
|
||||||
set_include_path($GLOBALS['HTMLPurifierTest']['PEAR'] . PATH_SEPARATOR .
|
|
||||||
get_include_path());
|
|
||||||
}
|
|
||||||
|
|
||||||
// initialize and load HTML Purifier
|
// initialize and load HTML Purifier
|
||||||
// use ?standalone to load the alterative standalone stub
|
// use ?standalone to load the alterative standalone stub
|
||||||
if (isset($_GET['standalone']) || (isset($argv[1]) && $argv[1] == 'standalone')) {
|
if (isset($_GET['standalone']) || (isset($argv[1]) && $argv[1] == 'standalone')) {
|
||||||
|
@ -110,6 +110,7 @@ $test_files[] = 'HTMLPurifier/Strategy/ValidateAttributesTest.php';
|
|||||||
$test_files[] = 'HTMLPurifier/Strategy/ValidateAttributes_IDTest.php';
|
$test_files[] = 'HTMLPurifier/Strategy/ValidateAttributes_IDTest.php';
|
||||||
$test_files[] = 'HTMLPurifier/Strategy/ValidateAttributes_TidyTest.php';
|
$test_files[] = 'HTMLPurifier/Strategy/ValidateAttributes_TidyTest.php';
|
||||||
$test_files[] = 'HTMLPurifier/TagTransformTest.php';
|
$test_files[] = 'HTMLPurifier/TagTransformTest.php';
|
||||||
|
$test_files[] = 'HTMLPurifier/TokenFactoryTest.php';
|
||||||
$test_files[] = 'HTMLPurifier/TokenTest.php';
|
$test_files[] = 'HTMLPurifier/TokenTest.php';
|
||||||
$test_files[] = 'HTMLPurifier/URIDefinitionTest.php';
|
$test_files[] = 'HTMLPurifier/URIDefinitionTest.php';
|
||||||
$test_files[] = 'HTMLPurifier/URIFilter/DisableExternalTest.php';
|
$test_files[] = 'HTMLPurifier/URIFilter/DisableExternalTest.php';
|
||||||
@ -122,10 +123,6 @@ $test_files[] = 'HTMLPurifier/URISchemeTest.php';
|
|||||||
$test_files[] = 'HTMLPurifier/URITest.php';
|
$test_files[] = 'HTMLPurifier/URITest.php';
|
||||||
$test_files[] = 'HTMLPurifierTest.php';
|
$test_files[] = 'HTMLPurifierTest.php';
|
||||||
|
|
||||||
if (version_compare(PHP_VERSION, '5', '>=')) {
|
|
||||||
$test_files[] = 'HTMLPurifier/TokenFactoryTest.php';
|
|
||||||
}
|
|
||||||
|
|
||||||
// ConfigDoc auxiliary library
|
// ConfigDoc auxiliary library
|
||||||
|
|
||||||
// ... none yet
|
// ... none yet
|
||||||
|
Loading…
Reference in New Issue
Block a user