2001-01-30 00:55:27 +00:00
|
|
|
--TEST--
|
2001-11-04 09:07:17 +00:00
|
|
|
PEAR_Error: default error handling
|
2001-01-30 00:55:27 +00:00
|
|
|
--FILE--
|
2001-11-04 09:07:17 +00:00
|
|
|
<?php // -*- PHP -*-
|
2001-01-30 00:55:27 +00:00
|
|
|
|
|
|
|
// Test for: PEAR.php
|
|
|
|
// Parts tested: - PEAR_Error class
|
|
|
|
// - PEAR::setErrorHandling
|
|
|
|
// - PEAR::raiseError method
|
|
|
|
|
2002-03-02 03:11:02 +00:00
|
|
|
include dirname(__FILE__)."/../PEAR.php";
|
2001-01-30 00:55:27 +00:00
|
|
|
|
2001-11-04 09:07:17 +00:00
|
|
|
error_reporting(E_ALL);
|
2001-01-30 00:55:27 +00:00
|
|
|
|
|
|
|
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";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-13 01:17:47 +00:00
|
|
|
// Test 1
|
|
|
|
PEAR::setErrorHandling(PEAR_ERROR_PRINT, "OOPS: %s\n");
|
|
|
|
$tmp = new PEAR;
|
|
|
|
$tmp->raiseError("error happens");
|
|
|
|
|
|
|
|
// Return PEAR to its original state
|
|
|
|
$GLOBALS['_PEAR_default_error_mode'] = PEAR_ERROR_RETURN;
|
|
|
|
$GLOBALS['_PEAR_default_error_options'] = E_USER_NOTICE;
|
|
|
|
$GLOBALS['_PEAR_default_error_callback'] = '';
|
|
|
|
|
|
|
|
// Test 2
|
2001-01-30 00:55:27 +00:00
|
|
|
$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");
|
2002-03-13 01:17:47 +00:00
|
|
|
$obj->raiseError("error 3");
|
2001-01-30 00:55:27 +00:00
|
|
|
$obj->setErrorHandling(PEAR_ERROR_PRINT);
|
|
|
|
$obj->raiseError("error 4\n");
|
|
|
|
|
|
|
|
?>
|
|
|
|
--EXPECT--
|
2002-03-13 01:17:47 +00:00
|
|
|
OOPS: error happens
|
2001-01-30 00:55:27 +00:00
|
|
|
error 1
|
|
|
|
errorhandler called with an error object.
|
|
|
|
error message: error 3
|
2002-03-13 01:17:47 +00:00
|
|
|
error 4
|