diff options
author | Stig Bakken <ssb@php.net> | 2001-12-10 01:50:11 +0000 |
---|---|---|
committer | Stig Bakken <ssb@php.net> | 2001-12-10 01:50:11 +0000 |
commit | b11d1eb4407c6eae1b1f2140968b5201c4927a17 (patch) | |
tree | 4f8c39e29a85271c8775a6dce02770c00d273b5a /pear/tests | |
parent | 5d1040309c4e1e5d7894f3c6fa098a2ea4641885 (diff) | |
download | php-git-b11d1eb4407c6eae1b1f2140968b5201c4927a17.tar.gz |
* initial commit of PEAR method autoloader
Diffstat (limited to 'pear/tests')
-rw-r--r-- | pear/tests/pear_autoloader.phpt | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/pear/tests/pear_autoloader.phpt b/pear/tests/pear_autoloader.phpt new file mode 100644 index 0000000000..d6c780d1ac --- /dev/null +++ b/pear/tests/pear_autoloader.phpt @@ -0,0 +1,80 @@ +--TEST-- +PEAR_Autoloader +--SKIPIF-- +<?php if (!extension_loaded("overload")) die("skip\n"); ?> +--FILE-- +<?php + +require "../PEAR/Autoloader.php"; + +class test1 extends PEAR_Autoloader { + function test1() { + $this->addAutoload(array( + 'testfunc1' => 'testclass1', + 'testfunca' => 'testclass1', + 'testfunc2' => 'testclass2', + 'testfuncb' => 'testclass2', + )); + } +} + +class testclass1 { + function testfunc1($a) { + print "testfunc1 arg=";var_dump($a); + return 1; + } + function testfunca($a) { + print "testfunca arg=";var_dump($a); + return 2; + } +} + +class testclass2 { + function testfunc2($b) { + print "testfunc2 arg=";var_dump($b); + return 3; + } + function testfuncb($b) { + print "testfuncb arg=";var_dump($b); + return 4; + } +} + +function dump($obj) { + print "mapped methods:"; + foreach ($obj->_method_map as $method => $object) { + print " $method"; + } + print "\n"; +} + +function call($msg, $retval) { + print "calling $msg returned $retval\n"; +} + +$obj = new test1; +dump($obj); +call("testfunc1", $obj->testfunc1(2)); +dump($obj); +call("testfunca", $obj->testfunca(2)); +dump($obj); +call("testfunc2", $obj->testfunc2(2)); +dump($obj); +call("testfuncb", $obj->testfuncb(2)); +dump($obj); + +?> +--EXPECT-- +mapped methods: +testfunc1 arg=int(2) +calling testfunc1 returned 1 +mapped methods: testfunc1 testfunca +testfunca arg=int(2) +calling testfunca returned 2 +mapped methods: testfunc1 testfunca +testfunc2 arg=int(2) +calling testfunc2 returned 3 +mapped methods: testfunc1 testfunca testfunc2 testfuncb +testfuncb arg=int(2) +calling testfuncb returned 4 +mapped methods: testfunc1 testfunca testfunc2 testfuncb |