1--TEST--
2Dom\Document::$title getter
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8echo "=== HTML namespaced root ===\n";
9
10$dom = Dom\XMLDocument::createFromString("<root xmlns=\"http://www.w3.org/1999/xhtml\"><title>A normal title without collapsable or strippable whitespace</title></root>");
11var_dump($dom->title);
12
13$dom = Dom\XMLDocument::createFromString("<root xmlns=\"http://www.w3.org/1999/xhtml\"><title>  only ws at front</title></root>");
14var_dump($dom->title);
15
16$dom = Dom\XMLDocument::createFromString("<root xmlns=\"http://www.w3.org/1999/xhtml\"><title>only ws at back  </title></root>");
17var_dump($dom->title);
18
19$dom = Dom\XMLDocument::createFromString("<root xmlns=\"http://www.w3.org/1999/xhtml\"><ignoreme/><div><title>first</title></div><title>second</title></root>");
20var_dump($dom->title);
21
22$dom = Dom\XMLDocument::createFromString("<title xmlns=\"http://www.w3.org/1999/xhtml\">title</title>");
23var_dump($dom->title);
24
25$dom = Dom\XMLDocument::createFromString("<root xmlns=\"http://www.w3.org/1999/xhtml\"><title>  abc def   ghi  </title></root>");
26var_dump($dom->title);
27
28$dom = Dom\XMLDocument::createFromString("<root xmlns=\"http://www.w3.org/1999/xhtml\"><title></title></root>");
29var_dump($dom->title);
30
31$dom = Dom\XMLDocument::createFromString("<root xmlns=\"http://www.w3.org/1999/xhtml\"></root>");
32var_dump($dom->title);
33
34$dom = Dom\XMLDocument::createFromString("<root xmlns=\"http://www.w3.org/1999/xhtml\"><title>  \t\r\n  </title></root>");
35var_dump($dom->title);
36
37$dom = Dom\XMLDocument::createFromString("<root xmlns=\"http://www.w3.org/1999/xhtml\"><title>  \tx<?y y?><![CDATA[z]]>\n  </title></root>");
38var_dump($dom->title);
39
40$dom = Dom\XMLDocument::createFromString("<root xmlns=\"http://www.w3.org/1999/xhtml\"><title><div><!-- comment -->x</div>y<p>z</p>w</title></root>");
41var_dump($dom->title);
42
43$dom = Dom\XMLDocument::createFromString("<root xmlns=\"http://www.w3.org/1999/xhtml\"><title>title\nhere</title></root>");
44var_dump($dom->title);
45
46$dom = Dom\XMLDocument::createFromString("<root xmlns=\"http://www.w3.org/1999/xhtml\"><title/></root>");
47$dom->getElementsByTagName('title')[0]->appendChild($dom->importLegacyNode(new DOMText));
48var_dump($dom->title);
49
50echo "=== SVG namespaced root ===\n";
51
52$dom = Dom\XMLDocument::createFromString("<root xmlns=\"http://www.w3.org/1999/xhtml\"><title>title</title></root>");
53var_dump($dom->title);
54
55$dom = Dom\XMLDocument::createFromString("<svg xmlns=\"http://www.w3.org/1999/xhtml\"><title xmlns=\"http://www.w3.org/1999/xhtml\">title</title></svg>");
56var_dump($dom->title);
57
58$dom = Dom\XMLDocument::createFromString("<svg xmlns=\"http://www.w3.org/1999/xhtml\"><title xmlns=\"http://www.w3.org/1999/xhtml\">title</title><foo/><title>hi</title></svg>");
59var_dump($dom->title);
60
61$dom = Dom\XMLDocument::createFromString("<svg xmlns=\"http://www.w3.org/1999/xhtml\"/>");
62var_dump($dom->title);
63
64?>
65--EXPECT--
66=== HTML namespaced root ===
67string(59) "A normal title without collapsable or strippable whitespace"
68string(16) "only ws at front"
69string(15) "only ws at back"
70string(5) "first"
71string(5) "title"
72string(11) "abc def ghi"
73string(0) ""
74string(0) ""
75string(0) ""
76string(2) "xz"
77string(2) "yw"
78string(10) "title here"
79string(0) ""
80=== SVG namespaced root ===
81string(5) "title"
82string(5) "title"
83string(5) "title"
84string(0) ""
85