diff options
author | Rob Richards <rrichards@php.net> | 2005-08-28 16:23:25 +0000 |
---|---|---|
committer | Rob Richards <rrichards@php.net> | 2005-08-28 16:23:25 +0000 |
commit | 1b02f3ec31abdcddaaf447b7d7d3862b623d1b93 (patch) | |
tree | 782766d1e933e481ca9db87e87d8034356438a52 /ext/dom/tests | |
parent | 2b53e968329711218e4a15377294a36c852bbce1 (diff) | |
download | php-git-1b02f3ec31abdcddaaf447b7d7d3862b623d1b93.tar.gz |
MFH: Fixed bug #34276 (setAttributeNS doesn't work with default namespace)
Add test
Diffstat (limited to 'ext/dom/tests')
-rw-r--r-- | ext/dom/tests/bug34276.phpt | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/ext/dom/tests/bug34276.phpt b/ext/dom/tests/bug34276.phpt new file mode 100644 index 0000000000..e1083364a5 --- /dev/null +++ b/ext/dom/tests/bug34276.phpt @@ -0,0 +1,43 @@ +--TEST-- +Bug # 34276: setAttributeNS and default namespace +--SKIPIF-- +<?php require_once('skipif.php'); ?> +--FILE-- +<?php +$xml = <<<HERE +<?xml version="1.0" encoding="ISO-8859-1" ?> +<foo xmlns="http://www.example.com/ns/foo" + xmlns:fubar="http://www.example.com/ns/fubar" attra="attra" /> +HERE; + +function dump($elems) { + foreach ($elems as $elem) { + var_dump($elem->nodeName); + dump($elem->childNodes); + } +} + +$dom = new DOMDocument(); +$dom->loadXML($xml); +$foo = $dom->documentElement; +var_dump($foo->hasAttributeNS('http://www.example.com/ns/foo', 'attra')); +var_dump($foo->getAttributeNS('http://www.example.com/ns/foo', 'attra')); + +$foo->setAttributeNS('http://www.example.com/ns/foo', 'attra', 'attranew'); +$foo->setAttributeNS('http://www.example.com/ns/fubar', 'attrb', 'attrbnew'); +$foo->setAttributeNS('http://www.example.com/ns/foo', 'attrc', 'attrc'); + +var_dump($foo->getAttributeNS('http://www.example.com/ns/foo', 'attra')); +var_dump($foo->getAttributeNS('http://www.example.com/ns/fubar', 'attrb')); +var_dump($foo->getAttributeNS('http://www.example.com/ns/foo', 'attrc')); + +print $dom->saveXML(); +?> +--EXPECT-- +bool(false) +string(0) "" +string(8) "attranew" +string(8) "attrbnew" +string(5) "attrc" +<?xml version="1.0" encoding="ISO-8859-1"?> +<foo xmlns="http://www.example.com/ns/foo" xmlns:fubar="http://www.example.com/ns/fubar" xmlns:default="http://www.example.com/ns/foo" attra="attra" default:attra="attranew" fubar:attrb="attrbnew" default:attrc="attrc"/> |