diff options
Diffstat (limited to 'ext/simplexml/tests')
28 files changed, 819 insertions, 199 deletions
diff --git a/ext/simplexml/tests/000.phpt b/ext/simplexml/tests/000.phpt new file mode 100755 index 000000000..51dbe3b5e --- /dev/null +++ b/ext/simplexml/tests/000.phpt @@ -0,0 +1,254 @@ +--TEST-- +SimpleXML: var_dump() +--SKIPIF-- +<?php if (!extension_loaded("simplexml")) print "skip"; ?> +--FILE-- +<?php + +$sxe = simplexml_load_file(dirname(__FILE__).'/000.xml'); + +function test($what) +{ + global $sxe; + echo "===$what\n"; + eval("var_dump(isset(\$$what));"); + eval("var_dump((bool)\$$what);"); + eval("var_dump(count(\$$what));"); + eval("var_dump(\$$what);"); +} + +test('sxe'); +test('sxe->elem1'); +test('sxe->elem1[0]'); +test('sxe->elem1[0]->elem2'); +test('sxe->elem1[0]->elem2->bla'); +if (!ini_get("unicode_semantics")) test('sxe->elem1[0]["attr1"]'); +test('sxe->elem1[0]->attr1'); +test('sxe->elem1[1]'); +test('sxe->elem1[2]'); +test('sxe->elem11'); +test('sxe->elem11->elem111'); +test('sxe->elem11->elem111->elem1111'); +test('sxe->elem22'); +test('sxe->elem22->elem222'); +test('sxe->elem22->attr22'); +test('sxe->elem22["attr22"]'); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +===sxe +bool(true) +bool(true) +int(3) +object(SimpleXMLElement)#%d (3) { + ["@attributes"]=> + array(1) { + ["id"]=> + string(3) "123" + } + ["elem1"]=> + array(2) { + [0]=> + string(36) "There is some text.Here is some more" + [1]=> + object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(2) { + ["attr1"]=> + string(2) "11" + ["attr2"]=> + string(2) "12" + } + } + } + ["elem11"]=> + object(SimpleXMLElement)#%d (1) { + ["elem111"]=> + object(SimpleXMLElement)#%d (1) { + ["elem1111"]=> + object(SimpleXMLElement)#%d (0) { + } + } + } +} +===sxe->elem1 +bool(true) +bool(true) +int(2) +object(SimpleXMLElement)#%d (3) { + ["@attributes"]=> + array(2) { + ["attr1"]=> + string(5) "first" + ["attr2"]=> + string(6) "second" + } + ["comment"]=> + object(SimpleXMLElement)#%d (0) { + } + ["elem2"]=> + object(SimpleXMLElement)#%d (2) { + ["@attributes"]=> + array(2) { + ["att25"]=> + string(2) "25" + ["att42"]=> + string(2) "42" + } + ["elem3"]=> + object(SimpleXMLElement)#%d (1) { + ["elem4"]=> + object(SimpleXMLElement)#%d (1) { + ["test"]=> + object(SimpleXMLElement)#%d (0) { + } + } + } + } +} +===sxe->elem1[0] +bool(true) +bool(true) +int(1) +object(SimpleXMLElement)#%d (3) { + ["@attributes"]=> + array(2) { + ["attr1"]=> + string(5) "first" + ["attr2"]=> + string(6) "second" + } + ["comment"]=> + object(SimpleXMLElement)#%d (0) { + } + ["elem2"]=> + object(SimpleXMLElement)#%d (2) { + ["@attributes"]=> + array(2) { + ["att25"]=> + string(2) "25" + ["att42"]=> + string(2) "42" + } + ["elem3"]=> + object(SimpleXMLElement)#%d (1) { + ["elem4"]=> + object(SimpleXMLElement)#%d (1) { + ["test"]=> + object(SimpleXMLElement)#%d (0) { + } + } + } + } +} +===sxe->elem1[0]->elem2 +bool(true) +bool(true) +int(1) +object(SimpleXMLElement)#%d (2) { + ["@attributes"]=> + array(2) { + ["att25"]=> + string(2) "25" + ["att42"]=> + string(2) "42" + } + ["elem3"]=> + object(SimpleXMLElement)#%d (1) { + ["elem4"]=> + object(SimpleXMLElement)#%d (1) { + ["test"]=> + object(SimpleXMLElement)#%d (0) { + } + } + } +} +===sxe->elem1[0]->elem2->bla +bool(false) +bool(false) +int(0) +object(SimpleXMLElement)#%d (0) { +} +===sxe->elem1[0]["attr1"] +bool(true) +bool(true) +int(0) +object(SimpleXMLElement)#%d (1) { + [0]=> + string(5) "first" +} +===sxe->elem1[0]->attr1 +bool(false) +bool(false) +int(0) +object(SimpleXMLElement)#%d (0) { +} +===sxe->elem1[1] +bool(true) +bool(true) +int(0) +object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(2) { + ["attr1"]=> + string(2) "11" + ["attr2"]=> + string(2) "12" + } +} +===sxe->elem1[2] +bool(false) +bool(false) +int(0) +NULL +===sxe->elem11 +bool(true) +bool(true) +int(1) +object(SimpleXMLElement)#%d (1) { + ["elem111"]=> + object(SimpleXMLElement)#%d (1) { + ["elem1111"]=> + object(SimpleXMLElement)#%d (0) { + } + } +} +===sxe->elem11->elem111 +bool(true) +bool(true) +int(1) +object(SimpleXMLElement)#%d (1) { + ["elem1111"]=> + object(SimpleXMLElement)#%d (0) { + } +} +===sxe->elem11->elem111->elem1111 +bool(true) +bool(true) +int(1) +object(SimpleXMLElement)#%d (0) { +} +===sxe->elem22 +bool(false) +bool(false) +int(0) +object(SimpleXMLElement)#%d (0) { +} +===sxe->elem22->elem222 +bool(false) +bool(false) +int(0) +NULL +===sxe->elem22->attr22 +bool(false) +bool(false) +int(0) +NULL +===sxe->elem22["attr22"] +bool(false) +bool(false) +int(0) +NULL +===DONE=== diff --git a/ext/simplexml/tests/000.xml b/ext/simplexml/tests/000.xml new file mode 100755 index 000000000..b0f278546 --- /dev/null +++ b/ext/simplexml/tests/000.xml @@ -0,0 +1,16 @@ +<?xml version='1.0'?> +<!DOCTYPE sxe SYSTEM "sxe.dtd" [ +<!ENTITY % incent SYSTEM "sxe.ent"> +%incent; +]> +<sxe id="123"> + <elem1 attr1='first' attr2='second'>There is some text.<!-- comment --><elem2 att25='25' att42='42'> + <elem3> + <elem4> + <?test processing instruction ?> + </elem4> + </elem3> + </elem2>Here is some more</elem1> + <elem1 attr1='11' attr2='12'/> + <elem11><elem111><elem1111/></elem111></elem11> +</sxe>
\ No newline at end of file diff --git a/ext/simplexml/tests/001.phpt b/ext/simplexml/tests/001.phpt index cacc2d306..0be77710e 100644 --- a/ext/simplexml/tests/001.phpt +++ b/ext/simplexml/tests/001.phpt @@ -5,39 +5,39 @@ SimpleXML: Simple document --FILE-- <?php -$sxe = simplexml_load_file(dirname(__FILE__).'/sxe.xml'); - -print_r($sxe); - -echo "---Done---\n"; +var_dump(simplexml_load_file(dirname(__FILE__).'/sxe.xml')); ?> ---EXPECT-- -SimpleXMLElement Object -( - [elem1] => SimpleXMLElement Object - ( - [comment] => SimpleXMLElement Object - ( - ) - - [elem2] => SimpleXMLElement Object - ( - [elem3] => SimpleXMLElement Object - ( - [elem4] => SimpleXMLElement Object - ( - [test] => SimpleXMLElement Object - ( - ) - - ) - - ) - - ) - - ) - -) ----Done--- +===DONE=== +--EXPECTF-- +object(SimpleXMLElement)#%d (2) { + ["@attributes"]=> + array(1) { + ["id"]=> + string(5) "elem1" + } + ["elem1"]=> + 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) { + } + } + } + } + } +} +===DONE=== diff --git a/ext/simplexml/tests/002.phpt b/ext/simplexml/tests/002.phpt index 95d644fe7..4f1f6b622 100644 --- a/ext/simplexml/tests/002.phpt +++ b/ext/simplexml/tests/002.phpt @@ -1,5 +1,5 @@ --TEST-- -SimpleXML and clone +SimpleXML: clone --SKIPIF-- <?php if (!extension_loaded("simplexml")) print "skip"; ?> --FILE-- @@ -26,37 +26,39 @@ $sxe = simplexml_load_string($xml); $copy = clone $sxe; -print_r($copy); - -echo "---Done---\n"; +var_dump($copy); ?> ---EXPECT-- -SimpleXMLElement Object -( - [elem1] => SimpleXMLElement Object - ( - [comment] => SimpleXMLElement Object - ( - ) - - [elem2] => SimpleXMLElement Object - ( - [elem3] => SimpleXMLElement Object - ( - [elem4] => SimpleXMLElement Object - ( - [test] => SimpleXMLElement Object - ( - ) - - ) - - ) - - ) - - ) - -) ----Done--- +===DONE=== +--EXPECTF-- +object(SimpleXMLElement)#%d (2) { + ["@attributes"]=> + array(1) { + ["id"]=> + string(5) "elem1" + } + ["elem1"]=> + 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) { + } + } + } + } + } +} +===DONE=== diff --git a/ext/simplexml/tests/003.phpt b/ext/simplexml/tests/003.phpt index 96aad372d..105f616d6 100755 --- a/ext/simplexml/tests/003.phpt +++ b/ext/simplexml/tests/003.phpt @@ -1,5 +1,5 @@ --TEST-- -SimpleXML and Entities +SimpleXML: Entities --SKIPIF-- <?php if (!extension_loaded("simplexml")) print "skip"; ?> --FILE-- @@ -26,44 +26,44 @@ $xml =<<<EOF </sxe> EOF; -$sxe = simplexml_load_string($xml); - -print_r($sxe); - -echo "---Done---\n"; +var_dump(simplexml_load_string($xml)); ?> ---EXPECT-- -SimpleXMLElement Object -( - [elem1] => SimpleXMLElement Object - ( - [comment] => SimpleXMLElement Object - ( - ) - - [elem2] => SimpleXMLElement Object - ( - [elem3] => SimpleXMLElement Object - ( - [included-entity] => SimpleXMLElement Object - ( - [included-entity] => This is text included from an entity - ) - - [elem4] => SimpleXMLElement Object - ( - [test] => SimpleXMLElement Object - ( - ) - - ) - - ) - - ) - - ) - -) ----Done--- +===DONE=== +--EXPECTF-- +object(SimpleXMLElement)#%d (2) { + ["@attributes"]=> + array(1) { + ["id"]=> + string(5) "elem1" + } + ["elem1"]=> + 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 (2) { + ["included-entity"]=> + object(SimpleXMLElement)#%d (1) { + ["included-entity"]=> + string(36) "This is text included from an entity" + } + ["elem4"]=> + object(SimpleXMLElement)#%d (1) { + ["test"]=> + object(SimpleXMLElement)#%d (0) { + } + } + } + } + } +} +===DONE=== diff --git a/ext/simplexml/tests/004.phpt b/ext/simplexml/tests/004.phpt index 392b1d498..21cb5469e 100755 --- a/ext/simplexml/tests/004.phpt +++ b/ext/simplexml/tests/004.phpt @@ -1,5 +1,5 @@ --TEST-- -SimpleXML and CDATA +SimpleXML: CDATA --SKIPIF-- <?php if (!extension_loaded("simplexml")) print "skip"; ?> --FILE-- @@ -25,7 +25,7 @@ $sxe = simplexml_load_string(<<<EOF EOF ); -print_r($sxe); +var_dump($sxe); $elem1 = $sxe->elem1; $elem2 = $elem1->elem2; @@ -33,33 +33,36 @@ var_dump(trim((string)$elem2)); ?> ===DONE=== ---EXPECT-- -SimpleXMLElement Object -( - [elem1] => SimpleXMLElement Object - ( - [comment] => SimpleXMLElement Object - ( - ) - - [elem2] => SimpleXMLElement Object - ( - [elem3] => SimpleXMLElement Object - ( - [elem4] => SimpleXMLElement Object - ( - [test] => SimpleXMLElement Object - ( - ) - - ) - - ) - - ) - - ) - -) +--EXPECTF-- +object(SimpleXMLElement)#%d (2) { + ["@attributes"]=> + array(1) { + ["id"]=> + string(5) "elem1" + } + ["elem1"]=> + 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) { + } + } + } + } + } +} string(11) "CDATA block" ===DONE=== diff --git a/ext/simplexml/tests/005.phpt b/ext/simplexml/tests/005.phpt index 237a5d261..141106543 100755 --- a/ext/simplexml/tests/005.phpt +++ b/ext/simplexml/tests/005.phpt @@ -1,5 +1,5 @@ --TEST-- -SimpleXML and text data +SimpleXML: Text data --SKIPIF-- <?php if (!extension_loaded("simplexml")) print "skip"; ?> --FILE-- diff --git a/ext/simplexml/tests/006.phpt b/ext/simplexml/tests/006.phpt index 9360b2dff..72ad0c808 100755 --- a/ext/simplexml/tests/006.phpt +++ b/ext/simplexml/tests/006.phpt @@ -1,5 +1,5 @@ --TEST-- -SimpleXML and foreach +SimpleXML: foreach --SKIPIF-- <?php if (!extension_loaded("simplexml")) print "skip"; ?> --FILE-- diff --git a/ext/simplexml/tests/007.phpt b/ext/simplexml/tests/007.phpt index b55d32496..51d7a847f 100755 --- a/ext/simplexml/tests/007.phpt +++ b/ext/simplexml/tests/007.phpt @@ -1,5 +1,5 @@ --TEST-- -SimpleXML and attributes +SimpleXML: Attributes --SKIPIF-- <?php if (!extension_loaded("simplexml")) print "skip"; ?> --FILE-- @@ -48,7 +48,12 @@ var_dump($a); ===Done=== --EXPECTF-- ===Property=== -object(SimpleXMLElement)#%d (2) { +object(SimpleXMLElement)#%d (3) { + ["@attributes"]=> + array(1) { + ["attr1"]=> + string(5) "first" + } ["comment"]=> object(SimpleXMLElement)#%d (0) { } diff --git a/ext/simplexml/tests/008.phpt b/ext/simplexml/tests/008.phpt index 3554b3204..4fda204a2 100644 --- a/ext/simplexml/tests/008.phpt +++ b/ext/simplexml/tests/008.phpt @@ -1,5 +1,5 @@ --TEST-- -SimpleXML and XPath +SimpleXML: XPath --SKIPIF-- <?php if (!extension_loaded("simplexml")) print "skip"; ?> --FILE-- diff --git a/ext/simplexml/tests/009.phpt b/ext/simplexml/tests/009.phpt index 2115dd314..a76f3d111 100755 --- a/ext/simplexml/tests/009.phpt +++ b/ext/simplexml/tests/009.phpt @@ -1,5 +1,5 @@ --TEST-- -SimpleXML and foreach +SimpleXML: foreach --SKIPIF-- <?php if (!extension_loaded("simplexml")) print "skip"; ?> --FILE-- @@ -31,7 +31,7 @@ EOF foreach($sxe->children() as $name=>$val) { var_dump($name); var_dump(get_class($val)); - var_dump(trim((string)$val)); + var_dump(trim($val)); } ?> ===DONE=== diff --git a/ext/simplexml/tests/010.phpt b/ext/simplexml/tests/010.phpt index ea6c7fd07..267780905 100644 --- a/ext/simplexml/tests/010.phpt +++ b/ext/simplexml/tests/010.phpt @@ -26,38 +26,39 @@ $xml =<<<EOF </sxe> EOF; -$sxe = simplexml_load_string($xml, 'simplexml_inherited'); - -print_r($sxe); +var_dump(simplexml_load_string($xml, 'simplexml_inherited')); ?> ===DONE=== ---EXPECT-- -simplexml_inherited Object -( - [elem1] => simplexml_inherited Object - ( - [comment] => simplexml_inherited Object - ( - ) - - [elem2] => simplexml_inherited Object - ( - [elem3] => simplexml_inherited Object - ( - [elem4] => simplexml_inherited Object - ( - [test] => simplexml_inherited Object - ( - ) - - ) - - ) - - ) - - ) - -) +--EXPECTF-- +object(simplexml_inherited)#%d (2) { + ["@attributes"]=> + array(1) { + ["id"]=> + string(5) "elem1" + } + ["elem1"]=> + object(simplexml_inherited)#%d (3) { + ["@attributes"]=> + array(1) { + ["attr1"]=> + string(5) "first" + } + ["comment"]=> + object(simplexml_inherited)#%d (0) { + } + ["elem2"]=> + object(simplexml_inherited)#%d (1) { + ["elem3"]=> + object(simplexml_inherited)#%d (1) { + ["elem4"]=> + object(simplexml_inherited)#%d (1) { + ["test"]=> + object(simplexml_inherited)#%d (0) { + } + } + } + } + } +} ===DONE=== diff --git a/ext/simplexml/tests/011.phpt b/ext/simplexml/tests/011.phpt index f48c9f1ee..74ea4705c 100755 --- a/ext/simplexml/tests/011.phpt +++ b/ext/simplexml/tests/011.phpt @@ -1,5 +1,5 @@ --TEST-- -SimpleXML and echo/print +SimpleXML: echo/print --SKIPIF-- <?php if (!extension_loaded('simplexml')) print 'skip'; diff --git a/ext/simplexml/tests/012.phpt b/ext/simplexml/tests/012.phpt index 79c01107f..2fc9bec41 100755 --- a/ext/simplexml/tests/012.phpt +++ b/ext/simplexml/tests/012.phpt @@ -1,5 +1,5 @@ --TEST-- -SimpleXML and Attribute creation +SimpleXML: Attribute creation --SKIPIF-- <?php if (!extension_loaded('simplexml')) print 'skip'; @@ -26,6 +26,7 @@ echo $sxe->asXML(); $sxe[] = "error"; +__HALT_COMPILER(); ?> ===DONE=== --EXPECTF-- diff --git a/ext/simplexml/tests/013.phpt b/ext/simplexml/tests/013.phpt index fbd80b0c4..56c57dfbc 100755 --- a/ext/simplexml/tests/013.phpt +++ b/ext/simplexml/tests/013.phpt @@ -1,5 +1,5 @@ --TEST-- -SimpleXML and Split text content +SimpleXML: Split text content --SKIPIF-- <?php if (!extension_loaded('simplexml')) print 'skip'; diff --git a/ext/simplexml/tests/014a.phpt b/ext/simplexml/tests/014a.phpt index 770cb4481..649828b4d 100755 --- a/ext/simplexml/tests/014a.phpt +++ b/ext/simplexml/tests/014a.phpt @@ -53,4 +53,4 @@ object(SimpleXMLElement)#%d (1) { [0]=> string(1) "5" } -===DONE===
\ No newline at end of file +===DONE=== diff --git a/ext/simplexml/tests/014b.phpt b/ext/simplexml/tests/014b.phpt index 14bd6ce86..034396751 100755 --- a/ext/simplexml/tests/014b.phpt +++ b/ext/simplexml/tests/014b.phpt @@ -52,4 +52,4 @@ object(SimpleXMLElement)#%d (1) { [0]=> string(1) "5" } -===DONE===
\ No newline at end of file +===DONE=== diff --git a/ext/simplexml/tests/019.phpt b/ext/simplexml/tests/019.phpt index a54a1bdd5..aec74ba42 100755 --- a/ext/simplexml/tests/019.phpt +++ b/ext/simplexml/tests/019.phpt @@ -1,5 +1,5 @@ --TEST-- -SimpleXML and foreach with children() +SimpleXML: foreach with children() --SKIPIF-- <?php if (!extension_loaded("simplexml")) print "skip"; ?> --FILE-- diff --git a/ext/simplexml/tests/020.phpt b/ext/simplexml/tests/020.phpt index 9433f81dc..b43d0340b 100755 --- a/ext/simplexml/tests/020.phpt +++ b/ext/simplexml/tests/020.phpt @@ -1,5 +1,5 @@ --TEST--
-SimpleXML attribute compared to string
+SimpleXML: Attribute compared to string
--SKIPIF-- <?php if (!extension_loaded("simplexml")) print "skip"; ?>
--FILE--
diff --git a/ext/simplexml/tests/021.phpt b/ext/simplexml/tests/021.phpt index e58e26d6e..d5138685f 100644 --- a/ext/simplexml/tests/021.phpt +++ b/ext/simplexml/tests/021.phpt @@ -1,5 +1,5 @@ --TEST-- -SimpleXML element check +SimpleXML: Element check --SKIPIF-- <?php if (!extension_loaded("simplexml")) print "skip"; ?> --FILE-- diff --git a/ext/simplexml/tests/022.phpt b/ext/simplexml/tests/022.phpt index 08cb908c9..2af4a1dd2 100755 --- a/ext/simplexml/tests/022.phpt +++ b/ext/simplexml/tests/022.phpt @@ -1,5 +1,5 @@ --TEST-- -SimpleXML and attributes inside foreach +SimpleXML: Attributes inside foreach --SKIPIF-- <?php if (!extension_loaded("simplexml")) print "skip"; ?> --FILE-- @@ -12,6 +12,13 @@ EOF; $sxe = simplexml_load_string($xml); +echo "===CONTENT===\n"; +var_dump($sxe->content); + +echo "===FILE===\n"; +var_dump($sxe->content->file); + +echo "===FOREACH===\n"; foreach($sxe->content->file as $file) { var_dump($file); @@ -21,7 +28,32 @@ foreach($sxe->content->file as $file) ?> ===DONE=== --EXPECTF-- -object(SimpleXMLElement)#%d (0) { +===CONTENT=== +object(SimpleXMLElement)#%d (1) { + ["file"]=> + object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(1) { + ["glob"]=> + string(11) "slide_*.xml" + } + } +} +===FILE=== +object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(1) { + ["glob"]=> + string(11) "slide_*.xml" + } +} +===FOREACH=== +object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(1) { + ["glob"]=> + string(11) "slide_*.xml" + } } object(SimpleXMLElement)#%d (1) { [0]=> diff --git a/ext/simplexml/tests/023.phpt b/ext/simplexml/tests/023.phpt index dd6dde59d..515a1460c 100755 --- a/ext/simplexml/tests/023.phpt +++ b/ext/simplexml/tests/023.phpt @@ -22,7 +22,12 @@ var_dump($sxe['attr']); ?> ===DONE=== --EXPECTF-- -object(SimpleXMLElement)#%d (0) { +object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(1) { + ["attr"]=> + string(%d) "foo%sbar%sbaz" + } } object(SimpleXMLElement)#%d (1) { [0]=> diff --git a/ext/simplexml/tests/024.phpt b/ext/simplexml/tests/024.phpt new file mode 100755 index 000000000..9f31fd5e9 --- /dev/null +++ b/ext/simplexml/tests/024.phpt @@ -0,0 +1,175 @@ +--TEST-- +SimpleXML: XPath and attributes +--SKIPIF-- +<?php if (!extension_loaded("simplexml")) print "skip"; ?> +--FILE-- +<?php + +$xml =<<<EOF +<?xml version='1.0'?> +<root> +<elem attr1='11' attr2='12' attr3='13'/> +<elem attr1='21' attr2='22' attr3='23'/> +<elem attr1='31' attr2='32' attr3='33'/> +</root> +EOF; + +$sxe = simplexml_load_string($xml); + +function test($xpath) +{ + global $sxe; + + echo "===$xpath===\n"; + var_dump($sxe->xpath($xpath)); +} + +test('elem/@attr2'); +test('//@attr2'); +test('//@*'); +test('elem[2]/@attr2'); + +?> +===DONE=== +--EXPECTF-- +===elem/@attr2=== +array(3) { + [0]=> + object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(1) { + ["attr2"]=> + string(2) "12" + } + } + [1]=> + object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(1) { + ["attr2"]=> + string(2) "22" + } + } + [2]=> + object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(1) { + ["attr2"]=> + string(2) "32" + } + } +} +===//@attr2=== +array(3) { + [0]=> + object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(1) { + ["attr2"]=> + string(2) "12" + } + } + [1]=> + object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(1) { + ["attr2"]=> + string(2) "22" + } + } + [2]=> + object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(1) { + ["attr2"]=> + string(2) "32" + } + } +} +===//@*=== +array(9) { + [0]=> + object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(1) { + ["attr1"]=> + string(2) "11" + } + } + [1]=> + object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(1) { + ["attr2"]=> + string(2) "12" + } + } + [2]=> + object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(1) { + ["attr3"]=> + string(2) "13" + } + } + [3]=> + object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(1) { + ["attr1"]=> + string(2) "21" + } + } + [4]=> + object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(1) { + ["attr2"]=> + string(2) "22" + } + } + [5]=> + object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(1) { + ["attr3"]=> + string(2) "23" + } + } + [6]=> + object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(1) { + ["attr1"]=> + string(2) "31" + } + } + [7]=> + object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(1) { + ["attr2"]=> + string(2) "32" + } + } + [8]=> + object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(1) { + ["attr3"]=> + string(2) "33" + } + } +} +===elem[2]/@attr2=== +array(1) { + [0]=> + object(SimpleXMLElement)#%d (1) { + ["@attributes"]=> + array(1) { + ["attr2"]=> + string(2) "22" + } + } +} +===DONE=== diff --git a/ext/simplexml/tests/025.phpt b/ext/simplexml/tests/025.phpt new file mode 100755 index 000000000..b9e3bbb0d --- /dev/null +++ b/ext/simplexml/tests/025.phpt @@ -0,0 +1,92 @@ +--TEST-- +SimpleXML: getting namespaces +--SKIPIF-- +<?php if (!extension_loaded("simplexml")) print "skip"; ?> +--FILE-- +<?php + +$xml =<<<EOF +<?xml version='1.0'?> +<xhtml:html xmlns:html='http://www.w3.org/1999/xhtml' xmlns:xhtml='http://www.w3.org/TR/REC-html40'> +<xhtml:head><xhtml:title xmlns:xhtml='http://www.w3.org/TR/REC-html401'>bla</xhtml:title></xhtml:head> +<xhtml:body html:title="b"> +<html:h1>bla</html:h1> +<foo:bar xmlns:foo='foobar' xmlns:baz='foobarbaz'/> +</xhtml:body> +</xhtml:html> +EOF; + +$sxe = simplexml_load_string($xml); + +var_dump($sxe->getNamespaces()); +var_dump($sxe->getNamespaces(true)); +var_dump($sxe->getDocNamespaces()); +var_dump($sxe->getDocNamespaces(true)); + +$xml =<<<EOF +<?xml version='1.0'?> +<html xmlns='http://www.w3.org/1999/xhtml'> +<head><title xmlns='http://www.w3.org/TR/REC-html40'>bla</title></head> +</html> +EOF; + +$sxe = simplexml_load_string($xml); + +var_dump($sxe->getNamespaces()); +var_dump($sxe->getDocNamespaces()); + +$xml =<<<EOF +<?xml version='1.0'?> +<root/> +EOF; + +$sxe = simplexml_load_string($xml); + +var_dump($sxe->getNamespaces()); +var_dump($sxe->getDocNamespaces()); + +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +array(1) { + ["xhtml"]=> + string(31) "http://www.w3.org/TR/REC-html40" +} +array(3) { + ["xhtml"]=> + string(31) "http://www.w3.org/TR/REC-html40" + ["html"]=> + string(28) "http://www.w3.org/1999/xhtml" + ["foo"]=> + string(6) "foobar" +} +array(2) { + ["html"]=> + string(28) "http://www.w3.org/1999/xhtml" + ["xhtml"]=> + string(31) "http://www.w3.org/TR/REC-html40" +} +array(4) { + ["html"]=> + string(28) "http://www.w3.org/1999/xhtml" + ["xhtml"]=> + string(31) "http://www.w3.org/TR/REC-html40" + ["foo"]=> + string(6) "foobar" + ["baz"]=> + string(9) "foobarbaz" +} +array(1) { + [""]=> + string(28) "http://www.w3.org/1999/xhtml" +} +array(1) { + [""]=> + string(28) "http://www.w3.org/1999/xhtml" +} +array(0) { +} +array(0) { +} +===DONE=== diff --git a/ext/simplexml/tests/bug27010.phpt b/ext/simplexml/tests/bug27010.phpt index 9ba9f7b6b..364ca4675 100755 --- a/ext/simplexml/tests/bug27010.phpt +++ b/ext/simplexml/tests/bug27010.phpt @@ -1,5 +1,7 @@ --TEST-- -#27010: segfault and node text not displayed when returned from children() +Bug #27010 (segfault and node text not displayed when returned from children()) +--SKIPIF-- +<?php if (!extension_loaded("simplexml")) print "skip"; ?> --FILE-- <?php diff --git a/ext/simplexml/tests/bug35785.phpt b/ext/simplexml/tests/bug35785.phpt new file mode 100755 index 000000000..34489c5b1 --- /dev/null +++ b/ext/simplexml/tests/bug35785.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #35785 (SimpleXML memory read error) +--FILE-- +<?php + +$options["database"] = "xmldatabase"; +$xml = simplexml_load_string("<root></root>"); +$count = count($xml->posts) + 1; +$xml->bla->posts[$count]->name = $_POST["name"]; +echo $xml->asXML(); +?> +===DONE=== +<?php exit(0); __halt_compiler(); ?> +--EXPECTF-- + +Notice: Undefined index: name in %sbug35785.php on line %d + +Strict Standards: Creating default object from empty value in %sbug35785.php on line %d + +Warning: Attempt to assign property of non-object in %sbug35785.php on line %d +<?xml version="1.0"?> +<root/> +===DONE=== diff --git a/ext/simplexml/tests/profile11.phpt b/ext/simplexml/tests/profile11.phpt index e68e6bd51..54c31bf71 100644 --- a/ext/simplexml/tests/profile11.phpt +++ b/ext/simplexml/tests/profile11.phpt @@ -12,15 +12,24 @@ $root = simplexml_load_string('<?xml version="1.0"?> </root> '); -echo $root->children('reserved-ns')->child; -echo "\n"; -echo $root->children('special-ns')->child; -foreach ($root->child as $child) { - echo "$child\n"; -} -echo "\n---Done---\n"; +var_dump($root->children('reserved-ns')->child); +var_dump($root->children('special-ns')->child); +var_dump((string)$root->children('reserved-ns')->child); +var_dump((string)$root->children('special-ns')->child); +var_dump($root->child); ?> ---EXPECT-- -Hello -World ----Done--- +===DONE=== +--EXPECTF-- +object(SimpleXMLElement)#%d (1) { + [0]=> + string(5) "Hello" +} +object(SimpleXMLElement)#%d (1) { + [0]=> + string(5) "World" +} +string(5) "Hello" +string(5) "World" +object(SimpleXMLElement)#%d (0) { +} +===DONE=== diff --git a/ext/simplexml/tests/simplexml_import_dom.phpt b/ext/simplexml/tests/simplexml_import_dom.phpt index c66ba8f08..76e7f041d 100755 --- a/ext/simplexml/tests/simplexml_import_dom.phpt +++ b/ext/simplexml/tests/simplexml_import_dom.phpt @@ -1,5 +1,5 @@ --TEST-- -Interop: simplexml_import_dom +SimpleXML [interop]: simplexml_import_dom --SKIPIF-- <?php if (!extension_loaded("simplexml")) print "skip"; ?> <?php if (!extension_loaded("dom")) print "skip. dom extension not loaded"; ?> |
