Annotation of embedaddon/php/ext/dom/tests/dom003.phpt, revision 1.1.1.2

1.1       misho       1: --TEST--
                      2: Test 3: Exception Test
                      3: --SKIPIF--
                      4: <?php require_once('skipif.inc'); ?>
                      5: --FILE--
                      6: <?php
                      7: 
                      8: $dom = new domdocument;
                      9: $dom->load(dirname(__FILE__)."/book.xml");
                     10: $rootNode = $dom->documentElement;
                     11: print "--- Catch exception with try/catch\n";
                     12: try {
                     13:     $rootNode->appendChild($rootNode);
                     14: } catch (domexception $e) {
1.1.1.2 ! misho      15:        ob_start();
1.1       misho      16:     var_dump($e);
1.1.1.2 ! misho      17:        $contents = ob_get_contents();
        !            18:        ob_end_clean();
        !            19:        echo preg_replace('/object\(DOMElement\).+\{.*?\}/s', 'DOMElement', $contents);
1.1       misho      20: }
                     21: print "--- Don't catch exception with try/catch\n";
                     22: $rootNode->appendChild($rootNode);
                     23: 
                     24: 
                     25: ?>
                     26: --EXPECTF--
                     27: --- Catch exception with try/catch
                     28: object(DOMException)#%d (%d) {
                     29:   ["message":protected]=>
                     30:   string(23) "Hierarchy Request Error"
                     31:   ["string":"Exception":private]=>
                     32:   string(0) ""
                     33:   ["file":protected]=>
                     34:   string(%d) "%sdom003.php"
                     35:   ["line":protected]=>
                     36:   int(8)
                     37:   ["trace":"Exception":private]=>
                     38:   array(1) {
                     39:     [0]=>
                     40:     array(6) {
                     41:       ["file"]=>
                     42:       string(%d) "%sdom003.php"
                     43:       ["line"]=>
                     44:       int(8)
                     45:       ["function"]=>
                     46:       string(11) "appendChild"
                     47:       ["class"]=>
                     48:       string(7) "DOMNode"
                     49:       ["type"]=>
                     50:       string(2) "->"
                     51:       ["args"]=>
                     52:       array(1) {
                     53:         [0]=>
1.1.1.2 ! misho      54:         DOMElement
1.1       misho      55:       }
                     56:     }
                     57:   }
                     58:   ["previous":"Exception":private]=>
                     59:   NULL
                     60:   ["code"]=>
                     61:   int(3)
                     62: }
                     63: --- Don't catch exception with try/catch
                     64: 
                     65: Fatal error: Uncaught exception 'DOMException' with message 'Hierarchy Request Error' in %sdom003.php:%d
                     66: Stack trace:
1.1.1.2 ! misho      67: #0 %sdom003.php(%d): DOMNode->appendChild(Object(DOMElement))
1.1       misho      68: #1 {main}
                     69:   thrown in %sdom003.php on line %d

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>