diff options
Diffstat (limited to 'pear/tests')
-rw-r--r-- | pear/tests/pear1.phpt | 87 | ||||
-rw-r--r-- | pear/tests/pear_autoloader.phpt | 80 | ||||
-rw-r--r-- | pear/tests/pear_config.phpt | 72 | ||||
-rw-r--r-- | pear/tests/pear_error.phpt | 153 | ||||
-rw-r--r-- | pear/tests/pear_error2.phpt | 24 | ||||
-rw-r--r-- | pear/tests/pear_error3.phpt | 40 | ||||
-rw-r--r-- | pear/tests/pear_error4.phpt | 89 | ||||
-rw-r--r-- | pear/tests/pear_registry.phpt | 92 | ||||
-rw-r--r-- | pear/tests/php.ini | 2 | ||||
-rw-r--r-- | pear/tests/system.input | 1 | ||||
-rw-r--r-- | pear/tests/user.input | 0 |
11 files changed, 0 insertions, 640 deletions
diff --git a/pear/tests/pear1.phpt b/pear/tests/pear1.phpt deleted file mode 100644 index 067c7165fe..0000000000 --- a/pear/tests/pear1.phpt +++ /dev/null @@ -1,87 +0,0 @@ ---TEST-- -PEAR constructor/destructor test ---SKIPIF-- ---FILE-- -<?php - -require_once "PEAR.php"; - -class TestPEAR extends PEAR { - function TestPEAR($name) { - $this->_debug = true; - $this->name = $name; - $this->PEAR(); - } - function _TestPEAR() { - print "This is the TestPEAR($this->name) destructor\n"; - $this->_PEAR(); - } -} - -class Test2 extends PEAR { - function _Test2() { - print "This is the Test2 destructor\n"; - $this->_PEAR(); - } -} - -class Test3 extends Test2 { -} - -// test for bug http://bugs.php.net/bug.php?id=14744 -class Other extends Pear { - - var $a = 'default value'; - - function Other() { - $this->PEAR(); - } - - function _Other() { - // $a was modified but here misteriously returns to be - // the original value. That makes the destructor useless - // The correct value for $a in the destructor shoud be "new value" - echo "#bug 14744# Other class destructor: other->a == '" . $this->a ."'\n"; - } -} - -print "testing plain destructors\n"; -$o = new TestPEAR("test1"); -$p = new TestPEAR("test2"); -print "..\n"; -print "testing inherited destructors\n"; -$q = new Test3; - -echo "...\ntesting bug #14744\n"; -$other = new Other; -echo "#bug 14744# Other class constructor: other->a == '" . $other->a ."'\n"; -// Modify $a -$other->a = 'new value'; -echo "#bug 14744# Other class modified: other->a == '" . $other->a ."'\n"; - -print "..\n"; -print "script exiting...\n"; -print "..\n"; - -?> ---GET-- ---POST-- ---EXPECT-- -testing plain destructors -PEAR constructor called, class=testpear -PEAR constructor called, class=testpear -.. -testing inherited destructors -... -testing bug #14744 -#bug 14744# Other class constructor: other->a == 'default value' -#bug 14744# Other class modified: other->a == 'new value' -.. -script exiting... -.. -This is the TestPEAR(test1) destructor -PEAR destructor called, class=testpear -This is the TestPEAR(test2) destructor -PEAR destructor called, class=testpear -This is the Test2 destructor -#bug 14744# Other class destructor: other->a == 'new value' diff --git a/pear/tests/pear_autoloader.phpt b/pear/tests/pear_autoloader.phpt deleted file mode 100644 index d6c780d1ac..0000000000 --- a/pear/tests/pear_autoloader.phpt +++ /dev/null @@ -1,80 +0,0 @@ ---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 diff --git a/pear/tests/pear_config.phpt b/pear/tests/pear_config.phpt deleted file mode 100644 index 186c3a0cc3..0000000000 --- a/pear/tests/pear_config.phpt +++ /dev/null @@ -1,72 +0,0 @@ ---TEST-- -PEAR_Config ---FILE-- -<?php - -error_reporting(E_ALL); -include "../PEAR/Config.php"; -copy("system.input", "system.conf"); -copy("user.input", "user.conf"); -PEAR::setErrorHandling(PEAR_ERROR_DIE, "%s\n"); -dumpall(); - -print "creating config object\n"; -$config = new PEAR_Config("user.conf", "system.conf"); - -// overriding system values -$config->set("master_server", "pear.localdomain"); -$config->writeConfigFile(); -dumpall(); -var_dump($config->get("master_server")); - -// going back to defaults -$config->toDefault("master_server"); -$config->writeConfigFile(); -dumpall(); - -// - -print "done\n"; - -unlink("user.conf"); -unlink("system.conf"); - -// ------------------------------------------------------------------------- // - -function dumpit($file) -{ - $fp = fopen($file, "r"); - print "$file:"; - $data = unserialize(fread($fp, filesize($file))); - fclose($fp); - if (!is_array($data)) { - print " <empty>\n"; - return; - } - foreach ($data as $k => $v) { - print " $k=\"$v\""; - } - print "\n"; -} - -function dumpall() -{ - print "dumping...\n"; - dumpit("system.conf"); - dumpit("user.conf"); -} - -?> ---EXPECT-- -dumping... -system.conf: master_server="pear.php.net" -user.conf: <empty> -creating config object -dumping... -system.conf: master_server="pear.php.net" -user.conf: master_server="pear.localdomain" -string(16) "pear.localdomain" -dumping... -system.conf: master_server="pear.php.net" -user.conf: -done diff --git a/pear/tests/pear_error.phpt b/pear/tests/pear_error.phpt deleted file mode 100644 index f4e5b12699..0000000000 --- a/pear/tests/pear_error.phpt +++ /dev/null @@ -1,153 +0,0 @@ ---TEST-- -PEAR_Error: basic test ---SKIPIF-- ---FILE-- -<?php // -*- PHP -*- - -// Test for: PEAR.php -// Parts tested: - PEAR_Error class -// - PEAR::isError static method - -require "../PEAR.php"; - -function test_error_handler($errno, $errmsg, $file, $line, $vars) { - $errortype = array ( - 1 => "Error", - 2 => "Warning", - 4 => "Parsing Error", - 8 => "Notice", - 16 => "Core Error", - 32 => "Core Warning", - 64 => "Compile Error", - 128 => "Compile Warning", - 256 => "User Error", - 512 => "User Warning", - 1024=> "User Notice" - ); - if (preg_match('/^The call_user_method.. function is deprecated/', - $errmsg)) { - return; - } - $prefix = $errortype[$errno]; - $file = basename($file); - print "\n$prefix: $errmsg in $file on line $line\n"; -} - -error_reporting(E_ALL); -set_error_handler("test_error_handler"); - -class Foo_Error extends PEAR_Error -{ - function Foo_Error($message = "unknown error", $code = null, - $mode = null, $options = null, $userinfo = null) - { - $this->PEAR_Error($message, $code, $mode, $options, $userinfo); - $this->error_message_prefix = 'Foo_Error prefix'; - } -} - -class Test1 extends PEAR { - function Test1() { - $this->PEAR("Foo_Error"); - } - function runtest() { - return $this->raiseError("test error"); - } -} - -function errorhandler(&$obj) { - print "errorhandler function called, obj=".$obj->toString()."\n"; -} - -class errorclass { - function errorhandler(&$obj) { - print "errorhandler method called, obj=".$obj->toString()."\n"; - } -} - -print "specify error class: "; -$obj = new Test1; -$err = $obj->runtest(); -print $err->toString() . "\n"; - -$eo = new errorclass; - -print "default PEAR_Error: "; -$err = new PEAR_Error; -print $err->toString() . "\n"; -print "Testing it: "; -var_dump(PEAR::isError($err)); -print "This is not an error: "; -$str = "not an error"; -var_dump(PEAR::isError($str)); - -print "Now trying a bunch of variations...\n"; - -print "different message: "; -$err = new PEAR_Error("test error"); -print $err->toString() . "\n"; - -print "different message,code: "; -$err = new PEAR_Error("test error", -42); -print $err->toString() . "\n"; - -print "mode=print: "; -$err = new PEAR_Error("test error", -42, PEAR_ERROR_PRINT); -print $err->toString() . "\n"; - -print "mode=callback(function): "; -$err = new PEAR_Error("test error", -42, PEAR_ERROR_CALLBACK, "errorhandler"); - -print "mode=callback(method): "; -$err = new PEAR_Error("test error", -42, PEAR_ERROR_CALLBACK, - array(&$eo, "errorhandler")); - -print "mode=print&trigger: "; -$err = new PEAR_Error("test error", -42, PEAR_ERROR_PRINT|PEAR_ERROR_TRIGGER); -print $err->toString() . "\n"; - -print "mode=trigger:"; -$err = new PEAR_Error("test error", -42, PEAR_ERROR_TRIGGER); -print $err->toString() . "\n"; - -print "mode=trigger,level=notice:"; -$err = new PEAR_Error("test error", -42, PEAR_ERROR_TRIGGER, E_USER_NOTICE); -print $err->toString() . "\n"; - -print "mode=trigger,level=warning:"; -$err = new PEAR_Error("test error", -42, PEAR_ERROR_TRIGGER, E_USER_WARNING); -print $err->toString() . "\n"; - -print "mode=trigger,level=error:"; -$err = new PEAR_Error("test error", -42, PEAR_ERROR_TRIGGER, E_USER_ERROR); -print $err->toString() . "\n"; - -?> ---GET-- ---POST-- ---EXPECT-- -specify error class: [foo_error: message="test error" code=0 mode=return level=notice prefix="Foo_Error prefix" info=""] -default PEAR_Error: [pear_error: message="unknown error" code=0 mode=return level=notice prefix="" info=""] -Testing it: bool(true) -This is not an error: bool(false) -Now trying a bunch of variations... -different message: [pear_error: message="test error" code=0 mode=return level=notice prefix="" info=""] -different message,code: [pear_error: message="test error" code=-42 mode=return level=notice prefix="" info=""] -mode=print: test error[pear_error: message="test error" code=-42 mode=print level=notice prefix="" info=""] -mode=callback(function): errorhandler function called, obj=[pear_error: message="test error" code=-42 mode=callback callback=errorhandler prefix="" info=""] -mode=callback(method): errorhandler method called, obj=[pear_error: message="test error" code=-42 mode=callback callback=errorclass::errorhandler prefix="" info=""] -mode=print&trigger: test error -User Notice: test error in PEAR.php on line 594 -[pear_error: message="test error" code=-42 mode=print|trigger level=notice prefix="" info=""] -mode=trigger: -User Notice: test error in PEAR.php on line 594 -[pear_error: message="test error" code=-42 mode=trigger level=notice prefix="" info=""] -mode=trigger,level=notice: -User Notice: test error in PEAR.php on line 594 -[pear_error: message="test error" code=-42 mode=trigger level=notice prefix="" info=""] -mode=trigger,level=warning: -User Warning: test error in PEAR.php on line 594 -[pear_error: message="test error" code=-42 mode=trigger level=warning prefix="" info=""] -mode=trigger,level=error: -User Error: test error in PEAR.php on line 594 -[pear_error: message="test error" code=-42 mode=trigger level=error prefix="" info=""] diff --git a/pear/tests/pear_error2.phpt b/pear/tests/pear_error2.phpt deleted file mode 100644 index eef585289f..0000000000 --- a/pear/tests/pear_error2.phpt +++ /dev/null @@ -1,24 +0,0 @@ ---TEST-- -PEAR_Error: die mode ---SKIPIF-- ---FILE-- -<?php // -*- C++ -*- - -// Test for: PEAR.php -// Parts tested: - PEAR_Error class -// - PEAR::isError static method -// testing PEAR_Error - -require "../PEAR.php"; - -error_reporting(E_ALL); - -print "mode=die: "; -$err = new PEAR_Error("test error!!\n", -42, PEAR_ERROR_DIE); -print $err->toString() . "\n"; - -?> ---GET-- ---POST-- ---EXPECT-- -mode=die: test error!! diff --git a/pear/tests/pear_error3.phpt b/pear/tests/pear_error3.phpt deleted file mode 100644 index 86d82c464d..0000000000 --- a/pear/tests/pear_error3.phpt +++ /dev/null @@ -1,40 +0,0 @@ ---TEST-- -PEAR_Error: default error handling ---FILE-- -<?php // -*- PHP -*- - -// Test for: PEAR.php -// Parts tested: - PEAR_Error class -// - PEAR::setErrorHandling -// - PEAR::raiseError method - -require "../PEAR.php"; - -error_reporting(E_ALL); - -function errorhandler($eobj) -{ - if (PEAR::isError($eobj)) { - print "errorhandler called with an error object.\n"; - print "error message: ".$eobj->getMessage()."\n"; - } else { - print "errorhandler called, but without an error object.\n"; - } -} - -$obj = new PEAR; -$obj->setErrorHandling(PEAR_ERROR_PRINT); -$obj->raiseError("error 1\n"); -$obj->setErrorHandling(null); -$obj->raiseError("error 2\n"); -PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, "errorhandler"); -$obj->raiseError("error 3\n"); -$obj->setErrorHandling(PEAR_ERROR_PRINT); -$obj->raiseError("error 4\n"); - -?> ---EXPECT-- -error 1 -errorhandler called with an error object. -error message: error 3 -error 4 diff --git a/pear/tests/pear_error4.phpt b/pear/tests/pear_error4.phpt deleted file mode 100644 index 1b50637698..0000000000 --- a/pear/tests/pear_error4.phpt +++ /dev/null @@ -1,89 +0,0 @@ ---TEST-- -PEAR_Error: expected errors ---FILE-- -<?php // -*- PHP -*- - -// Test for: PEAR.php -// Parts tested: - PEAR_Error class -// - PEAR::expectError -// - PEAR::popExpect - -require "../PEAR.php"; - -error_reporting(E_ALL); - -function errorhandler($eobj) -{ - if (PEAR::isError($eobj)) { - print "error: ".$eobj->getMessage()."\n"; - } else { - print "errorhandler called without error object\n"; - } -} - -$obj = new PEAR; -$obj->setErrorHandling(PEAR_ERROR_CALLBACK, "errorhandler"); - -print "subtest 1\n"; -$obj->expectError(1); -$obj->raiseError("1", 1); -$obj->popExpect(); -$obj->raiseError("2", 2); - -print "subtest 2\n"; -$obj->expectError(3); -$obj->expectError(2); -$obj->raiseError("3", 3); - -print "subtest 3\n"; -$obj->popExpect(); -$obj->raiseError("3", 3); -$obj->popExpect(); - -print "subtest 4\n"; -$obj->expectError(array(1,2,3,4,5)); -$obj->raiseError("0", 0); -$obj->raiseError("1", 1); -$obj->raiseError("2", 2); -$obj->raiseError("3", 3); -$obj->raiseError("4", 4); -$obj->raiseError("5", 5); -$obj->raiseError("6", 6); -$obj->raiseError("error"); -$obj->popExpect(); - -print "subtest 5\n"; -$obj->expectError("*"); -$obj->raiseError("42", 42); -$obj->raiseError("75", 75); -$obj->raiseError("13", 13); -$obj->popExpect(); - -print "subtest 6\n"; -$obj->expectError(); -$obj->raiseError("123", 123); -$obj->raiseError("456", 456); -$obj->raiseError("789", 789); -$obj->popExpect(); - -print "subtest 7\n"; -$obj->expectError("syntax error"); -$obj->raiseError("type mismatch"); -$obj->raiseError("syntax error"); -$obj->popExpect(); - -?> ---EXPECT-- -subtest 1 -error: 2 -subtest 2 -error: 3 -subtest 3 -subtest 4 -error: 0 -error: 6 -error: error -subtest 5 -subtest 6 -subtest 7 -error: type mismatch diff --git a/pear/tests/pear_registry.phpt b/pear/tests/pear_registry.phpt deleted file mode 100644 index 55af6d3aba..0000000000 --- a/pear/tests/pear_registry.phpt +++ /dev/null @@ -1,92 +0,0 @@ ---TEST-- -PEAR_Registry ---FILE-- -<?php - -error_reporting(E_ALL); -include "../PEAR/Registry.php"; -PEAR::setErrorHandling(PEAR_ERROR_DIE, "%s\n"); -cleanall(); - -print "creating registry object\n"; -$reg = new PEAR_Registry; -$reg->statedir = getcwd(); -dumpall($reg); -$reg->addPackage("pkg1", array("name" => "pkg1", "version" => "1.0")); -dumpall($reg); -$reg->addPackage("pkg2", array("name" => "pkg2", "version" => "2.0")); -$reg->addPackage("pkg3", array("name" => "pkg3", "version" => "3.0")); -dumpall($reg); -$reg->updatePackage("pkg2", array("version" => "2.1")); -dumpall($reg); -var_dump($reg->deletePackage("pkg2")); -dumpall($reg); -var_dump($reg->deletePackage("pkg2")); -dumpall($reg); -$reg->updatePackage("pkg3", array("version" => "3.1b1", "status" => "beta")); -dumpall($reg); - -print "tests done\n"; - -cleanall(); - -// ------------------------------------------------------------------------- // - -function cleanall() -{ - $dp = opendir("."); - while ($ent = readdir($dp)) { - if (substr($ent, -4) == ".reg") { - unlink($ent); - } - } -} - -function dumpall(&$reg) -{ - print "dumping registry...\n"; - $info = $reg->packageInfo(); - foreach ($info as $pkg) { - print $pkg["name"] . ":"; - unset($pkg["name"]); - foreach ($pkg as $k => $v) { - print " $k=\"$v\""; - } - print "\n"; - } - print "dump done\n"; -} - -?> ---EXPECT-- -creating registry object -dumping registry... -dump done -dumping registry... -pkg1: version="1.0" -dump done -dumping registry... -pkg1: version="1.0" -pkg2: version="2.0" -pkg3: version="3.0" -dump done -dumping registry... -pkg1: version="1.0" -pkg2: version="2.1" -pkg3: version="3.0" -dump done -bool(true) -dumping registry... -pkg1: version="1.0" -pkg3: version="3.0" -dump done -bool(false) -dumping registry... -pkg1: version="1.0" -pkg3: version="3.0" -dump done -dumping registry... -pkg1: version="1.0" -pkg3: version="3.1b1" status="beta" -dump done -tests done diff --git a/pear/tests/php.ini b/pear/tests/php.ini deleted file mode 100644 index c75c9b4f11..0000000000 --- a/pear/tests/php.ini +++ /dev/null @@ -1,2 +0,0 @@ -; php.ini for PEAR tests -include_path=.. diff --git a/pear/tests/system.input b/pear/tests/system.input deleted file mode 100644 index 9c6bece157..0000000000 --- a/pear/tests/system.input +++ /dev/null @@ -1 +0,0 @@ -a:1:{s:13:"master_server";s:12:"pear.php.net";}
\ No newline at end of file diff --git a/pear/tests/user.input b/pear/tests/user.input deleted file mode 100644 index e69de29bb2..0000000000 --- a/pear/tests/user.input +++ /dev/null |