1--TEST-- 2Test Dom\Document::$body getter 3--EXTENSIONS-- 4dom 5--FILE-- 6<?php 7 8echo "--- From parsing ---\n"; 9 10$dom = Dom\HTMLDocument::createFromString("<p>foo</p>", LIBXML_NOERROR); 11var_dump($dom->body?->nodeName); 12 13echo "--- After body removal ---\n"; 14 15$dom->body->remove(); 16var_dump($dom->body?->nodeName); 17 18echo "--- body in no namespace ---\n"; 19 20$tmp = $dom->documentElement->appendChild($dom->createElementNS("", "body")); 21var_dump($dom->body?->nodeName); 22$tmp->remove(); 23 24echo "--- frameset in no namespace ---\n"; 25 26$tmp = $dom->documentElement->appendChild($dom->createElementNS("", "frameset")); 27var_dump($dom->body?->nodeName); 28$tmp->remove(); 29 30echo "--- body in right namespace ---\n"; 31 32$tmp = $dom->documentElement->appendChild($dom->createElementNS("http://www.w3.org/1999/xhtml", "body")); 33var_dump($dom->body?->nodeName); 34$tmp->remove(); 35 36echo "--- frameset in right namespace ---\n"; 37 38$tmp = $dom->documentElement->appendChild($dom->createElementNS("http://www.w3.org/1999/xhtml", "frameset")); 39var_dump($dom->body?->nodeName); 40$tmp->remove(); 41 42echo "--- prefixed body in right namespace ---\n"; 43 44$tmp = $dom->documentElement->appendChild($dom->createElementNS("http://www.w3.org/1999/xhtml", "prefix:body")); 45var_dump($dom->body?->nodeName); 46$tmp->remove(); 47 48echo "--- prefixed frameset in right namespace ---\n"; 49 50$tmp = $dom->documentElement->appendChild($dom->createElementNS("http://www.w3.org/1999/xhtml", "prefix:frameset")); 51var_dump($dom->body?->nodeName); 52$tmp->remove(); 53 54echo "--- multiple body-like elements in right namespace ---\n"; 55 56$tmp1 = $dom->documentElement->appendChild($dom->createElementNS("http://www.w3.org/1999/xhtml", "prefix1:body")); 57var_dump($dom->body?->nodeName); 58$tmp2 = $dom->documentElement->appendChild($dom->createElementNS("http://www.w3.org/1999/xhtml", "prefix2:frameset")); 59var_dump($dom->body?->nodeName); 60$tmp1->remove(); 61var_dump($dom->body?->nodeName); 62$tmp2->remove(); 63var_dump($dom->body?->nodeName); 64 65echo "--- html element in no namespace ---\n"; 66 67$dom = Dom\XMLDocument::createFromString(<<<XML 68<html xmlns=""> 69 <body/> 70</html> 71XML); 72var_dump($dom->body); 73 74?> 75--EXPECT-- 76--- From parsing --- 77string(4) "BODY" 78--- After body removal --- 79NULL 80--- body in no namespace --- 81NULL 82--- frameset in no namespace --- 83NULL 84--- body in right namespace --- 85string(4) "BODY" 86--- frameset in right namespace --- 87string(8) "FRAMESET" 88--- prefixed body in right namespace --- 89string(11) "PREFIX:BODY" 90--- prefixed frameset in right namespace --- 91string(15) "PREFIX:FRAMESET" 92--- multiple body-like elements in right namespace --- 93string(12) "PREFIX1:BODY" 94string(12) "PREFIX1:BODY" 95string(16) "PREFIX2:FRAMESET" 96NULL 97--- html element in no namespace --- 98NULL 99