]> granicus.if.org Git - php/commitdiff
*** empty log message ***
authorDmitry Stogov <dmitry@php.net>
Wed, 17 Dec 2003 14:49:10 +0000 (14:49 +0000)
committerDmitry Stogov <dmitry@php.net>
Wed, 17 Dec 2003 14:49:10 +0000 (14:49 +0000)
ext/simplexml/tests/014.phpt [new file with mode: 0644]
ext/simplexml/tests/015.phpt [new file with mode: 0644]
ext/simplexml/tests/016.phpt [new file with mode: 0644]

diff --git a/ext/simplexml/tests/014.phpt b/ext/simplexml/tests/014.phpt
new file mode 100644 (file)
index 0000000..b3d17af
--- /dev/null
@@ -0,0 +1,36 @@
+--TEST--
+SimpleXML: adding/removing attributes
+--SKIPIF--
+<?php if (!extension_loaded("simplexml")) print "skip"; ?>
+--FILE--
+<?php 
+$xml =<<<EOF
+<people>
+   <person name="Joe"></person>
+   <person name="Boe"></person>
+</people>
+EOF;
+
+$people = simplexml_load_string($xml);
+var_dump($people->person[0]['name']);
+var_dump($people->person[0]['age']);
+$people->person[0]['name'] = "XXX";
+$people->person[0]['age'] = 30;
+var_dump($people->person[0]['name']);
+var_dump($people->person[0]['age']);
+$people->person[0]['age'] += 5;
+var_dump($people->person[0]['age']);
+unset($people->person[0]['age']);
+var_dump($people->person[0]['age']);
+var_dump(isset($people->person[0]['age']));
+echo "---Done---\n";
+?>
+--EXPECT--
+string(3) "Joe"
+NULL
+string(3) "XXX"
+string(2) "30"
+string(2) "35"
+NULL
+bool(false)
+---Done---
diff --git a/ext/simplexml/tests/015.phpt b/ext/simplexml/tests/015.phpt
new file mode 100644 (file)
index 0000000..ecf172a
--- /dev/null
@@ -0,0 +1,40 @@
+--TEST--
+SimpleXML: accessing singular subnode as array
+--SKIPIF--
+<?php if (!extension_loaded("simplexml")) print "skip"; ?>
+--FILE--
+<?php 
+$xml =<<<EOF
+<people>
+   <person name="Joe"></person>
+</people>
+EOF;
+
+$people = simplexml_load_string($xml);
+var_dump($people->person['name']);
+var_dump($people->person[0]['name']);
+$people->person['name'] = "XXX";
+var_dump($people->person['name']);
+var_dump($people->person[0]['name']);
+$people->person[0]['name'] = "YYY";
+var_dump($people->person['name']);
+var_dump($people->person[0]['name']);
+unset($people->person[0]['name']);
+var_dump($people->person['name']);
+var_dump($people->person[0]['name']);
+var_dump(isset($people->person['name']));
+var_dump(isset($people->person[0]['name']));
+echo "---Done---\n";
+?>
+--EXPECT--
+string(3) "Joe"
+string(3) "Joe"
+string(3) "XXX"
+string(3) "XXX"
+string(3) "YYY"
+string(3) "YYY"
+NULL
+NULL
+bool(false)
+bool(false)
+---Done---
diff --git a/ext/simplexml/tests/016.phpt b/ext/simplexml/tests/016.phpt
new file mode 100644 (file)
index 0000000..9c402ad
--- /dev/null
@@ -0,0 +1,26 @@
+--TEST--
+SimpleXML: modifying attributes of singular subnode
+--SKIPIF--
+<?php if (!extension_loaded("simplexml")) print "skip"; ?>
+--FILE--
+<?php 
+$xml =<<<EOF
+<people>
+   <person name="Joe"></person>
+</people>
+EOF;
+
+$people = simplexml_load_string($xml);
+var_dump($people->person['name']);
+var_dump($people->person[0]['name']);
+$people->person[0]['name'] .= "ZZZ";
+var_dump($people->person['name']);
+var_dump($people->person[0]['name']);
+echo "---Done---\n";
+?>
+--EXPECT--
+string(3) "Joe"
+string(3) "Joe"
+string(3) "JoeZZZ"
+string(3) "JoeZZZ"
+---Done---