diff --git a/ext/dom/tests/modern/common/namespace_sxe_interaction.phpt b/ext/dom/tests/modern/common/namespace_sxe_interaction.phpt new file mode 100644 index 00000000000..dfe01ba279b --- /dev/null +++ b/ext/dom/tests/modern/common/namespace_sxe_interaction.phpt @@ -0,0 +1,53 @@ +--TEST-- +Serialization interaction between simplexml and dom for namespaces +--EXTENSIONS-- +dom +simplexml +--FILE-- +'); +$sxe = simplexml_import_dom($dom); + +$sxe->addAttribute('a:attr', 'value', 'urn:a'); +$sxe->addChild('b:child', 'value', 'urn:b'); +$sxe->addChild('foo', 'value2'); +$dom->documentElement->firstElementChild->appendChild($dom->createElementNS('urn:c', 'c:child')); + +echo "namespace c: "; +var_dump($dom->documentElement->firstElementChild->firstElementChild->lookupNamespaceURI('c')); +echo "namespace b: "; +var_dump($dom->documentElement->firstElementChild->firstElementChild->lookupNamespaceURI('b')); +echo "namespace a: "; +var_dump($dom->documentElement->firstElementChild->firstElementChild->lookupNamespaceURI('a')); + +echo "=== serialize SimpleXML ===\n"; + +echo $sxe->saveXML(), "\n"; + +echo "=== serialize DOM ===\n"; + +echo $dom->saveXML(), "\n\n"; + +echo "=== serialize imported DOM ===\n"; + +// Importing should yield the exact same document +$new_dom = Dom\XMLDocument::createEmpty(); +$new_dom->append($new_dom->importNode($dom->documentElement, true)); +echo $new_dom->saveXML(), "\n"; + +?> +--EXPECT-- +namespace c: string(5) "urn:c" +namespace b: string(5) "urn:b" +namespace a: NULL +=== serialize SimpleXML === + +value +=== serialize DOM === + +value + +=== serialize imported DOM === + +value