]> granicus.if.org Git - php/commitdiff
Add some testing
authorMarcus Boerger <helly@php.net>
Sat, 25 Oct 2003 20:00:04 +0000 (20:00 +0000)
committerMarcus Boerger <helly@php.net>
Sat, 25 Oct 2003 20:00:04 +0000 (20:00 +0000)
ext/simplexml/tests/001.phpt
ext/simplexml/tests/002.phpt [new file with mode: 0644]
ext/simplexml/tests/sxe.dtd [new file with mode: 0755]
ext/simplexml/tests/sxe.ent [new file with mode: 0755]
ext/simplexml/tests/sxe.xml [new file with mode: 0755]

index 7b53bf1cb7a0518f9e4f92195612f0928cfa6249..3c1c8869a80bbc6a48154dee7b43ddbe833b7c4f 100644 (file)
@@ -1,24 +1,48 @@
 --TEST--
-Check for simplexml presence
+SimpleXML without CDATA
 --SKIPIF--
 <?php if (!extension_loaded("simplexml")) print "skip"; ?>
---POST--
---GET--
---INI--
 --FILE--
 <?php 
-echo "simplexml extension is available";
-/*
-       you can add regression tests for your extension here
-
-  the output of your test code has to be equal to the
-  text in the --EXPECT-- section below for the tests
-  to pass, differences between the output and the
-  expected text are interpreted as failure
-
-       see php4/README.TESTING for further information on
-  writing regression tests
-*/
+
+$sxe = simplexml_load_file(dirname(__FILE__).'/sxe.xml');
+
+print_r($sxe);
+
+echo "---Done---\n";
+
 ?>
 --EXPECT--
-simplexml extension is available
+simplexml_element Object
+(
+    [elem1] => simplexml_element Object
+        (
+            [comment] => simplexml_element Object
+                (
+                )
+
+            [elem2] => simplexml_element Object
+                (
+                    [elem3] => simplexml_element Object
+                        (
+                            [included-entity] => simplexml_element Object
+                                (
+                                    [included-entity] => This is text included from an entity
+                                )
+
+                            [elem4] => simplexml_element Object
+                                (
+                                    [test] => simplexml_element Object
+                                        (
+                                        )
+
+                                )
+
+                        )
+
+                )
+
+        )
+
+)
+---Done--- 
diff --git a/ext/simplexml/tests/002.phpt b/ext/simplexml/tests/002.phpt
new file mode 100644 (file)
index 0000000..5cae438
--- /dev/null
@@ -0,0 +1,50 @@
+--TEST--
+SimpleXML and clone
+--SKIPIF--
+<?php if (!extension_loaded("simplexml")) print "skip"; ?>
+--FILE--
+<?php 
+
+$sxe = simplexml_load_file(dirname(__FILE__).'/sxe.xml');
+
+$copy = $sxe->__clone;
+
+print_r($copy);
+
+echo "---Done---\n";
+
+?>
+--EXPECT--
+simplexml_element Object
+(
+    [elem1] => simplexml_element Object
+        (
+            [comment] => simplexml_element Object
+                (
+                )
+
+            [elem2] => simplexml_element Object
+                (
+                    [elem3] => simplexml_element Object
+                        (
+                            [included-entity] => simplexml_element Object
+                                (
+                                    [included-entity] => This is text included from an entity
+                                )
+
+                            [elem4] => simplexml_element Object
+                                (
+                                    [test] => simplexml_element Object
+                                        (
+                                        )
+
+                                )
+
+                        )
+
+                )
+
+        )
+
+)
+---Done--- 
diff --git a/ext/simplexml/tests/sxe.dtd b/ext/simplexml/tests/sxe.dtd
new file mode 100755 (executable)
index 0000000..66b0369
--- /dev/null
@@ -0,0 +1,18 @@
+<?xml encoding='US-ASCII'?>\r
+\r
+<!ELEMENT sxe    elem1>\r
+<!ATTLIST sxe    id>\r
+\r
+<!ELEMENT elem1  elem2>\r
+<!ATTLIST elem1  attr1  CDATA  #required\r
+                 attr2  CDATA  "default>\r
+\r
+<!ELEMENT elem2  elem3>\r
+<!ATTLIST elem2>\r
+\r
+<!ELEMENT elem3  elem4>\r
+<!ATTLIST elem3>\r
+\r
+<!ELEMENT elem4  EMPTY>\r
+<!ATTLIST elem4>\r
+\r
diff --git a/ext/simplexml/tests/sxe.ent b/ext/simplexml/tests/sxe.ent
new file mode 100755 (executable)
index 0000000..8f86465
--- /dev/null
@@ -0,0 +1 @@
+<!ENTITY included-entity "This is text included from an entity">
diff --git a/ext/simplexml/tests/sxe.xml b/ext/simplexml/tests/sxe.xml
new file mode 100755 (executable)
index 0000000..751921b
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version='1.0'?>
+<!DOCTYPE sxe SYSTEM "notfound.dtd" [
+<!ENTITY % incent SYSTEM "sxe.ent">
+%incent;
+]>
+<sxe id="elem1">
+ Plain text.
+ <elem1 attr1='first'>
+  <!-- comment -->
+  <elem2>
+   <elem3>
+    &included-entity;
+    <elem4>
+     <?test processing instruction ?>
+    </elem4>
+   </elem3>
+  </elem2>
+ </elem1>
+</sxe> 
\ No newline at end of file