first commit
This commit is contained in:
12
htmlpurifier-4.10.0/tests/HTMLPurifier/PHPT/loading/_autoload.inc
Executable file
12
htmlpurifier-4.10.0/tests/HTMLPurifier/PHPT/loading/_autoload.inc
Executable file
@ -0,0 +1,12 @@
|
||||
<?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())");
|
||||
|
||||
// vim: et sw=4 sts=4
|
17
htmlpurifier-4.10.0/tests/HTMLPurifier/PHPT/loading/_no-autoload.inc
Executable file
17
htmlpurifier-4.10.0/tests/HTMLPurifier/PHPT/loading/_no-autoload.inc
Executable file
@ -0,0 +1,17 @@
|
||||
<?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")');
|
||||
}
|
||||
}
|
||||
|
||||
// vim: et sw=4 sts=4
|
12
htmlpurifier-4.10.0/tests/HTMLPurifier/PHPT/loading/auto-includes.phpt
Executable file
12
htmlpurifier-4.10.0/tests/HTMLPurifier/PHPT/loading/auto-includes.phpt
Executable file
@ -0,0 +1,12 @@
|
||||
--TEST--
|
||||
HTMLPurifier.auto.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>
|
28
htmlpurifier-4.10.0/tests/HTMLPurifier/PHPT/loading/auto-with-autoload.phpt
Executable file
28
htmlpurifier-4.10.0/tests/HTMLPurifier/PHPT/loading/auto-with-autoload.phpt
Executable file
@ -0,0 +1,28 @@
|
||||
--TEST--
|
||||
HTMLPurifier.auto.php using spl_autoload_register with __autoload() already defined loading test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!function_exists('spl_autoload_register')) {
|
||||
echo "skip - spl_autoload_register() not available";
|
||||
}
|
||||
--FILE--
|
||||
<?php
|
||||
function __autoload($class) {
|
||||
echo "Autoloading $class...
|
||||
";
|
||||
eval("class $class {}");
|
||||
}
|
||||
|
||||
require '../library/HTMLPurifier.auto.php';
|
||||
require 'HTMLPurifier/PHPT/loading/_autoload.inc';
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$purifier = new HTMLPurifier($config);
|
||||
echo $purifier->purify('<b>Salsa!') . "
|
||||
";
|
||||
|
||||
// purposely invoke older autoload
|
||||
$bar = new Bar();
|
||||
|
||||
--EXPECT--
|
||||
<b>Salsa!</b>
|
||||
Autoloading Bar...
|
@ -0,0 +1,25 @@
|
||||
--TEST--
|
||||
HTMLPurifier.auto.php using spl_autoload_register default
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!function_exists('spl_autoload_register')) {
|
||||
echo "skip - spl_autoload_register() not available";
|
||||
}
|
||||
--FILE--
|
||||
<?php
|
||||
spl_autoload_extensions(".php");
|
||||
spl_autoload_register();
|
||||
|
||||
require '../library/HTMLPurifier.auto.php';
|
||||
require 'HTMLPurifier/PHPT/loading/_autoload.inc';
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$purifier = new HTMLPurifier($config);
|
||||
echo $purifier->purify('<b>Salsa!') . "
|
||||
";
|
||||
|
||||
// purposely invoke standard autoload
|
||||
$test = new default_load();
|
||||
|
||||
--EXPECT--
|
||||
<b>Salsa!</b>
|
||||
Default loaded
|
@ -0,0 +1,43 @@
|
||||
--TEST--
|
||||
HTMLPurifier.auto.php using spl_autoload_register with user registration loading test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!function_exists('spl_autoload_register')) {
|
||||
echo "skip - spl_autoload_register() not available";
|
||||
}
|
||||
--FILE--
|
||||
<?php
|
||||
function my_autoload($class) {
|
||||
echo "Autoloading $class...
|
||||
";
|
||||
eval("class $class {}");
|
||||
return true;
|
||||
}
|
||||
class MyClass {
|
||||
public static function myAutoload($class) {
|
||||
if ($class == 'Foo') {
|
||||
echo "Special autoloading Foo...
|
||||
";
|
||||
eval("class $class {}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
spl_autoload_register(array('MyClass', 'myAutoload'));
|
||||
spl_autoload_register('my_autoload');
|
||||
|
||||
require '../library/HTMLPurifier.auto.php';
|
||||
require 'HTMLPurifier/PHPT/loading/_autoload.inc';
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$purifier = new HTMLPurifier($config);
|
||||
echo $purifier->purify('<b>Salsa!') . "
|
||||
";
|
||||
|
||||
// purposely invoke older autoloads
|
||||
$foo = new Foo();
|
||||
$bar = new Bar();
|
||||
|
||||
--EXPECT--
|
||||
<b>Salsa!</b>
|
||||
Special autoloading Foo...
|
||||
Autoloading Bar...
|
@ -0,0 +1,19 @@
|
||||
--TEST--
|
||||
HTMLPurifier.auto.php without spl_autoload_register without userland autoload loading test
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (function_exists('spl_autoload_register')) {
|
||||
echo "skip - spl_autoload_register() available";
|
||||
}
|
||||
--FILE--
|
||||
<?php
|
||||
assert("!function_exists('__autoload')");
|
||||
require '../library/HTMLPurifier.auto.php';
|
||||
require 'HTMLPurifier/PHPT/loading/_autoload.inc';
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$purifier = new HTMLPurifier($config);
|
||||
echo $purifier->purify('<b>Salsa!') . "
|
||||
";
|
||||
|
||||
--EXPECT--
|
||||
<b>Salsa!</b>
|
@ -0,0 +1,21 @@
|
||||
--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...
|
||||
";
|
||||
eval("class $class {}");
|
||||
}
|
||||
require '../library/HTMLPurifier.auto.php';
|
||||
require 'HTMLPurifier/PHPT/loading/_no-autoload.inc';
|
||||
$purifier = new HTMLPurifier();
|
||||
|
||||
--EXPECT--
|
||||
Autoloading HTMLPurifier...
|
11
htmlpurifier-4.10.0/tests/HTMLPurifier/PHPT/loading/auto.phpt
Executable file
11
htmlpurifier-4.10.0/tests/HTMLPurifier/PHPT/loading/auto.phpt
Executable file
@ -0,0 +1,11 @@
|
||||
--TEST--
|
||||
HTMLPurifier.auto.php loading test
|
||||
--FILE--
|
||||
<?php
|
||||
require '../library/HTMLPurifier.auto.php';
|
||||
require 'HTMLPurifier/PHPT/loading/_autoload.inc';
|
||||
$config = HTMLPurifier_Config::createDefault();
|
||||
$purifier = new HTMLPurifier($config);
|
||||
echo $purifier->purify('<b>Salsa!');
|
||||
--EXPECT--
|
||||
<b>Salsa!</b>
|
@ -0,0 +1,32 @@
|
||||
--TEST--
|
||||
Error when registering autoload with non-static autoload already on SPL stack
|
||||
--SKIPIF--
|
||||
<?php
|
||||
if (!function_exists('spl_autoload_register')) {
|
||||
echo "skip - spl_autoload_register() not available";
|
||||
}
|
||||
if (version_compare(PHP_VERSION, '5.2.11', '>=')) {
|
||||
echo "skip - non-buggy version of PHP";
|
||||
}
|
||||
--FILE--
|
||||
<?php
|
||||
class NotStatic
|
||||
{
|
||||
public function autoload($class) {
|
||||
echo "Autoloading... $class" . PHP_EOL;
|
||||
eval("class $class {}");
|
||||
}
|
||||
}
|
||||
|
||||
$obj = new NotStatic();
|
||||
spl_autoload_register(array($obj, 'autoload'));
|
||||
|
||||
try {
|
||||
require '../library/HTMLPurifier.auto.php';
|
||||
} catch (Exception $e) {
|
||||
echo 'Caught error gracefully';
|
||||
assert('strpos($e->getMessage(), "44144") !== false');
|
||||
}
|
||||
|
||||
--EXPECT--
|
||||
Caught error gracefully
|
@ -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
htmlpurifier-4.10.0/tests/HTMLPurifier/PHPT/loading/path-includes.phpt
Executable file
12
htmlpurifier-4.10.0/tests/HTMLPurifier/PHPT/loading/path-includes.phpt
Executable 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
htmlpurifier-4.10.0/tests/HTMLPurifier/PHPT/loading/safe-includes.phpt
Executable file
12
htmlpurifier-4.10.0/tests/HTMLPurifier/PHPT/loading/safe-includes.phpt
Executable file
@ -0,0 +1,12 @@
|
||||
--TEST--
|
||||
HTMLPurifier.safe-includes.php loading test
|
||||
--FILE--
|
||||
<?php
|
||||
require_once '../library/HTMLPurifier.php'; // Tests for require_once
|
||||
require_once '../library/HTMLPurifier.safe-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
htmlpurifier-4.10.0/tests/HTMLPurifier/PHPT/loading/standalone-autoload.phpt
Executable file
12
htmlpurifier-4.10.0/tests/HTMLPurifier/PHPT/loading/standalone-autoload.phpt
Executable 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>
|
@ -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>
|
13
htmlpurifier-4.10.0/tests/HTMLPurifier/PHPT/loading/standalone.phpt
Executable file
13
htmlpurifier-4.10.0/tests/HTMLPurifier/PHPT/loading/standalone.phpt
Executable file
@ -0,0 +1,13 @@
|
||||
--TEST--
|
||||
HTMLPurifier.standalone.php loading test
|
||||
--FILE--
|
||||
<?php
|
||||
require '../library/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/standalone/HTMLPurifier/Filter/YouTube.php"), get_included_files())');
|
||||
--EXPECT--
|
||||
<b>Salsa!</b>
|
Reference in New Issue
Block a user