From e3fdda1f3c94a2c5002adcec06389ad4fed57942 Mon Sep 17 00:00:00 2001 From: "Edward Z. Yang" Date: Mon, 18 Feb 2008 00:49:45 +0000 Subject: [PATCH] - Bulk up loading PHPT tests. - Fix documentation error with regards to standalone path behavior git-svn-id: http://htmlpurifier.org/svnroot/htmlpurifier/trunk@1562 48356398-32a2-884e-a903-53898d9a118a --- INSTALL | 19 +++++------------- tests/HTMLPurifier/PHPT/loading/_autoload.inc | 10 ++++++++++ .../PHPT/loading/_no-autoload.inc | 15 ++++++++++++++ .../PHPT/loading/auto-includes.phpt | 5 +++-- .../PHPT/loading/auto-with-autoload.phpt | 3 ++- .../PHPT/loading/auto-with-spl-autoload.phpt | 3 ++- .../loading/auto-without-spl-autoload.phpt | 4 ++-- .../auto-without-spl-with-autoload.phpt | 20 +++++++++++++++++++ tests/HTMLPurifier/PHPT/loading/auto.phpt | 3 ++- .../PHPT/loading/path-includes-autoload.phpt | 14 +++++++++++++ .../PHPT/loading/path-includes.phpt | 12 +++++++++++ .../PHPT/loading/standalone-autoload.phpt | 12 +++++++++++ .../PHPT/loading/standalone-with-prefix.phpt | 15 ++++++++++++++ .../HTMLPurifier/PHPT/loading/standalone.phpt | 5 ++++- 14 files changed, 118 insertions(+), 22 deletions(-) create mode 100644 tests/HTMLPurifier/PHPT/loading/_autoload.inc create mode 100644 tests/HTMLPurifier/PHPT/loading/_no-autoload.inc create mode 100644 tests/HTMLPurifier/PHPT/loading/auto-without-spl-with-autoload.phpt create mode 100644 tests/HTMLPurifier/PHPT/loading/path-includes-autoload.phpt create mode 100644 tests/HTMLPurifier/PHPT/loading/path-includes.phpt create mode 100644 tests/HTMLPurifier/PHPT/loading/standalone-autoload.phpt create mode 100644 tests/HTMLPurifier/PHPT/loading/standalone-with-prefix.phpt diff --git a/INSTALL b/INSTALL index 87e61012..fb672e82 100644 --- a/INSTALL +++ b/INSTALL @@ -168,20 +168,11 @@ Standalone version require '/path/to/HTMLPurifier.standalone.php'; - This is equivalent to including HTMLPurifier.includes.php, but no - include path changes are necessary unless you want to use optional - classes. If you *do* want the optional classes, you need to add - HTML Purifier's source directory to your path. This will vary: - - * If you downloaded the htmlpurifier-x.y.z-standalone - distribution, you'll notice that the rest of the library is - missing; add standalone/ to your include path. - - * If you generated the standalone file yourself, the - standalone/ directory will also exist with the relevant - optional classes, but you can also set library/ to your path - and things will still work properly (in theory, a file in both - places should be equivalent). + This is equivalent to including HTMLPurifier.includes.php, except that + the contents of standalone/ will be added to your path. To override this + behavior, specify a new HTMLPURIFIER_PREFIX where standalone files can + be found (usually, this will be one directory up, the "true" library + directory in full distributions). Don't forget to set your path too! The autoloader can be added to the end to ensure the classes are loaded when necessary; otherwise you can manually include them. diff --git a/tests/HTMLPurifier/PHPT/loading/_autoload.inc b/tests/HTMLPurifier/PHPT/loading/_autoload.inc new file mode 100644 index 00000000..45023695 --- /dev/null +++ b/tests/HTMLPurifier/PHPT/loading/_autoload.inc @@ -0,0 +1,10 @@ +getFileName() != realpath("../library/HTMLPurifier.autoload.php")'); + } +} diff --git a/tests/HTMLPurifier/PHPT/loading/auto-includes.phpt b/tests/HTMLPurifier/PHPT/loading/auto-includes.phpt index 69327e31..2768cd04 100644 --- a/tests/HTMLPurifier/PHPT/loading/auto-includes.phpt +++ b/tests/HTMLPurifier/PHPT/loading/auto-includes.phpt @@ -2,8 +2,9 @@ HTMLPurifier.auto.php and HTMLPurifier.includes.php loading test --FILE-- purify('Salsa!'); diff --git a/tests/HTMLPurifier/PHPT/loading/auto-with-autoload.phpt b/tests/HTMLPurifier/PHPT/loading/auto-with-autoload.phpt index bb2dfa72..a446f87b 100644 --- a/tests/HTMLPurifier/PHPT/loading/auto-with-autoload.phpt +++ b/tests/HTMLPurifier/PHPT/loading/auto-with-autoload.phpt @@ -12,7 +12,8 @@ function __autoload($class) { eval("class $class {}"); } -require_once '../library/HTMLPurifier.auto.php'; +require '../library/HTMLPurifier.auto.php'; +require 'HTMLPurifier/PHPT/loading/_autoload.inc'; $config = HTMLPurifier_Config::createDefault(); $purifier = new HTMLPurifier($config); echo $purifier->purify('Salsa!') . PHP_EOL; diff --git a/tests/HTMLPurifier/PHPT/loading/auto-with-spl-autoload.phpt b/tests/HTMLPurifier/PHPT/loading/auto-with-spl-autoload.phpt index 23c7f46f..dfc937a0 100644 --- a/tests/HTMLPurifier/PHPT/loading/auto-with-spl-autoload.phpt +++ b/tests/HTMLPurifier/PHPT/loading/auto-with-spl-autoload.phpt @@ -12,7 +12,8 @@ function __autoload($class) { eval("class $class {}"); } -require_once '../library/HTMLPurifier.auto.php'; +require '../library/HTMLPurifier.auto.php'; +require 'HTMLPurifier/PHPT/loading/_autoload.inc'; $config = HTMLPurifier_Config::createDefault(); $purifier = new HTMLPurifier($config); echo $purifier->purify('Salsa!') . PHP_EOL; diff --git a/tests/HTMLPurifier/PHPT/loading/auto-without-spl-autoload.phpt b/tests/HTMLPurifier/PHPT/loading/auto-without-spl-autoload.phpt index a05a2fe1..be56f132 100644 --- a/tests/HTMLPurifier/PHPT/loading/auto-without-spl-autoload.phpt +++ b/tests/HTMLPurifier/PHPT/loading/auto-without-spl-autoload.phpt @@ -8,11 +8,11 @@ if (function_exists('spl_autoload_register')) { --FILE-- purify('Salsa!') . PHP_EOL; -assert("function_exists('__autoload')"); --EXPECT-- Salsa! diff --git a/tests/HTMLPurifier/PHPT/loading/auto-without-spl-with-autoload.phpt b/tests/HTMLPurifier/PHPT/loading/auto-without-spl-with-autoload.phpt new file mode 100644 index 00000000..7bf6612b --- /dev/null +++ b/tests/HTMLPurifier/PHPT/loading/auto-without-spl-with-autoload.phpt @@ -0,0 +1,20 @@ +--TEST-- +HTMLPurifier.auto.php without spl_autoload_register but with userland +__autoload() defined test +--SKIPIF-- +purify('Salsa!'); diff --git a/tests/HTMLPurifier/PHPT/loading/path-includes-autoload.phpt b/tests/HTMLPurifier/PHPT/loading/path-includes-autoload.phpt new file mode 100644 index 00000000..a6cb59e3 --- /dev/null +++ b/tests/HTMLPurifier/PHPT/loading/path-includes-autoload.phpt @@ -0,0 +1,14 @@ +--TEST-- +HTMLPurifier.path.php, HTMLPurifier.includes.php and HTMLPurifier.autoload.php loading test +--FILE-- +purify('Salsa!'); + +--EXPECT-- +Salsa! diff --git a/tests/HTMLPurifier/PHPT/loading/path-includes.phpt b/tests/HTMLPurifier/PHPT/loading/path-includes.phpt new file mode 100644 index 00000000..2c703ca3 --- /dev/null +++ b/tests/HTMLPurifier/PHPT/loading/path-includes.phpt @@ -0,0 +1,12 @@ +--TEST-- +HTMLPurifier.path.php and HTMLPurifier.includes.php loading test +--FILE-- +purify('Salsa!'); +--EXPECT-- +Salsa! diff --git a/tests/HTMLPurifier/PHPT/loading/standalone-autoload.phpt b/tests/HTMLPurifier/PHPT/loading/standalone-autoload.phpt new file mode 100644 index 00000000..bad3647b --- /dev/null +++ b/tests/HTMLPurifier/PHPT/loading/standalone-autoload.phpt @@ -0,0 +1,12 @@ +--TEST-- +HTMLPurifier.standalone.php loading test +--FILE-- +purify('Salsa!'); +--EXPECT-- +Salsa! diff --git a/tests/HTMLPurifier/PHPT/loading/standalone-with-prefix.phpt b/tests/HTMLPurifier/PHPT/loading/standalone-with-prefix.phpt new file mode 100644 index 00000000..d1ee2bdb --- /dev/null +++ b/tests/HTMLPurifier/PHPT/loading/standalone-with-prefix.phpt @@ -0,0 +1,15 @@ +--TEST-- +HTMLPurifier.standalone.php with HTMLPURIFIER_PREFIX loading test +--FILE-- +purify('Salsa!'); +assert('in_array(realpath("../library/HTMLPurifier/Filter/YouTube.php"), get_included_files())'); +--EXPECT-- +Salsa! diff --git a/tests/HTMLPurifier/PHPT/loading/standalone.phpt b/tests/HTMLPurifier/PHPT/loading/standalone.phpt index ab9a5fb5..7fb0a3bc 100644 --- a/tests/HTMLPurifier/PHPT/loading/standalone.phpt +++ b/tests/HTMLPurifier/PHPT/loading/standalone.phpt @@ -2,9 +2,12 @@ HTMLPurifier.standalone.php loading test --FILE-- purify('Salsa!'); +assert('in_array(realpath("../library/standalone/HTMLPurifier/Filter/YouTube.php"), get_included_files())'); --EXPECT-- Salsa!