Add some __autoload() tests.

This commit is contained in:
Marcus Boerger 2003-12-29 12:36:31 +00:00
parent 03e039b19d
commit 23191fb208
6 changed files with 120 additions and 0 deletions

24
tests/classes/autoload_001.phpt Executable file
View File

@ -0,0 +1,24 @@
--TEST--
ZE2 Autoload and class_exists
--SKIPIF--
<?php
if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed');
if (class_exists('autoload_root')) die('skip Autoload test classes exist already');
?>
--FILE--
<?php
function __autoload($class_name)
{
require_once(dirname(__FILE__) . '/' . $class_name . '.p5c');
echo __FUNCTION__ . '(' . $class_name . ")\n";
}
var_dump(class_exists('autoload_root'));
?>
===DONE===
--EXPECT--
__autoload(autoload_root)
bool(true)
===DONE===

27
tests/classes/autoload_002.phpt Executable file
View File

@ -0,0 +1,27 @@
--TEST--
ZE2 Autoload and get_class_methods
--SKIPIF--
<?php
if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed');
if (class_exists('autoload_root')) die('skip Autoload test classes exist already');
?>
--FILE--
<?php
function __autoload($class_name)
{
require_once(dirname(__FILE__) . '/' . $class_name . '.p5c');
echo __FUNCTION__ . '(' . $class_name . ")\n";
}
var_dump(get_class_methods('autoload_root'));
?>
===DONE===
--EXPECT--
__autoload(autoload_root)
array(1) {
[0]=>
string(12) "testFunction"
}
===DONE===

25
tests/classes/autoload_003.phpt Executable file
View File

@ -0,0 +1,25 @@
--TEST--
ZE2 Autoload and derived classes
--SKIPIF--
<?php
if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed');
if (class_exists('autoload_root')) die('skip Autoload test classes exist already');
?>
--FILE--
<?php
function __autoload($class_name)
{
require_once(dirname(__FILE__) . '/' . $class_name . '.p5c');
echo __FUNCTION__ . '(' . $class_name . ")\n";
}
var_dump(class_exists('autoload_derived'));
?>
===DONE===
--EXPECT--
__autoload(autoload_root)
__autoload(autoload_derived)
bool(true)
===DONE===

28
tests/classes/autoload_004.phpt Executable file
View File

@ -0,0 +1,28 @@
--TEST--
ZE2 Autoload and recursion
--SKIPIF--
<?php
if (version_compare(zend_version(), '2.0.0-dev', '<')) die('skip ZendEngine 2 needed');
if (class_exists('autoload_root')) die('skip Autoload test classes exist already');
?>
--FILE--
<?php
function __autoload($class_name)
{
var_dump(class_exists($class_name));
require_once(dirname(__FILE__) . '/' . $class_name . '.p5c');
echo __FUNCTION__ . '(' . $class_name . ")\n";
}
var_dump(class_exists('autoload_derived'));
?>
===DONE===
--EXPECT--
bool(false)
bool(false)
__autoload(autoload_root)
__autoload(autoload_derived)
bool(true)
===DONE===

View File

@ -0,0 +1,6 @@
<?php
class autoload_derived extends autoload_root {
}
?>

10
tests/classes/autoload_root.p5c Executable file
View File

@ -0,0 +1,10 @@
<?php
class autoload_root {
function testFunction()
{
return true;
}
}
?>