xref: /PHP-8.1/ext/simplexml/tests/bug72971_2.phpt (revision 7f2f0c00)
1--TEST--
2Bug #72971 (2): SimpleXML property write does not respect namespace
3--EXTENSIONS--
4simplexml
5--FILE--
6<?php
7
8$xml = new SimpleXMLElement('<root xmlns:ns="ns"><foo>bar</foo><ns:foo>ns:bar</ns:foo></root>');
9
10$xml->foo = 'new-bar';
11var_dump($xml->foo);
12var_dump($xml->children('ns')->foo);
13
14$xml->children('ns')->foo = 'ns:new-bar';
15var_dump($xml->foo);
16var_dump($xml->children('ns')->foo);
17
18?>
19--EXPECT--
20object(SimpleXMLElement)#2 (1) {
21  [0]=>
22  string(7) "new-bar"
23}
24object(SimpleXMLElement)#3 (1) {
25  [0]=>
26  string(6) "ns:bar"
27}
28object(SimpleXMLElement)#3 (1) {
29  [0]=>
30  string(7) "new-bar"
31}
32object(SimpleXMLElement)#2 (1) {
33  [0]=>
34  string(10) "ns:new-bar"
35}
36