php-src/ext/dom/tests/dom003.phpt

70 lines
1.5 KiB
Plaintext
Raw Normal View History

2003-10-27 12:52:37 +00:00
--TEST--
Test 3: Exception Test
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
$dom = new domdocument;
$dom->load(dirname(__FILE__)."/book.xml");
$rootNode = $dom->documentElement;
print "--- Catch exception with try/catch\n";
try {
$rootNode->appendChild($rootNode);
} catch (domexception $e) {
ob_start();
2003-10-27 12:52:37 +00:00
var_dump($e);
$contents = ob_get_contents();
ob_end_clean();
echo preg_replace('/object\(DOMElement\).+\{.*?\}/s', 'DOMElement', $contents);
2003-10-27 12:52:37 +00:00
}
print "--- Don't catch exception with try/catch\n";
$rootNode->appendChild($rootNode);
?>
--EXPECTF--
--- Catch exception with try/catch
2008-07-14 11:47:44 +00:00
object(DOMException)#%d (%d) {
["message":protected]=>
string(23) "Hierarchy Request Error"
["string":"Exception":private]=>
string(0) ""
["file":protected]=>
2005-04-08 12:18:57 +00:00
string(%d) "%sdom003.php"
["line":protected]=>
int(8)
["trace":"Exception":private]=>
2005-06-22 15:30:14 +00:00
array(1) {
[0]=>
array(6) {
["file"]=>
2005-06-23 10:57:52 +00:00
string(%d) "%sdom003.php"
2005-06-22 15:30:14 +00:00
["line"]=>
int(8)
["function"]=>
string(11) "appendChild"
["class"]=>
string(7) "DOMNode"
2005-06-22 15:30:14 +00:00
["type"]=>
string(2) "->"
["args"]=>
array(1) {
[0]=>
DOMElement
2005-06-22 15:30:14 +00:00
}
}
}
2008-07-13 21:22:55 +00:00
["previous":"Exception":private]=>
NULL
2008-07-14 11:47:44 +00:00
["code"]=>
int(3)
2003-10-27 12:52:37 +00:00
}
--- Don't catch exception with try/catch
2004-03-29 20:54:13 +00:00
Fatal error: Uncaught exception 'DOMException' with message 'Hierarchy Request Error' in %sdom003.php:%d
2003-10-27 12:52:37 +00:00
Stack trace:
#0 %sdom003.php(%d): DOMNode->appendChild(Object(DOMElement))
2005-06-22 15:30:14 +00:00
#1 {main}
2003-12-11 13:36:42 +00:00
thrown in %sdom003.php on line %d