1--TEST--
2Dom\Document::$title setter
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8echo "\n=== SVG namespaced test ===\n\n";
9
10$dom = Dom\XMLDocument::createFromString('<root xmlns="http://www.w3.org/2000/svg"/>');
11$dom->title = "hello &amp; world";
12echo $dom->saveXML(), "\n";
13
14$dom = Dom\XMLDocument::createFromString('<svg xmlns="http://www.w3.org/2000/svg"/>');
15$dom->title = "hello &amp; world";
16echo $dom->saveXML(), "\n";
17$dom->title = "";
18echo $dom->saveXML(), "\n";
19$dom->title = "test";
20echo $dom->saveXML(), "\n";
21
22$dom = Dom\XMLDocument::createFromString('<svg:svg xmlns:svg="http://www.w3.org/2000/svg"/>');
23$dom->title = "test";
24echo $dom->saveXML(), "\n";
25var_dump($dom->documentElement->firstElementChild->prefix, $dom->documentElement->firstElementChild->namespaceURI);
26
27$dom = Dom\XMLDocument::createFromString('<svg xmlns="http://www.w3.org/2000/svg">first node<div/></svg>');
28$dom->title = "test";
29echo $dom->saveXML(), "\n";
30$dom->documentElement->firstElementChild->remove();
31$dom->title = "test2";
32echo $dom->saveXML(), "\n";
33
34echo "\n=== HTML namespaced test ===\n\n";
35
36$dom = Dom\XMLDocument::createFromString('<root xmlns="http://www.w3.org/1999/xhtml"/>');
37$dom->title = "test";
38echo $dom->saveXML(), "\n";
39
40$dom = Dom\XMLDocument::createFromString('<html xmlns="http://www.w3.org/1999/xhtml"/>');
41$dom->title = "test";
42echo $dom->saveXML(), "\n";
43
44$dom = Dom\XMLDocument::createFromString('<html xmlns="http://www.w3.org/1999/xhtml"><foo/><head/></html>');
45$dom->title = "test";
46echo $dom->saveXML(), "\n";
47
48$dom = Dom\XMLDocument::createFromString('<html xmlns="http://www.w3.org/1999/xhtml"><head><?ignore me?></head></html>');
49$dom->title = "test";
50echo $dom->saveXML(), "\n";
51
52$dom = Dom\XMLDocument::createFromString('<html xmlns="http://www.w3.org/1999/xhtml"><head><?ignore me?><title>foo<div/></title></head></html>');
53$dom->title = "test";
54echo $dom->saveXML(), "\n";
55
56echo "\n=== neither namespaced test ===\n\n";
57
58$dom = Dom\XMLDocument::createEmpty();
59$dom->title = "";
60echo $dom->saveXML(), "\n";
61
62$dom = Dom\XMLDocument::createFromString('<root/>');
63$dom->title = "test";
64echo $dom->saveXML(), "\n";
65
66?>
67--EXPECT--
68=== SVG namespaced test ===
69
70<?xml version="1.0" encoding="UTF-8"?>
71<root xmlns="http://www.w3.org/2000/svg"/>
72<?xml version="1.0" encoding="UTF-8"?>
73<svg xmlns="http://www.w3.org/2000/svg"><title>hello &amp;amp; world</title></svg>
74<?xml version="1.0" encoding="UTF-8"?>
75<svg xmlns="http://www.w3.org/2000/svg"><title></title></svg>
76<?xml version="1.0" encoding="UTF-8"?>
77<svg xmlns="http://www.w3.org/2000/svg"><title>test</title></svg>
78<?xml version="1.0" encoding="UTF-8"?>
79<svg:svg xmlns:svg="http://www.w3.org/2000/svg"><svg:title>test</svg:title></svg:svg>
80NULL
81string(26) "http://www.w3.org/2000/svg"
82<?xml version="1.0" encoding="UTF-8"?>
83<svg xmlns="http://www.w3.org/2000/svg"><title>test</title>first node<div/></svg>
84<?xml version="1.0" encoding="UTF-8"?>
85<svg xmlns="http://www.w3.org/2000/svg"><title>test2</title>first node<div/></svg>
86
87=== HTML namespaced test ===
88
89<?xml version="1.0" encoding="UTF-8"?>
90<root xmlns="http://www.w3.org/1999/xhtml"></root>
91<?xml version="1.0" encoding="UTF-8"?>
92<html xmlns="http://www.w3.org/1999/xhtml"></html>
93<?xml version="1.0" encoding="UTF-8"?>
94<html xmlns="http://www.w3.org/1999/xhtml"><foo></foo><head><title>test</title></head></html>
95<?xml version="1.0" encoding="UTF-8"?>
96<html xmlns="http://www.w3.org/1999/xhtml"><head><?ignore me?><title>test</title></head></html>
97<?xml version="1.0" encoding="UTF-8"?>
98<html xmlns="http://www.w3.org/1999/xhtml"><head><?ignore me?><title>test</title></head></html>
99
100=== neither namespaced test ===
101
102<?xml version="1.0" encoding="UTF-8"?>
103
104<?xml version="1.0" encoding="UTF-8"?>
105<root/>
106