bug28721.phpt
来自「PHP v6.0 For Linux 运行环境:Win9X/ WinME/ Wi」· PHPT 代码 · 共 486 行
PHPT
486 行
--TEST--Bug # 28721: (appendChild() and insertBefore() unset DOMText)--SKIPIF--<?php require_once('skipif.inc'); ?>--FILE--<?phpfunction print_node(DomNode $node) { echo "name (value): " . $node->nodeName . " (" . $node->nodeValue . ")\n";}function print_node_r(DomNode $node) { static $indent = ""; echo "\n" . $indent; print_node($node); echo $indent . "parent: "; if ( $node->parentNode ) print_node($node->parentNode); else echo "NULL\n"; echo $indent . "previousSibling: "; if ( $node->previousSibling ) print_node($node->previousSibling); else echo "NULL\n"; echo $indent . "nextSibling: "; if ( $node->nextSibling ) print_node($node->nextSibling); else echo "NULL\n"; if ( !$node->hasChildNodes() ) return; foreach ($node->childNodes as $child) { $old_indent = $indent; $indent .= " "; print_node_r($child); $indent = $old_indent; }}function err_handler($errno, $errstr, $errfile, $errline) { echo "Error ($errno) on line $errline: $errstr\n";}// Record 'DocumentFragment is empty' warningsset_error_handler("err_handler", E_WARNING);$xml = new DomDocument();$p = $xml->createElement("p");$p->appendChild($t1 = $xml->createTextNode(" t1 "));$p->appendChild($b = $xml->createElement("b"));$b->appendChild($xml->createTextNode("X"));$p->appendChild($t2 = $xml->createTextNode(" t2 "));$p->appendChild($xml->createTextNode(" xxx "));print_node_r($p);echo "\nAppend t1 to p:\n";$ret = $p->appendChild($t1);print_node_r($p);echo "\n";echo "t1 == ret: ";var_dump( $t1 === $ret );$d = $xml->createElement("div");$d->appendChild($t3 = $xml->createTextNode(" t3 "));$d->appendChild($b = $xml->createElement("b"));$b->appendChild($xml->createElement("X"));$d->appendChild($t4 = $xml->createTextNode(" t4 "));$d->appendChild($xml->createTextNode(" xxx "));echo "\ndiv:\n";print_node_r($d);echo "\nInsert t4 before t3:\n";$ret = $d->insertBefore($t4, $t3);print_node_r($d);echo "\n";$frag = $xml->createDocumentFragment();$t5 = $frag->appendChild($xml->createTextNode(" t5 "));$frag->appendChild($i = $xml->createElement("i"));$i->appendChild($xml->createTextNode(" frob "));$frag->appendChild($xml->createTextNOde(" t6 "));echo "\np:\n";print_node_r($p);echo "\nFragment:\n";print_node_r($frag);echo "\nAppending fragment to p:\n";$p->appendChild($frag);print_node_r($p);echo "\nFragment:\n";print_node_r($frag);echo "\ndiv:\n";print_node_r($d);echo "\nInserting fragment before t4\n";$d->insertBefore($frag, $t4);print_node_r($d);echo "\np:\n";print_node_r($p);?>--EXPECT--name (value): p ( t1 X t2 xxx )parent: NULLpreviousSibling: NULLnextSibling: NULL name (value): #text ( t1 ) parent: name (value): p ( t1 X t2 xxx ) previousSibling: NULL nextSibling: name (value): b (X) name (value): b (X) parent: name (value): p ( t1 X t2 xxx ) previousSibling: name (value): #text ( t1 ) nextSibling: name (value): #text ( t2 ) name (value): #text (X) parent: name (value): b (X) previousSibling: NULL nextSibling: NULL name (value): #text ( t2 ) parent: name (value): p ( t1 X t2 xxx ) previousSibling: name (value): b (X) nextSibling: name (value): #text ( xxx ) name (value): #text ( xxx ) parent: name (value): p ( t1 X t2 xxx ) previousSibling: name (value): #text ( t2 ) nextSibling: NULLAppend t1 to p:name (value): p (X t2 xxx t1 )parent: NULLpreviousSibling: NULLnextSibling: NULL name (value): b (X) parent: name (value): p (X t2 xxx t1 ) previousSibling: NULL nextSibling: name (value): #text ( t2 ) name (value): #text (X) parent: name (value): b (X) previousSibling: NULL nextSibling: NULL name (value): #text ( t2 ) parent: name (value): p (X t2 xxx t1 ) previousSibling: name (value): b (X) nextSibling: name (value): #text ( xxx ) name (value): #text ( xxx ) parent: name (value): p (X t2 xxx t1 ) previousSibling: name (value): #text ( t2 ) nextSibling: name (value): #text ( t1 ) name (value): #text ( t1 ) parent: name (value): p (X t2 xxx t1 ) previousSibling: name (value): #text ( xxx ) nextSibling: NULLt1 == ret: bool(true)div:name (value): div ( t3 t4 xxx )parent: NULLpreviousSibling: NULLnextSibling: NULL name (value): #text ( t3 ) parent: name (value): div ( t3 t4 xxx ) previousSibling: NULL nextSibling: name (value): b () name (value): b () parent: name (value): div ( t3 t4 xxx ) previousSibling: name (value): #text ( t3 ) nextSibling: name (value): #text ( t4 ) name (value): X () parent: name (value): b () previousSibling: NULL nextSibling: NULL name (value): #text ( t4 ) parent: name (value): div ( t3 t4 xxx ) previousSibling: name (value): b () nextSibling: name (value): #text ( xxx ) name (value): #text ( xxx ) parent: name (value): div ( t3 t4 xxx ) previousSibling: name (value): #text ( t4 ) nextSibling: NULLInsert t4 before t3:name (value): div ( t4 t3 xxx )parent: NULLpreviousSibling: NULLnextSibling: NULL name (value): #text ( t4 ) parent: name (value): div ( t4 t3 xxx ) previousSibling: NULL nextSibling: name (value): #text ( t3 ) name (value): #text ( t3 ) parent: name (value): div ( t4 t3 xxx ) previousSibling: name (value): #text ( t4 ) nextSibling: name (value): b () name (value): b () parent: name (value): div ( t4 t3 xxx ) previousSibling: name (value): #text ( t3 ) nextSibling: name (value): #text ( xxx ) name (value): X () parent: name (value): b () previousSibling: NULL nextSibling: NULL name (value): #text ( xxx ) parent: name (value): div ( t4 t3 xxx ) previousSibling: name (value): b () nextSibling: NULLp:name (value): p (X t2 xxx t1 )parent: NULLpreviousSibling: NULLnextSibling: NULL name (value): b (X) parent: name (value): p (X t2 xxx t1 ) previousSibling: NULL nextSibling: name (value): #text ( t2 ) name (value): #text (X) parent: name (value): b (X) previousSibling: NULL nextSibling: NULL name (value): #text ( t2 ) parent: name (value): p (X t2 xxx t1 ) previousSibling: name (value): b (X) nextSibling: name (value): #text ( xxx ) name (value): #text ( xxx ) parent: name (value): p (X t2 xxx t1 ) previousSibling: name (value): #text ( t2 ) nextSibling: name (value): #text ( t1 ) name (value): #text ( t1 ) parent: name (value): p (X t2 xxx t1 ) previousSibling: name (value): #text ( xxx ) nextSibling: NULLFragment:name (value): #document-fragment ()parent: NULLpreviousSibling: NULLnextSibling: NULL name (value): #text ( t5 ) parent: name (value): #document-fragment () previousSibling: NULL nextSibling: name (value): i ( frob ) name (value): i ( frob ) parent: name (value): #document-fragment () previousSibling: name (value): #text ( t5 ) nextSibling: name (value): #text ( t6 ) name (value): #text ( frob ) parent: name (value): i ( frob ) previousSibling: NULL nextSibling: NULL name (value): #text ( t6 ) parent: name (value): #document-fragment () previousSibling: name (value): i ( frob ) nextSibling: NULLAppending fragment to p:name (value): p (X t2 xxx t1 t5 frob t6 )parent: NULLpreviousSibling: NULLnextSibling: NULL name (value): b (X) parent: name (value): p (X t2 xxx t1 t5 frob t6 ) previousSibling: NULL nextSibling: name (value): #text ( t2 ) name (value): #text (X) parent: name (value): b (X) previousSibling: NULL nextSibling: NULL name (value): #text ( t2 ) parent: name (value): p (X t2 xxx t1 t5 frob t6 ) previousSibling: name (value): b (X) nextSibling: name (value): #text ( xxx ) name (value): #text ( xxx ) parent: name (value): p (X t2 xxx t1 t5 frob t6 ) previousSibling: name (value): #text ( t2 ) nextSibling: name (value): #text ( t1 ) name (value): #text ( t1 ) parent: name (value): p (X t2 xxx t1 t5 frob t6 ) previousSibling: name (value): #text ( xxx ) nextSibling: name (value): #text ( t5 ) name (value): #text ( t5 ) parent: name (value): p (X t2 xxx t1 t5 frob t6 ) previousSibling: name (value): #text ( t1 ) nextSibling: name (value): i ( frob ) name (value): i ( frob ) parent: name (value): p (X t2 xxx t1 t5 frob t6 ) previousSibling: name (value): #text ( t5 ) nextSibling: name (value): #text ( t6 ) name (value): #text ( frob ) parent: name (value): i ( frob ) previousSibling: NULL nextSibling: NULL name (value): #text ( t6 ) parent: name (value): p (X t2 xxx t1 t5 frob t6 ) previousSibling: name (value): i ( frob ) nextSibling: NULLFragment:name (value): #document-fragment ()parent: NULLpreviousSibling: NULLnextSibling: NULLdiv:name (value): div ( t4 t3 xxx )parent: NULLpreviousSibling: NULLnextSibling: NULL name (value): #text ( t4 ) parent: name (value): div ( t4 t3 xxx ) previousSibling: NULL nextSibling: name (value): #text ( t3 ) name (value): #text ( t3 ) parent: name (value): div ( t4 t3 xxx ) previousSibling: name (value): #text ( t4 ) nextSibling: name (value): b () name (value): b () parent: name (value): div ( t4 t3 xxx ) previousSibling: name (value): #text ( t3 ) nextSibling: name (value): #text ( xxx ) name (value): X () parent: name (value): b () previousSibling: NULL nextSibling: NULL name (value): #text ( xxx ) parent: name (value): div ( t4 t3 xxx ) previousSibling: name (value): b () nextSibling: NULLInserting fragment before t4Error (2) on line 109: DOMNode::insertBefore(): Document Fragment is emptyname (value): div ( t4 t3 xxx )parent: NULLpreviousSibling: NULLnextSibling: NULL name (value): #text ( t4 ) parent: name (value): div ( t4 t3 xxx ) previousSibling: NULL nextSibling: name (value): #text ( t3 ) name (value): #text ( t3 ) parent: name (value): div ( t4 t3 xxx ) previousSibling: name (value): #text ( t4 ) nextSibling: name (value): b () name (value): b () parent: name (value): div ( t4 t3 xxx ) previousSibling: name (value): #text ( t3 ) nextSibling: name (value): #text ( xxx ) name (value): X () parent: name (value): b () previousSibling: NULL nextSibling: NULL name (value): #text ( xxx ) parent: name (value): div ( t4 t3 xxx ) previousSibling: name (value): b () nextSibling: NULLp:name (value): p (X t2 xxx t1 t5 frob t6 )parent: NULLpreviousSibling: NULLnextSibling: NULL name (value): b (X) parent: name (value): p (X t2 xxx t1 t5 frob t6 ) previousSibling: NULL nextSibling: name (value): #text ( t2 ) name (value): #text (X) parent: name (value): b (X) previousSibling: NULL nextSibling: NULL name (value): #text ( t2 ) parent: name (value): p (X t2 xxx t1 t5 frob t6 ) previousSibling: name (value): b (X) nextSibling: name (value): #text ( xxx ) name (value): #text ( xxx ) parent: name (value): p (X t2 xxx t1 t5 frob t6 ) previousSibling: name (value): #text ( t2 ) nextSibling: name (value): #text ( t1 ) name (value): #text ( t1 ) parent: name (value): p (X t2 xxx t1 t5 frob t6 ) previousSibling: name (value): #text ( xxx ) nextSibling: name (value): #text ( t5 ) name (value): #text ( t5 ) parent: name (value): p (X t2 xxx t1 t5 frob t6 ) previousSibling: name (value): #text ( t1 ) nextSibling: name (value): i ( frob ) name (value): i ( frob ) parent: name (value): p (X t2 xxx t1 t5 frob t6 ) previousSibling: name (value): #text ( t5 ) nextSibling: name (value): #text ( t6 ) name (value): #text ( frob ) parent: name (value): i ( frob ) previousSibling: NULL nextSibling: NULL name (value): #text ( t6 ) parent: name (value): p (X t2 xxx t1 t5 frob t6 ) previousSibling: name (value): i ( frob ) nextSibling: NULL
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?