diff options
Diffstat (limited to 'ext/simplexml/tests')
| -rwxr-xr-x | ext/simplexml/tests/027.phpt | 14 | ||||
| -rwxr-xr-x | ext/simplexml/tests/bug35785.phpt | 17 | ||||
| -rwxr-xr-x | ext/simplexml/tests/bug37565.phpt | 2 | ||||
| -rw-r--r-- | ext/simplexml/tests/bug41582.phpt | 18 | ||||
| -rw-r--r-- | ext/simplexml/tests/bug41861.phpt | 38 | ||||
| -rw-r--r-- | ext/simplexml/tests/bug41867.phpt | 14 | ||||
| -rw-r--r-- | ext/simplexml/tests/bug41947.phpt | 14 |
7 files changed, 103 insertions, 14 deletions
diff --git a/ext/simplexml/tests/027.phpt b/ext/simplexml/tests/027.phpt index 105f99066..a531ccad4 100755 --- a/ext/simplexml/tests/027.phpt +++ b/ext/simplexml/tests/027.phpt @@ -40,7 +40,7 @@ $people->person[3] = 'Minni-me'; $people->person[2]['gender'] = 'male'; traverse_xml($people); $people->person[3]['gender'] = 'error'; - +traverse_xml($people); ?> ===DONE=== --EXPECTF-- @@ -70,6 +70,14 @@ Warning: main(): Cannot add element person number 3 when only 2 such elements ex <person gender="male">Minni-me </person> </people> - -Notice: Indirect modification of overloaded element of SimpleXMLElement has no effect in %s027.php on line %d +<people> + <person gender="female">Jane + </person> + <person gender="male">Joe + </person> + <person gender="male">Minni-me + </person> + <person gender="error"> + </person> +</people> ===DONE=== diff --git a/ext/simplexml/tests/bug35785.phpt b/ext/simplexml/tests/bug35785.phpt index 4156a7c9f..0e03f07c5 100755 --- a/ext/simplexml/tests/bug35785.phpt +++ b/ext/simplexml/tests/bug35785.phpt @@ -8,13 +8,13 @@ Bug #35785 (SimpleXML memory read error) $xml = simplexml_load_string("<root></root>"); $xml->bla->posts->name = "FooBar"; echo $xml->asXML(); - -echo "===FAIL===\n"; - $xml = simplexml_load_string("<root></root>"); $count = count($xml->bla->posts); var_dump($count); -$xml->bla->posts[++$count]->name = "FooBar"; +$xml->bla->posts[$count]->name = "FooBar"; +echo $xml->asXML(); +$xml = simplexml_load_string("<root></root>"); +$xml->bla->posts[]->name = "FooBar"; echo $xml->asXML(); ?> ===DONE=== @@ -22,12 +22,9 @@ echo $xml->asXML(); --EXPECTF-- <?xml version="1.0"?> <root><bla><posts><name>FooBar</name></posts></bla></root> -===FAIL=== int(0) - -Notice: Indirect modification of overloaded element of SimpleXMLElement has no effect in %sbug35785.php on line %d - -Strict Standards: Creating default object from empty value in %sbug35785.php on line %d <?xml version="1.0"?> -<root><bla><posts/></bla></root> +<root><bla><posts><name>FooBar</name></posts></bla></root> +<?xml version="1.0"?> +<root><bla><posts><name>FooBar</name></posts></bla></root> ===DONE=== diff --git a/ext/simplexml/tests/bug37565.phpt b/ext/simplexml/tests/bug37565.phpt index 019fc7169..c1e51040b 100755 --- a/ext/simplexml/tests/bug37565.phpt +++ b/ext/simplexml/tests/bug37565.phpt @@ -1,7 +1,7 @@ --TEST-- Bug #37565 (Using reflection::export with simplexml causing a crash) --SKIPIF-- -<?php if (!extension_loaded("simplexml")) print "skip"; ?> +<?php if (!extension_loaded("simplexml") || !extension_loaded('reflection')) print "skip"; ?> --FILE-- <?php diff --git a/ext/simplexml/tests/bug41582.phpt b/ext/simplexml/tests/bug41582.phpt new file mode 100644 index 000000000..b689607d0 --- /dev/null +++ b/ext/simplexml/tests/bug41582.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #41582 (SimpleXML crashes when accessing newly created element) +--FILE-- +<?php + +$xml = new SimpleXMLElement('<?xml version="1.0" standalone="yes"?> +<collection></collection>'); + +$xml->movie[]->characters->character[0]->name = 'Miss Coder'; + +echo($xml->asXml()); + +echo "Done\n"; +?> +--EXPECT-- +<?xml version="1.0" standalone="yes"?> +<collection><movie><characters><character><name>Miss Coder</name></character></characters></movie></collection> +Done diff --git a/ext/simplexml/tests/bug41861.phpt b/ext/simplexml/tests/bug41861.phpt new file mode 100644 index 000000000..07622ebbd --- /dev/null +++ b/ext/simplexml/tests/bug41861.phpt @@ -0,0 +1,38 @@ +--TEST-- +Bug #41861 (getNamespaces() returns the namespaces of a node's siblings) +--FILE-- +<?php + +$xml = simplexml_load_string('<root> + <first_node_no_ns /> + <ns1:node1 xmlns:ns1="#ns1" /> + <ns2:node2 xmlns:ns2="#ns2" /> + <ns3:node3 xmlns:ns3="#ns3" /> + <last_node_no_ns /> +</root>'); + +$name = $xml->getName(); +$namespaces = $xml->getNamespaces(True); +echo "root(recursive): '$name' -- namespaces: ", implode(', ', $namespaces), "\n"; +$namespaces = $xml->getNamespaces(False); +echo "root(non-recursive): '$name' -- namespaces: ", implode(', ', $namespaces), "\n"; + +foreach (array(null, '#ns1', '#ns2', '#ns3') as $ns) +{ + foreach ($xml->children($ns) as $child) + { + $name = $child->getName(); + $namespaces = $child->getNamespaces(false); + + echo "children($ns): '$name' -- namespaces: ", implode(', ', $namespaces), "\n"; + } +} +?> +--EXPECT-- +root(recursive): 'root' -- namespaces: #ns1, #ns2, #ns3 +root(non-recursive): 'root' -- namespaces: +children(): 'first_node_no_ns' -- namespaces: +children(): 'last_node_no_ns' -- namespaces: +children(#ns1): 'node1' -- namespaces: #ns1 +children(#ns2): 'node2' -- namespaces: #ns2 +children(#ns3): 'node3' -- namespaces: #ns3 diff --git a/ext/simplexml/tests/bug41867.phpt b/ext/simplexml/tests/bug41867.phpt new file mode 100644 index 000000000..f530f95dc --- /dev/null +++ b/ext/simplexml/tests/bug41867.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #41867 (getName is broken) +--FILE-- +<?php + +$a = simplexml_load_string("<a><b><c/></b></a>"); +echo $a->getName()."\n"; +echo $a->b->getName()."\n"; +echo $a->b->c->getName(); +?> +--EXPECT-- +a +b +c diff --git a/ext/simplexml/tests/bug41947.phpt b/ext/simplexml/tests/bug41947.phpt new file mode 100644 index 000000000..7af9ff8e7 --- /dev/null +++ b/ext/simplexml/tests/bug41947.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #41947 (addChild incorrectly registers empty strings as namespaces) +--FILE-- +<?php +$xml = simplexml_load_string('<?xml version="1.0" encoding="utf-8"?><root xmlns:myns="http://myns" />'); +$grandchild = $xml->addChild('child', null, 'http://myns')->addChild('grandchild', 'hello', ''); + +$gchild = $xml->xpath("//grandchild"); +if (count($gchild) > 0) { + echo $gchild[0]; +} +?> +--EXPECT-- +hello |
