mirror of
https://github.com/ezyang/htmlpurifier.git
synced 2024-12-22 08:21:52 +00:00
- 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
This commit is contained in:
parent
40d3d5b961
commit
e3fdda1f3c
19
INSTALL
19
INSTALL
@ -168,20 +168,11 @@ Standalone version
|
|||||||
|
|
||||||
require '/path/to/HTMLPurifier.standalone.php';
|
require '/path/to/HTMLPurifier.standalone.php';
|
||||||
|
|
||||||
This is equivalent to including HTMLPurifier.includes.php, but no
|
This is equivalent to including HTMLPurifier.includes.php, except that
|
||||||
include path changes are necessary unless you want to use optional
|
the contents of standalone/ will be added to your path. To override this
|
||||||
classes. If you *do* want the optional classes, you need to add
|
behavior, specify a new HTMLPURIFIER_PREFIX where standalone files can
|
||||||
HTML Purifier's source directory to your path. This will vary:
|
be found (usually, this will be one directory up, the "true" library
|
||||||
|
directory in full distributions). Don't forget to set your path too!
|
||||||
* 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).
|
|
||||||
|
|
||||||
The autoloader can be added to the end to ensure the classes are
|
The autoloader can be added to the end to ensure the classes are
|
||||||
loaded when necessary; otherwise you can manually include them.
|
loaded when necessary; otherwise you can manually include them.
|
||||||
|
10
tests/HTMLPurifier/PHPT/loading/_autoload.inc
Normal file
10
tests/HTMLPurifier/PHPT/loading/_autoload.inc
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if autoloading for HTML Purifier is enabled. If all tests pass,
|
||||||
|
* output is blank.
|
||||||
|
*/
|
||||||
|
|
||||||
|
assert("!in_array(realpath('../library/HTMLPurifier/Filter/YouTube.php'), get_included_files())");
|
||||||
|
new HTMLPurifier_Filter_YouTube();
|
||||||
|
assert(" in_array(realpath('../library/HTMLPurifier.autoload.php'), get_included_files())");
|
15
tests/HTMLPurifier/PHPT/loading/_no-autoload.inc
Normal file
15
tests/HTMLPurifier/PHPT/loading/_no-autoload.inc
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests if autoloading is off in HTML Purifier. If all tests pass, no output.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (function_exists('spl_autoload_register')) {
|
||||||
|
$__v = spl_autoload_functions();
|
||||||
|
assert('$__v == false || !in_array(array("HTMLPurifier_Bootstrap", "autoload"), $__v)');
|
||||||
|
} else {
|
||||||
|
if (function_exists('__autoload')) {
|
||||||
|
$__r = new ReflectionFunction('__autoload');
|
||||||
|
assert('$__r->getFileName() != realpath("../library/HTMLPurifier.autoload.php")');
|
||||||
|
}
|
||||||
|
}
|
@ -2,8 +2,9 @@
|
|||||||
HTMLPurifier.auto.php and HTMLPurifier.includes.php loading test
|
HTMLPurifier.auto.php and HTMLPurifier.includes.php loading test
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once '../library/HTMLPurifier.path.php';
|
require '../library/HTMLPurifier.path.php';
|
||||||
require_once 'HTMLPurifier.includes.php';
|
require 'HTMLPurifier.includes.php';
|
||||||
|
require 'HTMLPurifier/PHPT/loading/_no-autoload.inc';
|
||||||
$config = HTMLPurifier_Config::createDefault();
|
$config = HTMLPurifier_Config::createDefault();
|
||||||
$purifier = new HTMLPurifier($config);
|
$purifier = new HTMLPurifier($config);
|
||||||
echo $purifier->purify('<b>Salsa!');
|
echo $purifier->purify('<b>Salsa!');
|
||||||
|
@ -12,7 +12,8 @@ function __autoload($class) {
|
|||||||
eval("class $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();
|
$config = HTMLPurifier_Config::createDefault();
|
||||||
$purifier = new HTMLPurifier($config);
|
$purifier = new HTMLPurifier($config);
|
||||||
echo $purifier->purify('<b>Salsa!') . PHP_EOL;
|
echo $purifier->purify('<b>Salsa!') . PHP_EOL;
|
||||||
|
@ -12,7 +12,8 @@ function __autoload($class) {
|
|||||||
eval("class $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();
|
$config = HTMLPurifier_Config::createDefault();
|
||||||
$purifier = new HTMLPurifier($config);
|
$purifier = new HTMLPurifier($config);
|
||||||
echo $purifier->purify('<b>Salsa!') . PHP_EOL;
|
echo $purifier->purify('<b>Salsa!') . PHP_EOL;
|
||||||
|
@ -8,11 +8,11 @@ if (function_exists('spl_autoload_register')) {
|
|||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
assert("!function_exists('__autoload')");
|
assert("!function_exists('__autoload')");
|
||||||
require_once '../library/HTMLPurifier.auto.php';
|
require '../library/HTMLPurifier.auto.php';
|
||||||
|
require 'HTMLPurifier/PHPT/loading/_autoload.inc';
|
||||||
$config = HTMLPurifier_Config::createDefault();
|
$config = HTMLPurifier_Config::createDefault();
|
||||||
$purifier = new HTMLPurifier($config);
|
$purifier = new HTMLPurifier($config);
|
||||||
echo $purifier->purify('<b>Salsa!') . PHP_EOL;
|
echo $purifier->purify('<b>Salsa!') . PHP_EOL;
|
||||||
assert("function_exists('__autoload')");
|
|
||||||
|
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
<b>Salsa!</b>
|
<b>Salsa!</b>
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
--TEST--
|
||||||
|
HTMLPurifier.auto.php without spl_autoload_register but with userland
|
||||||
|
__autoload() defined test
|
||||||
|
--SKIPIF--
|
||||||
|
<?php
|
||||||
|
if (function_exists('spl_autoload_register')) {
|
||||||
|
echo "skip - spl_autoload_register() available";
|
||||||
|
}
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
function __autoload($class) {
|
||||||
|
echo "Autoloading $class..." . PHP_EOL;
|
||||||
|
eval("class $class {}");
|
||||||
|
}
|
||||||
|
require '../library/HTMLPurifier.auto.php';
|
||||||
|
require 'HTMLPurifier/PHPT/loading/_no-autoload.inc';
|
||||||
|
$purifier = new HTMLPurifier();
|
||||||
|
|
||||||
|
--EXPECT--
|
||||||
|
Autoloading HTMLPurifier...
|
@ -2,7 +2,8 @@
|
|||||||
HTMLPurifier.auto.php loading test
|
HTMLPurifier.auto.php loading test
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once '../library/HTMLPurifier.auto.php';
|
require '../library/HTMLPurifier.auto.php';
|
||||||
|
require 'HTMLPurifier/PHPT/loading/_autoload.inc';
|
||||||
$config = HTMLPurifier_Config::createDefault();
|
$config = HTMLPurifier_Config::createDefault();
|
||||||
$purifier = new HTMLPurifier($config);
|
$purifier = new HTMLPurifier($config);
|
||||||
echo $purifier->purify('<b>Salsa!');
|
echo $purifier->purify('<b>Salsa!');
|
||||||
|
14
tests/HTMLPurifier/PHPT/loading/path-includes-autoload.phpt
Normal file
14
tests/HTMLPurifier/PHPT/loading/path-includes-autoload.phpt
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
--TEST--
|
||||||
|
HTMLPurifier.path.php, HTMLPurifier.includes.php and HTMLPurifier.autoload.php loading test
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
require '../library/HTMLPurifier.path.php';
|
||||||
|
require 'HTMLPurifier.includes.php';
|
||||||
|
require 'HTMLPurifier.autoload.php';
|
||||||
|
require 'HTMLPurifier/PHPT/loading/_autoload.inc';
|
||||||
|
$config = HTMLPurifier_Config::createDefault();
|
||||||
|
$purifier = new HTMLPurifier($config);
|
||||||
|
echo $purifier->purify('<b>Salsa!');
|
||||||
|
|
||||||
|
--EXPECT--
|
||||||
|
<b>Salsa!</b>
|
12
tests/HTMLPurifier/PHPT/loading/path-includes.phpt
Normal file
12
tests/HTMLPurifier/PHPT/loading/path-includes.phpt
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
--TEST--
|
||||||
|
HTMLPurifier.path.php and HTMLPurifier.includes.php loading test
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
require '../library/HTMLPurifier.path.php';
|
||||||
|
require 'HTMLPurifier.includes.php';
|
||||||
|
require 'HTMLPurifier/PHPT/loading/_no-autoload.inc';
|
||||||
|
$config = HTMLPurifier_Config::createDefault();
|
||||||
|
$purifier = new HTMLPurifier($config);
|
||||||
|
echo $purifier->purify('<b>Salsa!');
|
||||||
|
--EXPECT--
|
||||||
|
<b>Salsa!</b>
|
12
tests/HTMLPurifier/PHPT/loading/standalone-autoload.phpt
Normal file
12
tests/HTMLPurifier/PHPT/loading/standalone-autoload.phpt
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
--TEST--
|
||||||
|
HTMLPurifier.standalone.php loading test
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
require '../library/HTMLPurifier.standalone.php';
|
||||||
|
require '../library/HTMLPurifier.autoload.php';
|
||||||
|
require 'HTMLPurifier/PHPT/loading/_autoload.inc';
|
||||||
|
$config = HTMLPurifier_Config::createDefault();
|
||||||
|
$purifier = new HTMLPurifier($config);
|
||||||
|
echo $purifier->purify('<b>Salsa!');
|
||||||
|
--EXPECT--
|
||||||
|
<b>Salsa!</b>
|
15
tests/HTMLPurifier/PHPT/loading/standalone-with-prefix.phpt
Normal file
15
tests/HTMLPurifier/PHPT/loading/standalone-with-prefix.phpt
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
--TEST--
|
||||||
|
HTMLPurifier.standalone.php with HTMLPURIFIER_PREFIX loading test
|
||||||
|
--FILE--
|
||||||
|
<?php
|
||||||
|
define('HTMLPURIFIER_PREFIX', realpath('../library'));
|
||||||
|
require '../library/HTMLPurifier.path.php';
|
||||||
|
require 'HTMLPurifier.standalone.php';
|
||||||
|
require 'HTMLPurifier/Filter/YouTube.php';
|
||||||
|
require 'HTMLPurifier/PHPT/loading/_no-autoload.inc';
|
||||||
|
$config = HTMLPurifier_Config::createDefault();
|
||||||
|
$purifier = new HTMLPurifier($config);
|
||||||
|
echo $purifier->purify('<b>Salsa!');
|
||||||
|
assert('in_array(realpath("../library/HTMLPurifier/Filter/YouTube.php"), get_included_files())');
|
||||||
|
--EXPECT--
|
||||||
|
<b>Salsa!</b>
|
@ -2,9 +2,12 @@
|
|||||||
HTMLPurifier.standalone.php loading test
|
HTMLPurifier.standalone.php loading test
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
require_once '../library/HTMLPurifier.standalone.php';
|
require '../library/HTMLPurifier.standalone.php';
|
||||||
|
require 'HTMLPurifier/Filter/YouTube.php';
|
||||||
|
require 'HTMLPurifier/PHPT/loading/_no-autoload.inc';
|
||||||
$config = HTMLPurifier_Config::createDefault();
|
$config = HTMLPurifier_Config::createDefault();
|
||||||
$purifier = new HTMLPurifier($config);
|
$purifier = new HTMLPurifier($config);
|
||||||
echo $purifier->purify('<b>Salsa!');
|
echo $purifier->purify('<b>Salsa!');
|
||||||
|
assert('in_array(realpath("../library/standalone/HTMLPurifier/Filter/YouTube.php"), get_included_files())');
|
||||||
--EXPECT--
|
--EXPECT--
|
||||||
<b>Salsa!</b>
|
<b>Salsa!</b>
|
||||||
|
Loading…
Reference in New Issue
Block a user