blob: 2e5ce8d2a2612e45a47359beff01fa76e09131bc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
--TEST--
PEAR_Error: default error handling
--SKIPIF--
<?php
if (!getenv('PHP_PEAR_RUNTESTS')) {
echo 'skip';
}
?>
--FILE--
<?php // -*- PHP -*-
// Test for: PEAR.php
// Parts tested: - PEAR_Error class
// - PEAR::setErrorHandling
// - PEAR::raiseError method
include_once "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";
}
}
// 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
$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");
$obj->setErrorHandling(PEAR_ERROR_PRINT);
$obj->raiseError("error 4\n");
?>
--EXPECT--
OOPS: error happens
error 1
errorhandler called with an error object.
error message: error 3
error 4
|