helly           Sun Oct 26 08:19:00 2003 EDT

  Added files:                 
    /php-src/ext/simplexml/tests        006.phpt 006.xml 

  Modified files:              
    /php-src/ext/simplexml/tests        sxe.dtd 
  Log:
  Add foreach test
  
  
Index: php-src/ext/simplexml/tests/sxe.dtd
diff -u php-src/ext/simplexml/tests/sxe.dtd:1.1 php-src/ext/simplexml/tests/sxe.dtd:1.2
--- php-src/ext/simplexml/tests/sxe.dtd:1.1     Sat Oct 25 16:00:04 2003
+++ php-src/ext/simplexml/tests/sxe.dtd Sun Oct 26 08:18:59 2003
@@ -1,7 +1,7 @@
 <?xml encoding='US-ASCII'?>
 
-<!ELEMENT sxe    elem1>
-<!ATTLIST sxe    id>
+<!ELEMENT sxe    elem1, elem 11>
+<!ATTLIST sxe    id     CDATA  #implied>
 
 <!ELEMENT elem1  elem2>
 <!ATTLIST elem1  attr1  CDATA  #required
@@ -15,4 +15,7 @@
 
 <!ELEMENT elem4  EMPTY>
 <!ATTLIST elem4>
+
+<!ELEMENT elem11 EMPTY>
+<!ATTLIST elem11>
 

Index: php-src/ext/simplexml/tests/006.phpt
+++ php-src/ext/simplexml/tests/006.phpt
--TEST--
SimpleXML and foreach
--SKIPIF--
<?php if (!extension_loaded("simplexml")) print "skip"; ?>
--FILE--
<?php 

$sxe = simplexml_load_file(dirname(__FILE__).'/006.xml');

foreach($sxe as $name => $data) {
        var_dump($name);
        var_dump(trim($data));
}

foreach($sxe->__clone() as $name => $data) {
        var_dump($name);
        var_dump(trim($data));
}

foreach($sxe->elem1 as $name => $data) {
        var_dump($name);
        var_dump(trim($data));
}

echo "===Done===\n";

?>
--EXPECT--
string(5) "elem1"
string(10) "Bla bla 1."
string(6) "elem11"
string(10) "Bla bla 2."
string(5) "elem1"
string(10) "Bla bla 1."
string(6) "elem11"
string(10) "Bla bla 2."
string(7) "comment"
string(0) ""
string(5) "elem2"
string(28) "Here we have some text data."
===Done===

Index: php-src/ext/simplexml/tests/006.xml
+++ php-src/ext/simplexml/tests/006.xml
<?xml version='1.0'?>
<!DOCTYPE sxe SYSTEM "notfound.dtd" [
<!ENTITY % incent SYSTEM "sxe.ent">
%incent;
]>
<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.
 </elem11>
</sxe> 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to