summaryrefslogtreecommitdiff
path: root/ext/simplexml/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ext/simplexml/tests')
-rwxr-xr-xext/simplexml/tests/006.phpt10
-rwxr-xr-xext/simplexml/tests/007.phpt20
-rw-r--r--ext/simplexml/tests/008.phpt4
-rwxr-xr-xext/simplexml/tests/011.phpt2
-rwxr-xr-xext/simplexml/tests/012.phpt4
-rw-r--r--ext/simplexml/tests/014.phpt35
-rwxr-xr-xext/simplexml/tests/014a.phpt34
-rwxr-xr-xext/simplexml/tests/014b.phpt33
-rw-r--r--ext/simplexml/tests/015.phpt24
-rw-r--r--ext/simplexml/tests/016.phpt34
-rw-r--r--ext/simplexml/tests/017.phpt36
-rw-r--r--ext/simplexml/tests/018.phpt2
-rwxr-xr-xext/simplexml/tests/019.phpt80
-rw-r--r--ext/simplexml/tests/bug25756.phpt70
14 files changed, 248 insertions, 140 deletions
diff --git a/ext/simplexml/tests/006.phpt b/ext/simplexml/tests/006.phpt
index 01ee3f45dd..9e81f20dd9 100755
--- a/ext/simplexml/tests/006.phpt
+++ b/ext/simplexml/tests/006.phpt
@@ -72,11 +72,9 @@ string(10) "Bla bla 1."
string(6) "elem11"
string(10) "Bla bla 2."
===ELEMENT===
-string(7) "elem111"
-string(7) "Foo Bar"
+string(6) "elem11"
+string(10) "Bla bla 2."
===COMMENT===
-string(7) "comment"
-string(0) ""
-string(5) "elem2"
-string(28) "Here we have some text data."
+string(5) "elem1"
+string(10) "Bla bla 1."
===DONE===
diff --git a/ext/simplexml/tests/007.phpt b/ext/simplexml/tests/007.phpt
index f37d5c2316..c7f3fc1849 100755
--- a/ext/simplexml/tests/007.phpt
+++ b/ext/simplexml/tests/007.phpt
@@ -49,11 +49,23 @@ object(simplexml_element)#%d (2) {
}
}
===Array===
-string(5) "elem1"
-string(5) "first"
+object(simplexml_element)#2 (1) {
+ [0]=>
+ string(5) "elem1"
+}
+object(simplexml_element)#6 (1) {
+ [0]=>
+ string(5) "first"
+}
===Set===
-string(8) "Changed1"
-string(2) "12"
+object(simplexml_element)#6 (1) {
+ [0]=>
+ string(8) "Changed1"
+}
+object(simplexml_element)#5 (1) {
+ [0]=>
+ string(2) "12"
+}
===Unset===
NULL
NULL
diff --git a/ext/simplexml/tests/008.phpt b/ext/simplexml/tests/008.phpt
index 14912a6673..1726726a1a 100644
--- a/ext/simplexml/tests/008.phpt
+++ b/ext/simplexml/tests/008.phpt
@@ -5,8 +5,8 @@ SimpleXML and XPath
--FILE--
<?php
$sxe = simplexml_load_file(dirname(__FILE__).'/sxe.xml');
-var_dump($sxe->xsearch("elem1/elem2/elem3/elem4"));
-var_dump($sxe->xsearch("***"));
+var_dump($sxe->xpath("elem1/elem2/elem3/elem4"));
+var_dump($sxe->xpath("***"));
?>
--EXPECTF--
array(1) {
diff --git a/ext/simplexml/tests/011.phpt b/ext/simplexml/tests/011.phpt
index 9b6bf15417..f48c9f1eec 100755
--- a/ext/simplexml/tests/011.phpt
+++ b/ext/simplexml/tests/011.phpt
@@ -39,7 +39,7 @@ echo "\n";
===BAR===
bar
===BAZ===
-Array
+baz1
===BAZ0===
baz1
===BAZ1===
diff --git a/ext/simplexml/tests/012.phpt b/ext/simplexml/tests/012.phpt
index cd8d85e9ec..79c01107fe 100755
--- a/ext/simplexml/tests/012.phpt
+++ b/ext/simplexml/tests/012.phpt
@@ -18,11 +18,11 @@ $sxe = simplexml_load_string($xml);
$sxe[""] = "warning";
$sxe["attr"] = "value";
-echo $sxe->to_xml_string();
+echo $sxe->asXML();
$sxe["attr"] = "new value";
-echo $sxe->to_xml_string();
+echo $sxe->asXML();
$sxe[] = "error";
diff --git a/ext/simplexml/tests/014.phpt b/ext/simplexml/tests/014.phpt
index 13fe42b96c..4c559d8a15 100644
--- a/ext/simplexml/tests/014.phpt
+++ b/ext/simplexml/tests/014.phpt
@@ -18,23 +18,40 @@ $person['name'] = "XXX";
var_dump($people->person['name']);
$people->person['age'] = 30;
var_dump($people->person['age']);
-$people->person['age'] += 5;
-var_dump($people->person['age']);
echo "---Unset:---\n";
unset($people->person['age']);
echo "---Unset?---\n";
var_dump($people->person['age']);
var_dump(isset($people->person['age']));
-echo "---Done---\n";
+$people->person['age'] = 30;
+echo "---Unsupported---\n";
+var_dump($people->person['age']);
+$people->person['age'] += 5;
+var_dump($people->person['age']);
?>
---EXPECT--
-string(3) "Joe"
+===DONE===
+--EXPECTF--
+object(simplexml_element)#%d (1) {
+ [0]=>
+ string(3) "Joe"
+}
NULL
-string(3) "XXX"
-string(2) "30"
-string(2) "35"
+object(simplexml_element)#%d (1) {
+ [0]=>
+ string(3) "XXX"
+}
+object(simplexml_element)#%d (1) {
+ [0]=>
+ string(2) "30"
+}
---Unset:---
---Unset?---
NULL
bool(false)
----Done---
+---Unsupported---
+object(simplexml_element)#%d (1) {
+ [0]=>
+ string(2) "30"
+}
+
+Fatal error: Unsupported operand types in %s014.php on line %d
diff --git a/ext/simplexml/tests/014a.phpt b/ext/simplexml/tests/014a.phpt
index 895917f6ce..5f2e15a74f 100755
--- a/ext/simplexml/tests/014a.phpt
+++ b/ext/simplexml/tests/014a.phpt
@@ -18,23 +18,39 @@ $person['name'] = "XXX";
var_dump($people->person[0]['name']);
$people->person[0]['age'] = 30;
var_dump($people->person[0]['age']);
-$people->person[0]['age'] += 5;
-var_dump($people->person[0]['age']);
echo "---Unset:---\n";
unset($people->person[0]['age']);
echo "---Unset?---\n";
var_dump($people->person[0]['age']);
var_dump(isset($people->person[0]['age']));
-echo "---Done---\n";
+echo "---Unsupported---\n";
+var_dump($people->person[0]['age']);
+$people->person['age'] += 5;
+var_dump($people->person[0]['age']);
?>
---EXPECT--
-string(3) "Joe"
+===DONE===
+--EXPECTF--
+object(simplexml_element)#%d (1) {
+ [0]=>
+ string(3) "Joe"
+}
NULL
-string(3) "XXX"
-string(2) "30"
-string(2) "35"
+object(simplexml_element)#%d (1) {
+ [0]=>
+ string(3) "XXX"
+}
+object(simplexml_element)#%d (1) {
+ [0]=>
+ string(2) "30"
+}
---Unset:---
---Unset?---
NULL
bool(false)
----Done---
+---Unsupported---
+object(simplexml_element)#%d (1) {
+ [0]=>
+ string(2) "30"
+}
+
+Fatal error: Unsupported operand types in %s014.php on line %d
diff --git a/ext/simplexml/tests/014b.phpt b/ext/simplexml/tests/014b.phpt
index 63882d01e7..2452a1468c 100755
--- a/ext/simplexml/tests/014b.phpt
+++ b/ext/simplexml/tests/014b.phpt
@@ -19,23 +19,38 @@ $person['name'] = "XXX";
var_dump($people->person[1]['name']);
$people->person[1]['age'] = 30;
var_dump($people->person[1]['age']);
-$people->person[1]['age'] += 5;
-var_dump($people->person[1]['age']);
echo "---Unset:---\n";
unset($people->person[1]['age']);
echo "---Unset?---\n";
var_dump($people->person[1]['age']);
var_dump(isset($people->person[1]['age']));
-echo "---Done---\n";
+echo "---Unsupported---\n";
+$people->person[1]['age'] += 5;
+var_dump($people->person[1]['age']);
?>
---EXPECT--
-string(3) "Joe"
+===DONE===
+--EXPECTF--
+object(simplexml_element)#%d (1) {
+ [0]=>
+ string(3) "Joe"
+}
NULL
-string(3) "XXX"
-string(2) "30"
-string(2) "35"
+object(simplexml_element)#%d (1) {
+ [0]=>
+ string(3) "XXX"
+}
+object(simplexml_element)#%d (1) {
+ [0]=>
+ string(2) "30"
+}
---Unset:---
---Unset?---
NULL
bool(false)
----Done---
+---Unsupported---
+object(simplexml_element)#%d (1) {
+ [0]=>
+ string(2) "30"
+}
+
+Fatal error: Unsupported operand types in %s014.php on line %d
diff --git a/ext/simplexml/tests/015.phpt b/ext/simplexml/tests/015.phpt
index 240c8f5b6b..b134354d79 100644
--- a/ext/simplexml/tests/015.phpt
+++ b/ext/simplexml/tests/015.phpt
@@ -34,11 +34,23 @@ var_dump($people->person[0]['name']);
$people = simplexml_load_string($xml2);
var_dump($people->person[0]['name']);
var_dump($people->person[1]['name']);
-echo "---Done---\n";
?>
+===DONE===
--EXPECT--
-string(3) "Joe"
-string(3) "Joe"
-string(3) "Joe"
-string(3) "Boe"
----Done---
+object(simplexml_element)#4 (1) {
+ [0]=>
+ string(3) "Joe"
+}
+object(simplexml_element)#3 (1) {
+ [0]=>
+ string(3) "Joe"
+}
+object(simplexml_element)#2 (1) {
+ [0]=>
+ string(3) "Joe"
+}
+object(simplexml_element)#2 (1) {
+ [0]=>
+ string(3) "Boe"
+}
+===DONE===
diff --git a/ext/simplexml/tests/016.phpt b/ext/simplexml/tests/016.phpt
index 9f88631222..ce197d4a63 100644
--- a/ext/simplexml/tests/016.phpt
+++ b/ext/simplexml/tests/016.phpt
@@ -26,14 +26,32 @@ var_dump($people->person[0]['name']);
$people->person[0]['name'] .= 'Bar';
var_dump($people->person[0]['name']);
-echo "---Done---\n";
?>
+===DONE===
--EXPECT--
-string(3) "Joe"
-string(6) "JoeFoo"
-string(9) "JoeFooBar"
+object(simplexml_element)#4 (1) {
+ [0]=>
+ string(3) "Joe"
+}
+object(simplexml_element)#2 (1) {
+ [0]=>
+ string(6) "JoeFoo"
+}
+object(simplexml_element)#5 (1) {
+ [0]=>
+ string(9) "JoeFooBar"
+}
---[0]---
-string(3) "Joe"
-string(6) "JoeFoo"
-string(9) "JoeFooBar"
----Done---
+object(simplexml_element)#3 (1) {
+ [0]=>
+ string(3) "Joe"
+}
+object(simplexml_element)#2 (1) {
+ [0]=>
+ string(6) "JoeFoo"
+}
+object(simplexml_element)#5 (1) {
+ [0]=>
+ string(9) "JoeFooBar"
+}
+===Done===
diff --git a/ext/simplexml/tests/017.phpt b/ext/simplexml/tests/017.phpt
index 355ac5f599..776b00c785 100644
--- a/ext/simplexml/tests/017.phpt
+++ b/ext/simplexml/tests/017.phpt
@@ -25,52 +25,62 @@ $xml1 =<<<EOF
EOF;
function print_xml($xml) {
- foreach($xml as $person) {
+ foreach($xml->children() as $person) {
echo "person: ".$person['name']."\n";
- foreach($person as $child) {
+ foreach($person->children() as $child) {
echo " child: ".$child['name']."\n";
}
}
- echo "----------\n";
}
function print_xml2($xml) {
- $persons = count($xml->person);
+ $persons = 2;
for ($i=0;$i<$persons;$i++) {
echo "person: ".$xml->person[$i]['name']."\n";
- $children = count($xml->person[$i]->child);
+ $children = 2;
for ($j=0;$j<$children;$j++) {
echo " child: ".$xml->person[$i]->child[$j]['name']."\n";
}
}
- echo "----------\n";
}
+echo "---11---\n";
print_xml(simplexml_load_string($xml));
+echo "---12---\n";
print_xml(simplexml_load_string($xml1));
+echo "---21---\n";
print_xml2(simplexml_load_string($xml));
+echo "---22---\n";
print_xml2(simplexml_load_string($xml1));
-echo "---Done---\n";
?>
---EXPECT--
+===DONE===
+--EXPECTF--
+---11---
person: Joe
child: Ann
child: Marray
person: Boe
child: Joe
child: Ann
-----------
+---12---
person: Joe
child: Ann
-----------
+---21---
person: Joe
child: Ann
child: Marray
person: Boe
child: Joe
child: Ann
-----------
+---22---
person: Joe
child: Ann
-----------
----Done---
+ child:
+person:
+
+Notice: Trying to get property of non-object in %s017.php on line %d
+ child:
+
+Notice: Trying to get property of non-object in %s017.php on line %d
+ child:
+===DONE===
diff --git a/ext/simplexml/tests/018.phpt b/ext/simplexml/tests/018.phpt
index cc7153b7ce..e5c810944e 100644
--- a/ext/simplexml/tests/018.phpt
+++ b/ext/simplexml/tests/018.phpt
@@ -28,7 +28,7 @@ $xml1 =<<<EOF
EOF;
function traverse_xml($pad,$xml) {
- foreach($xml as $name => $node) {
+ foreach($xml->children() as $name => $node) {
echo $pad."<$name";
foreach($node->attributes() as $attr => $value) {
echo " $attr=\"$value\"";
diff --git a/ext/simplexml/tests/019.phpt b/ext/simplexml/tests/019.phpt
new file mode 100755
index 0000000000..09f0569d7a
--- /dev/null
+++ b/ext/simplexml/tests/019.phpt
@@ -0,0 +1,80 @@
+--TEST--
+SimpleXML and foreach with children()
+--SKIPIF--
+<?php if (!extension_loaded("simplexml")) print "skip"; ?>
+--FILE--
+<?php
+
+$sxe = simplexml_load_string(<<<EOF
+<?xml version='1.0'?>
+<!DOCTYPE sxe SYSTEM "notfound.dtd">
+<sxe id="elem1">
+ Plain text.
+ <elem1 attr1='first'>
+ Bla bla 1.
+ <!-- comment -->
+ <elem2>
+ Here we have some text data.
+ <elem3>
+ And here some more.
+ <elem4>
+ Wow once again.
+ </elem4>
+ </elem3>
+ </elem2>
+ </elem1>
+ <elem11 attr2='second'>
+ Bla bla 2.
+ <elem111>
+ Foo Bar
+ </elem111>
+ </elem11>
+</sxe>
+EOF
+);
+
+foreach($sxe->children() as $name => $data) {
+ var_dump($name);
+ var_dump(trim($data));
+}
+
+echo "===CLONE===\n";
+
+foreach($sxe->children()->__clone() as $name => $data) {
+ var_dump($name);
+ var_dump(trim($data));
+}
+
+echo "===ELEMENT===\n";
+
+foreach($sxe->elem11->children() as $name => $data) {
+ var_dump($name);
+ var_dump(trim($data));
+}
+
+echo "===COMMENT===\n";
+
+foreach($sxe->elem1->children() as $name => $data) {
+ var_dump($name);
+ var_dump(trim($data));
+}
+
+?>
+===DONE===
+--EXPECT--
+string(5) "elem1"
+string(10) "Bla bla 1."
+string(6) "elem11"
+string(10) "Bla bla 2."
+===CLONE===
+string(5) "elem1"
+string(10) "Bla bla 1."
+string(6) "elem11"
+string(10) "Bla bla 2."
+===ELEMENT===
+string(7) "elem111"
+string(7) "Foo Bar"
+===COMMENT===
+string(5) "elem2"
+string(28) "Here we have some text data."
+===DONE===
diff --git a/ext/simplexml/tests/bug25756.phpt b/ext/simplexml/tests/bug25756.phpt
deleted file mode 100644
index 843ed40547..0000000000
--- a/ext/simplexml/tests/bug25756.phpt
+++ /dev/null
@@ -1,70 +0,0 @@
---TEST--
-Bug #25756 (validate_schema_file() broken)
---FILE--
-<?php
-$dir = dirname(__FILE__);
-$valid_schema_file = "$dir/bug25756.xsd";
-$invalid_schema_file = "$dir/bug25756_1.xml";
-$xml_file_valid = "$dir/bug25756_1.xml";
-$xml_file_invalid = "$dir/bug25756_2.xml";
-
-$s = simplexml_load_file($xml_file_valid);
-var_dump($s);
-var_dump($s->validate_schema_file($valid_schema_file));
-var_dump($s->validate_schema_file($invalid_schema_file));
-$s = simplexml_load_file($xml_file_invalid);
-var_dump($s);
-var_dump($s->validate_schema_file($valid_schema_file));
-?>
---EXPECTF--
-object(simplexml_element)#%d (1) {
- ["items"]=>
- object(simplexml_element)#%d (1) {
- ["item"]=>
- array(2) {
- [0]=>
- object(simplexml_element)#%d (2) {
- ["product-name"]=>
- string(3) "abc"
- ["quantity"]=>
- string(3) "123"
- }
- [1]=>
- object(simplexml_element)#%d (2) {
- ["product-name"]=>
- string(3) "def"
- ["quantity"]=>
- string(3) "456"
- }
- }
- }
-}
-bool(true)
-
-Warning: simplexml_element::validate_schema_file(): Malformed XML Schema in %sbug25756.php on line %d
-bool(false)
-object(simplexml_element)#%d (1) {
- ["items"]=>
- object(simplexml_element)#%d (1) {
- ["item"]=>
- array(2) {
- [0]=>
- object(simplexml_element)#%d (2) {
- ["product-name"]=>
- string(3) "abc"
- ["quantity"]=>
- string(3) "abc"
- }
- [1]=>
- object(simplexml_element)#%d (2) {
- ["product-name"]=>
- string(3) "abc"
- ["quantity"]=>
- string(3) "123"
- }
- }
- }
-}
-
-Warning: Element quantity: failed to validate basic type decimal in %s on line %d
-bool(false)