diff options
| author | SVN Migration <svn@php.net> | 2008-12-03 20:30:45 +0000 |
|---|---|---|
| committer | SVN Migration <svn@php.net> | 2008-12-03 20:30:45 +0000 |
| commit | 2876046398950e59c3b3c460e67e6fec7ff2ba3c (patch) | |
| tree | 33b2b8b4b859960a6446ad19d0ada1c55f9cfcda /ext/spl/tests | |
| parent | 3fb86b0b9e79e6a3312b694f30ee627e2e1b325c (diff) | |
| download | php-git-php-5.3.0alpha2.tar.gz | |
This commit was manufactured by cvs2svn to create tag 'php_5_3_0alpha2'.php-5.3.0alpha2
Diffstat (limited to 'ext/spl/tests')
| -rwxr-xr-x | ext/spl/tests/array_001.phpt | 8 | ||||
| -rw-r--r-- | ext/spl/tests/bug42259.phpt | 49 | ||||
| -rw-r--r-- | ext/spl/tests/heap_007.phpt | 9 | ||||
| -rw-r--r-- | ext/spl/tests/pqueue_003.phpt | 8 | ||||
| -rwxr-xr-x | ext/spl/tests/spl_autoload_012.phpt | 12 | ||||
| -rwxr-xr-x | ext/spl/tests/sxe_001.phpt | 63 | ||||
| -rwxr-xr-x | ext/spl/tests/sxe_002.phpt | 75 | ||||
| -rwxr-xr-x | ext/spl/tests/sxe_003.phpt | 77 | ||||
| -rwxr-xr-x | ext/spl/tests/sxe_004.phpt | 145 | ||||
| -rwxr-xr-x | ext/spl/tests/sxe_005.phpt | 44 |
10 files changed, 465 insertions, 25 deletions
diff --git a/ext/spl/tests/array_001.phpt b/ext/spl/tests/array_001.phpt index d9fb57c4ce..9f4f35057f 100755 --- a/ext/spl/tests/array_001.phpt +++ b/ext/spl/tests/array_001.phpt @@ -36,7 +36,7 @@ var_dump($ar); ===DONE=== <?php exit(0); ?> --EXPECTF-- -object(ArrayObject)#%d (1) { +object(ArrayObject)#1 (1) { ["storage":"ArrayObject":private]=> array(2) { [0]=> @@ -62,7 +62,7 @@ array(6) { int(5) } string(1) "a" -object(ArrayObject)#%d (1) { +object(ArrayObject)#1 (1) { ["storage":"ArrayObject":private]=> array(5) { [0]=> @@ -88,7 +88,7 @@ NULL Notice: Undefined offset: 7 in %sarray_001.php on line %d Notice: Undefined index: c in %sarray_001.php on line %d -object(ArrayObject)#%d (1) { +object(ArrayObject)#1 (1) { ["storage":"ArrayObject":private]=> array(2) { [0]=> @@ -97,7 +97,7 @@ object(ArrayObject)#%d (1) { int(2) } } -object(ArrayObject)#%d (1) { +object(ArrayObject)#1 (1) { ["storage":"ArrayObject":private]=> array(4) { [0]=> diff --git a/ext/spl/tests/bug42259.phpt b/ext/spl/tests/bug42259.phpt new file mode 100644 index 0000000000..19c02a577a --- /dev/null +++ b/ext/spl/tests/bug42259.phpt @@ -0,0 +1,49 @@ +--TEST-- +Bug #42259 (SimpleXMLIterator loses ancestry) +--SKIPIF-- +<?php +if (!extension_loaded('simplexml')) print 'skip'; +if (!extension_loaded("libxml")) print "skip LibXML not present"; +?> +--FILE-- +<?php +$xml =<<<EOF +<xml> + <fieldset1> + <field1/> + <field2/> + </fieldset1> + <fieldset2> + <options> + <option1/> + <option2/> + <option3/> + </options> + <field1/> + <field2/> + </fieldset2> +</xml> +EOF; + +$sxe = new SimpleXMLIterator($xml); +$rit = new RecursiveIteratorIterator($sxe, RecursiveIteratorIterator::LEAVES_ONLY); +foreach ($rit as $child) { + $path = ''; + $ancestry = $child->xpath('ancestor-or-self::*'); + foreach ($ancestry as $ancestor) { + $path .= $ancestor->getName() . '/'; + } + $path = substr($path, 0, strlen($path) - 1); + echo count($ancestry) . ' steps: ' . $path . PHP_EOL; +} +?> +===DONE=== +--EXPECT-- +3 steps: xml/fieldset1/field1 +3 steps: xml/fieldset1/field2 +4 steps: xml/fieldset2/options/option1 +4 steps: xml/fieldset2/options/option2 +4 steps: xml/fieldset2/options/option3 +3 steps: xml/fieldset2/field1 +3 steps: xml/fieldset2/field2 +===DONE=== diff --git a/ext/spl/tests/heap_007.phpt b/ext/spl/tests/heap_007.phpt index e8d5c9997c..784ac6e8b0 100644 --- a/ext/spl/tests/heap_007.phpt +++ b/ext/spl/tests/heap_007.phpt @@ -12,7 +12,6 @@ $h->insert(4); $h->rewind(); echo "count(\$h) = ".count($h)."\n"; echo "\$h->count() = ".$h->count()."\n"; - while ($h->valid()) { $k = $h->key(); $v = $h->current(); @@ -25,8 +24,8 @@ while ($h->valid()) { --EXPECTF-- count($h) = 4 $h->count() = 4 -3=>5 -2=>4 -1=>1 -0=>0 +4=>5 +3=>4 +2=>1 +1=>0 ===DONE=== diff --git a/ext/spl/tests/pqueue_003.phpt b/ext/spl/tests/pqueue_003.phpt index 9c0b5a5147..8abc72c4c7 100644 --- a/ext/spl/tests/pqueue_003.phpt +++ b/ext/spl/tests/pqueue_003.phpt @@ -24,8 +24,8 @@ while ($h->valid()) { --EXPECTF-- count($h) = 4 $h->count() = 4 -3=>5 -2=>4 -1=>1 -0=>0 +4=>5 +3=>4 +2=>1 +1=>0 ===DONE=== diff --git a/ext/spl/tests/spl_autoload_012.phpt b/ext/spl/tests/spl_autoload_012.phpt index e07f0e4fe5..07e9dfeb63 100755 --- a/ext/spl/tests/spl_autoload_012.phpt +++ b/ext/spl/tests/spl_autoload_012.phpt @@ -26,14 +26,6 @@ try { } while($e = $e->getPrevious()); } -try { - new ThisClassDoesNotExist; -} catch(Exception $e) { - do { - echo $e->getMessage()."\n"; - } while($e = $e->getPrevious()); -} - class_exists('ThisClassDoesNotExist'); ?> ===DONE=== @@ -44,10 +36,6 @@ second first autoload_first autoload_second -second -first -autoload_first -autoload_second Fatal error: Uncaught exception 'Exception' with message 'first' in %sspl_autoload_012.php:%d Stack trace: diff --git a/ext/spl/tests/sxe_001.phpt b/ext/spl/tests/sxe_001.phpt new file mode 100755 index 0000000000..bb93eea076 --- /dev/null +++ b/ext/spl/tests/sxe_001.phpt @@ -0,0 +1,63 @@ +--TEST-- +SPL: SimpleXMLIterator +--SKIPIF-- +<?php +if (!extension_loaded("simplexml")) print "skip SimpleXML not present"; +if (!extension_loaded("libxml")) print "skip LibXML not present"; +?> +--FILE-- +<?php + +$xml =<<<EOF +<?xml version='1.0'?> +<!DOCTYPE sxe SYSTEM "notfound.dtd"> +<sxe id="elem1"> + <elem1 attr1='first'> + <!-- comment --> + <elem2> + <elem3> + <elem4> + <?test processing instruction ?> + </elem4> + </elem3> + </elem2> + </elem1> +</sxe> +EOF; + +var_dump(simplexml_load_string((binary)$xml, 'SimpleXMLIterator')); + +?> +===DONE=== +--EXPECTF-- +object(SimpleXMLIterator)#%d (2) { + ["@attributes"]=> + array(1) { + ["id"]=> + string(5) "elem1" + } + ["elem1"]=> + object(SimpleXMLIterator)#%d (3) { + ["@attributes"]=> + array(1) { + ["attr1"]=> + string(5) "first" + } + ["comment"]=> + object(SimpleXMLIterator)#%d (0) { + } + ["elem2"]=> + object(SimpleXMLIterator)#%d (1) { + ["elem3"]=> + object(SimpleXMLIterator)#%d (1) { + ["elem4"]=> + object(SimpleXMLIterator)#%d (1) { + ["test"]=> + object(SimpleXMLIterator)#%d (0) { + } + } + } + } + } +} +===DONE=== diff --git a/ext/spl/tests/sxe_002.phpt b/ext/spl/tests/sxe_002.phpt new file mode 100755 index 0000000000..b937b011d0 --- /dev/null +++ b/ext/spl/tests/sxe_002.phpt @@ -0,0 +1,75 @@ +--TEST-- +SPL: SimpleXMLIterator and recursion +--SKIPIF-- +<?php +if (!extension_loaded('simplexml')) print 'skip'; +if (!extension_loaded("libxml")) print "skip LibXML not present"; +?> +--FILE-- +<?php + +$xml =<<<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; + +$sxe = simplexml_load_string((binary)$xml, 'SimpleXMLIterator'); + +foreach(new RecursiveIteratorIterator($sxe, 1) as $name => $data) { + var_dump($name); + var_dump(get_class($data)); + var_dump(trim($data)); +} + +echo "===DUMP===\n"; + +var_dump(get_class($sxe)); +var_dump(trim($sxe->elem1)); + +?> +===DONE=== +--EXPECT-- +string(5) "elem1" +string(17) "SimpleXMLIterator" +string(10) "Bla bla 1." +string(5) "elem2" +string(17) "SimpleXMLIterator" +string(28) "Here we have some text data." +string(5) "elem3" +string(17) "SimpleXMLIterator" +string(19) "And here some more." +string(5) "elem4" +string(17) "SimpleXMLIterator" +string(15) "Wow once again." +string(6) "elem11" +string(17) "SimpleXMLIterator" +string(10) "Bla bla 2." +string(7) "elem111" +string(17) "SimpleXMLIterator" +string(7) "Foo Bar" +===DUMP=== +string(17) "SimpleXMLIterator" +string(10) "Bla bla 1." +===DONE=== diff --git a/ext/spl/tests/sxe_003.phpt b/ext/spl/tests/sxe_003.phpt new file mode 100755 index 0000000000..58c7523160 --- /dev/null +++ b/ext/spl/tests/sxe_003.phpt @@ -0,0 +1,77 @@ +--TEST-- +SPL: SimpleXMLIterator and getChildren() +--SKIPIF-- +<?php +if (!extension_loaded('simplexml')) print 'skip'; +if (!extension_loaded("libxml")) print "skip LibXML not present"; +?> +--FILE-- +<?php + +$xml =<<<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; + +$sxe = simplexml_load_string((binary)$xml, 'SimpleXMLIterator'); + +foreach($sxe->getChildren() as $name => $data) { + var_dump($name); + var_dump(get_class($data)); + var_dump(trim($data)); +} + +echo "===RESET===\n"; + +for ($sxe->rewind(); $sxe->valid(); $sxe->next()) { + var_dump($sxe->hasChildren()); + var_dump(trim($sxe->key())); + var_dump(trim($sxe->current())); + foreach($sxe->getChildren() as $name => $data) { + var_dump($name); + var_dump(get_class($data)); + var_dump(trim($data)); + } +} + +?> +===DONE=== +--EXPECTF-- + +Warning: Invalid argument supplied for foreach() in %ssxe_003.php on line %d +===RESET=== +bool(true) +string(5) "elem1" +string(10) "Bla bla 1." +string(5) "elem2" +string(17) "SimpleXMLIterator" +string(28) "Here we have some text data." +bool(true) +string(6) "elem11" +string(10) "Bla bla 2." +string(7) "elem111" +string(17) "SimpleXMLIterator" +string(7) "Foo Bar" +===DONE=== diff --git a/ext/spl/tests/sxe_004.phpt b/ext/spl/tests/sxe_004.phpt new file mode 100755 index 0000000000..20431de8be --- /dev/null +++ b/ext/spl/tests/sxe_004.phpt @@ -0,0 +1,145 @@ +--TEST-- +SPL: SimpleXMLIterator and overridden iterator methods() +--SKIPIF-- +<?php +if (!extension_loaded('simplexml')) print 'skip'; +if (!extension_loaded("libxml")) print "skip LibXML not present"; +?> +--FILE-- +<?php + +$xml =<<<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; + +class SXETest extends SimpleXMLIterator +{ + function rewind() + { + echo __METHOD__ . "\n"; + return parent::rewind(); + } + function valid() + { + echo __METHOD__ . "\n"; + return parent::valid(); + } + function current() + { + echo __METHOD__ . "\n"; + return parent::current(); + } + function key() + { + echo __METHOD__ . "\n"; + return parent::key(); + } + function next() + { + echo __METHOD__ . "\n"; + return parent::next(); + } + function hasChildren() + { + echo __METHOD__ . "\n"; + return parent::hasChildren(); + } + function getChildren() + { + echo __METHOD__ . "\n"; + return parent::getChildren(); + } +} + +$sxe = new SXETest((binary)$xml); +$rit = new RecursiveIteratorIterator($sxe, RecursiveIteratorIterator::SELF_FIRST); + +foreach($rit as $data) { + var_dump(get_class($data)); + var_dump(trim($data)); +} + +?> +===DONE=== +--EXPECTF-- +SXETest::rewind +SXETest::valid +SXETest::hasChildren +SXETest::valid +SXETest::current +string(7) "SXETest" +string(10) "Bla bla 1." +SXETest::getChildren +SXETest::rewind +SXETest::valid +SXETest::hasChildren +SXETest::valid +SXETest::current +string(7) "SXETest" +string(28) "Here we have some text data." +SXETest::getChildren +SXETest::rewind +SXETest::valid +SXETest::hasChildren +SXETest::valid +SXETest::current +string(7) "SXETest" +string(19) "And here some more." +SXETest::getChildren +SXETest::rewind +SXETest::valid +SXETest::hasChildren +SXETest::valid +SXETest::current +string(7) "SXETest" +string(15) "Wow once again." +SXETest::next +SXETest::valid +SXETest::next +SXETest::valid +SXETest::next +SXETest::valid +SXETest::next +SXETest::valid +SXETest::hasChildren +SXETest::valid +SXETest::current +string(7) "SXETest" +string(10) "Bla bla 2." +SXETest::getChildren +SXETest::rewind +SXETest::valid +SXETest::hasChildren +SXETest::valid +SXETest::current +string(7) "SXETest" +string(7) "Foo Bar" +SXETest::next +SXETest::valid +SXETest::next +SXETest::valid +SXETest::valid +===DONE=== diff --git a/ext/spl/tests/sxe_005.phpt b/ext/spl/tests/sxe_005.phpt new file mode 100755 index 0000000000..183d351166 --- /dev/null +++ b/ext/spl/tests/sxe_005.phpt @@ -0,0 +1,44 @@ +--TEST-- +SPL: SimpleXMLIterator and overriden count() +--SKIPIF-- +<?php +if (!extension_loaded('simplexml')) print 'skip'; +if (!extension_loaded("libxml")) print "skip LibXML not present"; +?> +--FILE-- +<?php + +$xml =<<<EOF +<?xml version='1.0'?> +<sxe> + <elem1/> + <elem2/> + <elem2/> +</sxe> +EOF; + +class SXETest extends SimpleXMLIterator +{ + function count() + { + echo __METHOD__ . "\n"; + return parent::count(); + } +} + +$sxe = new SXETest((binary)$xml); + +var_dump(count($sxe)); +var_dump(count($sxe->elem1)); +var_dump(count($sxe->elem2)); + +?> +===DONE=== +--EXPECT-- +SXETest::count +int(3) +SXETest::count +int(1) +SXETest::count +int(2) +===DONE=== |
