diff options
| author | Ondřej Surý <ondrej@sury.org> | 2011-08-19 10:22:38 +0200 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2011-08-19 10:22:38 +0200 |
| commit | f452a2b3e4e4279b27594a8ddb66525442d59227 (patch) | |
| tree | d05cb62c5515ada33076d3cc3e49b664733a478c /ext/spl/tests | |
| parent | 038ba12e8724d537040e88ec794354b0c063f0a6 (diff) | |
| download | php-upstream/5.3.7.tar.gz | |
Imported Upstream version 5.3.7upstream/5.3.7
Diffstat (limited to 'ext/spl/tests')
| -rw-r--r-- | ext/spl/tests/DirectoryIterator_getGroup_basic.phpt | 20 | ||||
| -rw-r--r-- | ext/spl/tests/DirectoryIterator_getOwner_basic.phpt | 35 | ||||
| -rw-r--r-- | ext/spl/tests/SplFileInfo_getGroup_basic.phpt | 36 | ||||
| -rw-r--r-- | ext/spl/tests/SplFileInfo_getOwner_basic.phpt | 36 | ||||
| -rw-r--r-- | ext/spl/tests/bug54281.phpt | 15 | ||||
| -rw-r--r-- | ext/spl/tests/bug54291.phpt | 13 | ||||
| -rw-r--r-- | ext/spl/tests/bug54292.phpt | 14 | ||||
| -rw-r--r-- | ext/spl/tests/bug54384.phpt | 171 | ||||
| -rw-r--r-- | ext/spl/tests/bug54970.phpt | 33 | ||||
| -rw-r--r-- | ext/spl/tests/bug54971.phpt | 45 | ||||
| -rwxr-xr-x | ext/spl/tests/iterator_031.phpt | 4 |
11 files changed, 349 insertions, 73 deletions
diff --git a/ext/spl/tests/DirectoryIterator_getGroup_basic.phpt b/ext/spl/tests/DirectoryIterator_getGroup_basic.phpt index 58387ccce..9cc9fadbe 100644 --- a/ext/spl/tests/DirectoryIterator_getGroup_basic.phpt +++ b/ext/spl/tests/DirectoryIterator_getGroup_basic.phpt @@ -8,23 +8,19 @@ Daniel Londero <daniel.londero@gmail.com> Francesco Trucchia <ft@ideato.it> Jacopo Romei <jacopo@sviluppoagile.it> #Test Fest Cesena (Italy) on 2009-06-20
---SKIPIF--
-<?php
-if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
-?>
--FILE--
<?php
- -shell_exec('mkdir test_dir_ptfi'); -$dir = new DirectoryIterator('test_dir_ptfi'); -$result = shell_exec('ls -lnd test_dir_ptfi | cut -d" " -f 4'); - -var_dump($dir->getGroup() == $result); - +$dirname = 'DirectoryIterator_getGroup_basic'; +mkdir($dirname); +$dir = new DirectoryIterator($dirname); +$expected = filegroup($dirname); +$actual = $dir->getGroup(); +var_dump($expected == $actual); ?> --CLEAN-- <?php -rmdir('test_dir_ptfi'); +$dirname = 'DirectoryIterator_getGroup_basic'; +rmdir($dirname); ?>
--EXPECTF--
bool(true) diff --git a/ext/spl/tests/DirectoryIterator_getOwner_basic.phpt b/ext/spl/tests/DirectoryIterator_getOwner_basic.phpt index e342dcdb6..c5e9f7c2c 100644 --- a/ext/spl/tests/DirectoryIterator_getOwner_basic.phpt +++ b/ext/spl/tests/DirectoryIterator_getOwner_basic.phpt @@ -1,29 +1,26 @@ ---TEST--
-SPL: Spl Directory Iterator test getOwner
---CREDITS--
+--TEST-- +SPL: DirectoryIterator test getOwner +--CREDITS-- Cesare D'Amico <cesare.damico@gruppovolta.it> Andrea Giorgini <agiorg@gmail.com> Filippo De Santis <fd@ideato.it> Daniel Londero <daniel.londero@gmail.com> Francesco Trucchia <ft@ideato.it> Jacopo Romei <jacopo@sviluppoagile.it> -#Test Fest Cesena (Italy) on 2009-06-20
---SKIPIF--
-<?php
-if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
-?>
---FILE--
-<?php
- -shell_exec('mkdir test_dir_ptfi'); -$dir = new DirectoryIterator('test_dir_ptfi'); -$result = shell_exec('ls -lnd test_dir_ptfi | cut -d" " -f 3'); -var_dump($dir->getOwner() == $result); - +#Test Fest Cesena (Italy) on 2009-06-20 +--FILE-- +<?php +$dirname = 'DirectoryIterator_getOwner_basic'; +mkdir($dirname); +$dir = new DirectoryIterator($dirname); +$expected = fileowner($dirname); +$actual = $dir->getOwner(); +var_dump($expected == $actual); ?> --CLEAN-- <?php -rmdir('test_dir_ptfi'); -?>
---EXPECTF--
+$dirname = 'DirectoryIterator_getOwner_basic'; +rmdir($dirname); +?> +--EXPECTF-- bool(true) diff --git a/ext/spl/tests/SplFileInfo_getGroup_basic.phpt b/ext/spl/tests/SplFileInfo_getGroup_basic.phpt index 7b0528d7d..c5808c57d 100644 --- a/ext/spl/tests/SplFileInfo_getGroup_basic.phpt +++ b/ext/spl/tests/SplFileInfo_getGroup_basic.phpt @@ -1,30 +1,26 @@ ---TEST--
-SPL: Spl File Info test getGroup
---CREDITS--
+--TEST-- +SPL: SplFileInfo test getGroup +--CREDITS-- Cesare D'Amico <cesare.damico@gruppovolta.it> Andrea Giorgini <agiorg@gmail.com> Filippo De Santis <fd@ideato.it> Daniel Londero <daniel.londero@gmail.com> Francesco Trucchia <ft@ideato.it> Jacopo Romei <jacopo@sviluppoagile.it> -#Test Fest Cesena (Italy) on 2009-06-20
---SKIPIF--
-<?php
-if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
-?>
---FILE--
-<?php
- -//file -touch ('test_file_ptfi'); -$fileInfo = new SplFileInfo('test_file_ptfi'); -$result = shell_exec('ls -ln test_file_ptfi | cut -d" " -f 4'); -var_dump($fileInfo->getGroup() == $result); - +#Test Fest Cesena (Italy) on 2009-06-20 +--FILE-- +<?php +$filename = basename(__FILE__, 'phpt').'tmp'; +touch($filename); +$fileInfo = new SplFileInfo($filename); +$expected = filegroup($filename); +$actual = $fileInfo->getGroup(); +var_dump($expected == $actual); ?> --CLEAN-- <?php -unlink('test_file_ptfi'); -?>
---EXPECTF--
+$filename = basename(__FILE__, 'phpt').'tmp'; +unlink($filename); +?> +--EXPECTF-- bool(true) diff --git a/ext/spl/tests/SplFileInfo_getOwner_basic.phpt b/ext/spl/tests/SplFileInfo_getOwner_basic.phpt index 50f79430c..790dcc69b 100644 --- a/ext/spl/tests/SplFileInfo_getOwner_basic.phpt +++ b/ext/spl/tests/SplFileInfo_getOwner_basic.phpt @@ -1,30 +1,26 @@ ---TEST--
-SPL: Spl File Info test getOwner
---CREDITS--
+--TEST-- +SPL: SplFileInfo test getOwner +--CREDITS-- Cesare D'Amico <cesare.damico@gruppovolta.it> Andrea Giorgini <agiorg@gmail.com> Filippo De Santis <fd@ideato.it> Daniel Londero <daniel.londero@gmail.com> Francesco Trucchia <ft@ideato.it> Jacopo Romei <jacopo@sviluppoagile.it> -#Test Fest Cesena (Italy) on 2009-06-20
---SKIPIF--
-<?php
-if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
-?>
---FILE--
-<?php
- -//file -touch ('test_file_ptfi'); -$fileInfo = new SplFileInfo('test_file_ptfi'); -$result = shell_exec('ls -ln test_file_ptfi | cut -d" " -f 3'); -var_dump($fileInfo->getOwner() == $result); - +#Test Fest Cesena (Italy) on 2009-06-20 +--FILE-- +<?php +$filename = basename(__FILE__, 'phpt').'tmp'; +touch($filename); +$fileInfo = new SplFileInfo($filename); +$expected = fileowner($filename); +$actual = $fileInfo->getOwner(); +var_dump($expected == $actual); ?> --CLEAN-- <?php -unlink('test_file_ptfi'); -?>
---EXPECTF--
+$filename = basename(__FILE__, 'phpt').'tmp'; +unlink($filename); +?> +--EXPECTF-- bool(true) diff --git a/ext/spl/tests/bug54281.phpt b/ext/spl/tests/bug54281.phpt new file mode 100644 index 000000000..d42d9e585 --- /dev/null +++ b/ext/spl/tests/bug54281.phpt @@ -0,0 +1,15 @@ +--TEST-- +Bug #54281 (Crash in spl_recursive_it_rewind_ex) +--FILE-- +<?php + +class RecursiveArrayIteratorIterator extends RecursiveIteratorIterator { + function __construct($it, $max_depth) { } +} +$it = new RecursiveArrayIteratorIterator(new RecursiveArrayIterator(array()), 2); + +foreach($it as $k=>$v) { } + +?> +--EXPECTF-- +Fatal error: RecursiveIteratorIterator::rewind(): The RecursiveArrayIteratorIterator instance wasn't initialized properly in %s on line %d diff --git a/ext/spl/tests/bug54291.phpt b/ext/spl/tests/bug54291.phpt new file mode 100644 index 000000000..b8f596e02 --- /dev/null +++ b/ext/spl/tests/bug54291.phpt @@ -0,0 +1,13 @@ +--TEST-- +Bug #54291 (Crash iterating DirectoryIterator for dir name starting with \0) +--FILE-- +<?php +$dir = new DirectoryIterator("\x00/abc"); +$dir->isFile(); +--EXPECTF-- +Fatal error: Uncaught exception 'UnexpectedValueException' with message 'Failed to open directory ""' in %s:%d +Stack trace: +#0 %s(%d): DirectoryIterator->__construct('?/abc') +#1 {main} + thrown in %s on line %d + diff --git a/ext/spl/tests/bug54292.phpt b/ext/spl/tests/bug54292.phpt new file mode 100644 index 000000000..d9175f7e6 --- /dev/null +++ b/ext/spl/tests/bug54292.phpt @@ -0,0 +1,14 @@ +--TEST-- +Bug #54292 (Wrong parameter causes crash in SplFileObject::__construct()) +--FILE-- +<?php + +try { + new SplFileObject('foo', array()); +} catch (Exception $e) { + var_dump($e->getMessage()); +} + +?> +--EXPECTF-- +string(74) "SplFileObject::__construct() expects parameter 2 to be string, array given" diff --git a/ext/spl/tests/bug54384.phpt b/ext/spl/tests/bug54384.phpt new file mode 100644 index 000000000..a1ce7edff --- /dev/null +++ b/ext/spl/tests/bug54384.phpt @@ -0,0 +1,171 @@ +--TEST-- +Bug #54384: Several SPL classes crash when the parent constructor is not called +--FILE-- +<?php + +function test($f) { + try { + $f(); + echo "ran normally (unexpected)\n\n"; + } catch (LogicException $e) { + echo "exception (expected)\n"; + } +} + +echo "IteratorIterator... "; +class IteratorIteratorTest extends IteratorIterator { + function __construct(){} +} +test( function() { + $o = new IteratorIteratorTest; + $o->rewind(); +} ); + +echo "FilterIterator... "; +class FilterIteratorTest extends FilterIterator { + function __construct(){} + function accept(){} +} +test( function() { + $o = new FilterIteratorTest; + $o->rewind(); +} ); + +echo "RecursiveFilterIterator... "; +class RecursiveFilterIteratorTest extends RecursiveFilterIterator { + function __construct(){} + function accept(){} +} +test( function() { +$o = new RecursiveFilterIteratorTest; +$o->hasChildren(); +} ); + +echo "ParentIterator... "; +class ParentIteratorTest extends ParentIterator { + function __construct(){} +} +test ( function() { +$o = new ParentIteratorTest; +$o->accept(); +} ); + +echo "LimitIterator... "; +class LimitIteratorTest extends LimitIterator { + function __construct(){} +} +test ( function() { +$o = new LimitIteratorTest; +$o->rewind(); +} ); + +echo "CachingIterator... "; +class CachingIteratorTest extends CachingIterator { + function __construct(){} +} +test ( function() { +$o = new CachingIteratorTest; +$o->rewind(); +} ); + +echo "RecursiveCachingIterator... "; +class RecursiveCachingIteratorTest extends RecursiveCachingIterator { + function __construct(){} +} +test ( function() { +$o = new RecursiveCachingIteratorTest; +$o->rewind(); +} ); + +echo "NoRewindIterator... "; +class NoRewindIteratorTest extends NoRewindIterator { + function __construct(){} +} +test ( function() { +$o = new NoRewindIteratorTest; +$o->valid(); +} ); + +echo "RegexIterator... "; +class RegexIteratorTest extends RegexIterator { + function __construct(){} +} +test ( function() { +$o = new RegexIteratorTest; +$o->rewind(); +} ); + +echo "RecursiveRegexIterator... "; +class RecursiveRegexIteratorTest extends RecursiveRegexIterator { + function __construct(){} +} +test ( function() { +$o = new RecursiveRegexIteratorTest; +$o->hasChildren(); +} ); + +echo "GlobIterator... "; +class GlobIteratorTest extends GlobIterator { + function __construct(){} +} +test ( function() { +$o = new GlobIteratorTest; +$o->count(); +} ); + +echo "SplFileObject... "; +class SplFileObjectTest extends SplFileObject { + function __construct(){} +} +test ( function() { +$o = new SplFileObjectTest; +$o->rewind(); +} ); + +echo "SplTempFileObject... "; +class SplTempFileObjectTest extends SplTempFileObject { + function __construct(){} +} +test ( function() { +$o = new SplTempFileObjectTest; +$o->rewind(); +} ); + +echo "AppendIterator... "; +class AppendIteratorTest extends AppendIterator { + function __construct(){} +} +test ( function() { +$o = new AppendIteratorTest; +foreach ($o as $a) { +echo $a,"\n"; +} +} ); + +echo "InfiniteIterator... "; +class InfiniteIteratorTest extends InfiniteIterator { + function __construct(){} +} +test ( function() { +$o = new InfiniteIteratorTest; +foreach ($o as $a) { +echo $a,"\n"; +} +} ); + +--EXPECT-- +IteratorIterator... exception (expected) +FilterIterator... exception (expected) +RecursiveFilterIterator... exception (expected) +ParentIterator... exception (expected) +LimitIterator... exception (expected) +CachingIterator... exception (expected) +RecursiveCachingIterator... exception (expected) +NoRewindIterator... exception (expected) +RegexIterator... exception (expected) +RecursiveRegexIterator... exception (expected) +GlobIterator... exception (expected) +SplFileObject... exception (expected) +SplTempFileObject... exception (expected) +AppendIterator... exception (expected) +InfiniteIterator... exception (expected) diff --git a/ext/spl/tests/bug54970.phpt b/ext/spl/tests/bug54970.phpt new file mode 100644 index 000000000..62b1eedb5 --- /dev/null +++ b/ext/spl/tests/bug54970.phpt @@ -0,0 +1,33 @@ +--TEST-- +Bug #54970 (SplFixedArray::setSize() isn't resizing) +--FILE-- +<?php + +$fa = new SplFixedArray(2); +$fa[0] = 'Hello'; +$fa[1] = 'World'; +$fa->setSize(3); +$fa[2] = '!'; +var_dump($fa); +$fa->setSize(2); +var_dump($fa); +var_dump($fa->getSize()); + + +?> +--EXPECTF-- +object(SplFixedArray)#%d (3) { + [0]=> + string(5) "Hello" + [1]=> + string(5) "World" + [2]=> + string(1) "!" +} +object(SplFixedArray)#%d (2) { + [0]=> + string(5) "Hello" + [1]=> + string(5) "World" +} +int(2) diff --git a/ext/spl/tests/bug54971.phpt b/ext/spl/tests/bug54971.phpt new file mode 100644 index 000000000..166613b43 --- /dev/null +++ b/ext/spl/tests/bug54971.phpt @@ -0,0 +1,45 @@ +--TEST-- +Bug #54971 (Wrong result when using iterator_to_array with use_keys on true) +--FILE-- +<?php + +$source = <<<XML +<root> +<node>val1</node> +<node>val2</node> +</root> +XML; + + +$doc = new DOMDocument(); +$doc->loadXML($source); + +$xpath = new DOMXPath($doc); +$items = $xpath->query('//node'); + +print_r(iterator_to_array($items, false)); +print_r(iterator_to_array($items, true)); +?> +--EXPECT-- +Array +( + [0] => DOMElement Object + ( + ) + + [1] => DOMElement Object + ( + ) + +) +Array +( + [0] => DOMElement Object + ( + ) + + [1] => DOMElement Object + ( + ) + +) diff --git a/ext/spl/tests/iterator_031.phpt b/ext/spl/tests/iterator_031.phpt index 458f071b7..40342f4bb 100755 --- a/ext/spl/tests/iterator_031.phpt +++ b/ext/spl/tests/iterator_031.phpt @@ -56,7 +56,7 @@ try { $ap->append($it); } -catch(BadMethodCallException $e) +catch(LogicException $e) { echo $e->getMessage() . "\n"; } @@ -90,7 +90,7 @@ MyArrayIterator::rewind 1=>2 MyAppendIterator::__construct MyAppendIterator::append -Classes derived from AppendIterator must call AppendIterator::__construct() +The object is in an invalid state as the parent constructor was not called AppendIterator::getIterator() must be called exactly once per instance MyAppendIterator::append MyArrayIterator::rewind |
