mirror of
https://github.com/php/php-src.git
synced 2024-09-21 18:07:23 +00:00
Add some __autoload() tests.
This commit is contained in:
parent
03e039b19d
commit
23191fb208
24
tests/classes/autoload_001.phpt
Executable file
24
tests/classes/autoload_001.phpt
Executable 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
27
tests/classes/autoload_002.phpt
Executable 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
25
tests/classes/autoload_003.phpt
Executable 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
28
tests/classes/autoload_004.phpt
Executable 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===
|
6
tests/classes/autoload_derived.p5c
Executable file
6
tests/classes/autoload_derived.p5c
Executable file
@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
class autoload_derived extends autoload_root {
|
||||
}
|
||||
|
||||
?>
|
10
tests/classes/autoload_root.p5c
Executable file
10
tests/classes/autoload_root.p5c
Executable file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
class autoload_root {
|
||||
function testFunction()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user