diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-03-14 05:42:27 +0000 |
---|---|---|
committer | <> | 2013-04-03 16:25:08 +0000 |
commit | c4dd7a1a684490673e25aaf4fabec5df138854c4 (patch) | |
tree | 4d57c44caae4480efff02b90b9be86f44bf25409 /ext/simplexml/tests/007.phpt | |
download | php2-master.tar.gz |
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/simplexml/tests/007.phpt')
-rw-r--r-- | ext/simplexml/tests/007.phpt | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/ext/simplexml/tests/007.phpt b/ext/simplexml/tests/007.phpt new file mode 100644 index 0000000..51d7a84 --- /dev/null +++ b/ext/simplexml/tests/007.phpt @@ -0,0 +1,97 @@ +--TEST-- +SimpleXML: Attributes +--SKIPIF-- +<?php if (!extension_loaded("simplexml")) print "skip"; ?> +--FILE-- +<?php + +$xml =<<<EOF +<?xml version='1.0'?> +<!DOCTYPE sxe SYSTEM "notfound.dtd"> +<sxe id="elem1"> + <elem1 attr1='first'> + <!-- comment --> + <elem2> + <elem3> + <elem4> + <?test processing instruction ?> + </elem4> + </elem3> + </elem2> + </elem1> +</sxe> +EOF; + +$sxe = simplexml_load_string($xml); + +echo "===Property===\n"; +var_dump($sxe->elem1); +echo "===Array===\n"; +var_dump($sxe['id']); +var_dump($sxe->elem1['attr1']); +echo "===Set===\n"; +$sxe['id'] = "Changed1"; +var_dump($sxe['id']); +$sxe->elem1['attr1'] = 12; +var_dump($sxe->elem1['attr1']); +echo "===Unset===\n"; +unset($sxe['id']); +var_dump($sxe['id']); +unset($sxe->elem1['attr1']); +var_dump($sxe->elem1['attr1']); +echo "===Misc.===\n"; +$a = 4; +var_dump($a); +$dummy = $sxe->elem1[$a]; +var_dump($a); +?> +===Done=== +--EXPECTF-- +===Property=== +object(SimpleXMLElement)#%d (3) { + ["@attributes"]=> + array(1) { + ["attr1"]=> + string(5) "first" + } + ["comment"]=> + object(SimpleXMLElement)#%d (0) { + } + ["elem2"]=> + object(SimpleXMLElement)#%d (1) { + ["elem3"]=> + object(SimpleXMLElement)#%d (1) { + ["elem4"]=> + object(SimpleXMLElement)#%d (1) { + ["test"]=> + object(SimpleXMLElement)#%d (0) { + } + } + } + } +} +===Array=== +object(SimpleXMLElement)#%d (1) { + [0]=> + string(5) "elem1" +} +object(SimpleXMLElement)#%d (1) { + [0]=> + string(5) "first" +} +===Set=== +object(SimpleXMLElement)#%d (1) { + [0]=> + string(8) "Changed1" +} +object(SimpleXMLElement)#%d (1) { + [0]=> + string(2) "12" +} +===Unset=== +NULL +NULL +===Misc.=== +int(4) +int(4) +===Done=== |