diff options
| author | Ondřej Surý <ondrej@sury.org> | 2012-04-06 14:37:49 +0200 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2012-04-06 14:37:49 +0200 |
| commit | 7b10b0041aa63c6f8990ceb3ccc190bdd9eea2b9 (patch) | |
| tree | 01edb9389d7b7f6b277a57e2bce1d05f9748d609 /ext/spl/tests | |
| parent | 096b2f823b2273e3ee707b3805feb78d1e4be61d (diff) | |
| download | php-7b10b0041aa63c6f8990ceb3ccc190bdd9eea2b9.tar.gz | |
Imported Upstream version 5.4.1~rc1upstream/5.4.1_rc1
Diffstat (limited to 'ext/spl/tests')
| -rw-r--r-- | ext/spl/tests/SplFileInfo_001.phpt | 11 | ||||
| -rw-r--r-- | ext/spl/tests/SplFileObject_fputcsv_002.phpt | 5 | ||||
| -rw-r--r-- | ext/spl/tests/SplFileObject_fputcsv_error.phpt | 7 | ||||
| -rw-r--r-- | ext/spl/tests/SplFileObject_fputcsv_variation13.phpt | 5 | ||||
| -rw-r--r-- | ext/spl/tests/SplFileObject_fputcsv_variation14.phpt | 5 | ||||
| -rw-r--r-- | ext/spl/tests/arrayObject_offsetExists_nullcheck.phpt | 10 | ||||
| -rw-r--r-- | ext/spl/tests/bug54971.phpt | 24 | ||||
| -rw-r--r-- | ext/spl/tests/bug61326.phpt | 17 | ||||
| -rw-r--r-- | ext/spl/tests/bug61347.phpt | 40 | ||||
| -rw-r--r-- | ext/spl/tests/bug61418.phpt | 23 | ||||
| -rw-r--r-- | ext/spl/tests/bug61453.phpt | 19 | ||||
| -rw-r--r-- | ext/spl/tests/filesystemiterator_flags.phpt | 40 |
12 files changed, 181 insertions, 25 deletions
diff --git a/ext/spl/tests/SplFileInfo_001.phpt b/ext/spl/tests/SplFileInfo_001.phpt new file mode 100644 index 000000000..72060f0db --- /dev/null +++ b/ext/spl/tests/SplFileInfo_001.phpt @@ -0,0 +1,11 @@ +--TEST-- +Testing SplFileInfo calling the constructor twice +--FILE-- +<?php +$x = new splfileinfo(1); +$x->__construct(1); + +echo "done!\n"; +?> +--EXPECT-- +done! diff --git a/ext/spl/tests/SplFileObject_fputcsv_002.phpt b/ext/spl/tests/SplFileObject_fputcsv_002.phpt index ded467d7b..db174931f 100644 --- a/ext/spl/tests/SplFileObject_fputcsv_002.phpt +++ b/ext/spl/tests/SplFileObject_fputcsv_002.phpt @@ -2,7 +2,7 @@ SplFileObject::fputcsv(): Checking data after calling the function --FILE-- <?php -$fo = new SplFileObject('SplFileObject_fputcsv.csv', 'w'); +$fo = new SplFileObject(__DIR__ . '/SplFileObject_fputcsv.csv', 'w'); $data = array(1, 2, 'foo', 'haha', array(4, 5, 6), 1.3, null); @@ -12,7 +12,8 @@ var_dump($data); ?> --CLEAN-- <?php -unlink('SplFileObject::fputcsv.csv'); +$file = __DIR__ . '/SplFileObject_fputcsv.csv'; +unlink($file); ?> --EXPECTF-- Notice: Array to string conversion in %s on line %d diff --git a/ext/spl/tests/SplFileObject_fputcsv_error.phpt b/ext/spl/tests/SplFileObject_fputcsv_error.phpt index aed2a978e..8368e4211 100644 --- a/ext/spl/tests/SplFileObject_fputcsv_error.phpt +++ b/ext/spl/tests/SplFileObject_fputcsv_error.phpt @@ -2,7 +2,7 @@ SplFileObject::fputcsv(): error conditions --FILE-- <?php -$fo = new SplFileObject('SplFileObject_fputcsv.csv', 'w'); +$fo = new SplFileObject(__DIR__ . '/SplFileObject_fputcsv.csv', 'w'); echo "*** Testing error conditions ***\n"; // zero argument @@ -17,6 +17,11 @@ $enclosure ="\""; var_dump( $fo->fputcsv($fields, $delim, $enclosure, $fo) ); echo "Done\n"; +--CLEAN-- +<?php +$file = __DIR__ . '/SplFileObject_fputcsv.csv'; +unlink($file); +?> --EXPECTF-- *** Testing error conditions *** -- Testing fputcsv() with zero argument -- diff --git a/ext/spl/tests/SplFileObject_fputcsv_variation13.phpt b/ext/spl/tests/SplFileObject_fputcsv_variation13.phpt index 05f61958a..b7c2a6381 100644 --- a/ext/spl/tests/SplFileObject_fputcsv_variation13.phpt +++ b/ext/spl/tests/SplFileObject_fputcsv_variation13.phpt @@ -8,7 +8,7 @@ Test fputcsv() : usage variations - with default enclosure & delimiter of two ch echo "*** Testing fputcsv() : with default enclosure & delimiter of two chars ***\n"; -$fo = new SplFileObject('SplFileObject_fputcsv.csv', 'w'); +$fo = new SplFileObject(__DIR__ . '/SplFileObject_fputcsv.csv', 'w'); var_dump($fo->fputcsv(array('water', 'fruit'), ',,', '"')); @@ -18,7 +18,8 @@ echo "Done\n"; ?> --CLEAN-- <?php -unlink('SplFileObject::fputcsv.csv'); +$file = __DIR__ . '/SplFileObject_fputcsv.csv'; +unlink($file); ?> --EXPECTF-- *** Testing fputcsv() : with default enclosure & delimiter of two chars *** diff --git a/ext/spl/tests/SplFileObject_fputcsv_variation14.phpt b/ext/spl/tests/SplFileObject_fputcsv_variation14.phpt index 6d1cc5848..f8cda0e96 100644 --- a/ext/spl/tests/SplFileObject_fputcsv_variation14.phpt +++ b/ext/spl/tests/SplFileObject_fputcsv_variation14.phpt @@ -8,7 +8,7 @@ Test fputcsv() : usage variations - with enclosure & delimiter of two chars echo "*** Testing fputcsv() : with enclosure & delimiter of two chars and file opened in read mode ***\n"; -$fo = new SplFileObject('SplFileObject_fputcsv.csv', 'w'); +$fo = new SplFileObject(__DIR__ . '/SplFileObject_fputcsv.csv', 'w'); var_dump($fo->fputcsv(array('water', 'fruit'), ',,', '""')); @@ -18,7 +18,8 @@ echo "Done\n"; ?> --CLEAN-- <?php -unlink('SplFileObject::fputcsv.csv'); +$file = __DIR__ . '/SplFileObject_fputcsv.csv'; +unlink($file); ?> --EXPECTF-- *** Testing fputcsv() : with enclosure & delimiter of two chars and file opened in read mode *** diff --git a/ext/spl/tests/arrayObject_offsetExists_nullcheck.phpt b/ext/spl/tests/arrayObject_offsetExists_nullcheck.phpt new file mode 100644 index 000000000..1953643c8 --- /dev/null +++ b/ext/spl/tests/arrayObject_offsetExists_nullcheck.phpt @@ -0,0 +1,10 @@ +--TEST-- +SPL: ArrayObject::offsetExists() should return true for element containing NULL +--FILE-- +<?php +$ao = new ArrayObject(array('foo' => null)); +var_dump($ao->offsetExists('foo')); + +?> +--EXPECTF-- +bool(true)
\ No newline at end of file diff --git a/ext/spl/tests/bug54971.phpt b/ext/spl/tests/bug54971.phpt index 07a470627..22cdfba27 100644 --- a/ext/spl/tests/bug54971.phpt +++ b/ext/spl/tests/bug54971.phpt @@ -21,29 +21,17 @@ $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)); +print_r(array_map('get_class', iterator_to_array($items, false))); +print_r(array_map('get_class', iterator_to_array($items, true))); ?> --EXPECT-- Array ( - [0] => DOMElement Object - ( - ) - - [1] => DOMElement Object - ( - ) - + [0] => DOMElement + [1] => DOMElement ) Array ( - [0] => DOMElement Object - ( - ) - - [1] => DOMElement Object - ( - ) - + [0] => DOMElement + [1] => DOMElement ) diff --git a/ext/spl/tests/bug61326.phpt b/ext/spl/tests/bug61326.phpt new file mode 100644 index 000000000..85b577940 --- /dev/null +++ b/ext/spl/tests/bug61326.phpt @@ -0,0 +1,17 @@ +--TEST-- +Bug #61326: ArrayObject comparison +--FILE-- +<?php +$aobj1 = new ArrayObject(array(0)); +$aobj2 = new ArrayObject(array(1)); +var_dump($aobj1 == $aobj2); + +$aobj3 = new ArrayObject(array(0)); +var_dump($aobj1 == $aobj3); + +$aobj3->foo = 'bar'; +var_dump($aobj1 == $aobj3); +--EXPECT-- +bool(false) +bool(true) +bool(false) diff --git a/ext/spl/tests/bug61347.phpt b/ext/spl/tests/bug61347.phpt new file mode 100644 index 000000000..cb091858a --- /dev/null +++ b/ext/spl/tests/bug61347.phpt @@ -0,0 +1,40 @@ +--TEST-- +Bug #61347 (inconsist isset behavior of Arrayobject) +--FILE-- +<?php +$a = array('b' => NULL, 37 => NULL); +var_dump(isset($a['b'])); //false + +$b = new ArrayObject($a); +var_dump(isset($b['b'])); //false +var_dump(isset($b[37])); //false +var_dump(isset($b['no_exists'])); //false +var_dump(empty($b['b'])); //true +var_dump(empty($b[37])); //true + +var_dump(array_key_exists('b', $b)); //true +var_dump($b['b']); + +$a = array('b' => '', 37 => false); +$b = new ArrayObject($a); +var_dump(isset($b['b'])); //true +var_dump(isset($b[37])); //true +var_dump(isset($b['no_exists'])); //false +var_dump(empty($b['b'])); //true +var_dump(empty($b[37])); //true + + +--EXPECT-- +bool(false) +bool(false) +bool(false) +bool(false) +bool(true) +bool(true) +bool(true) +NULL +bool(true) +bool(true) +bool(false) +bool(true) +bool(true) diff --git a/ext/spl/tests/bug61418.phpt b/ext/spl/tests/bug61418.phpt new file mode 100644 index 000000000..c5d9db948 --- /dev/null +++ b/ext/spl/tests/bug61418.phpt @@ -0,0 +1,23 @@ +--TEST-- +Bug #61418: Segmentation fault using FiltesystemIterator & RegexIterator +--FILE-- +<?php +$fileIterator = new FilesystemIterator(__DIR__, FilesystemIterator::KEY_AS_FILENAME); +$regexpIterator = new RegexIterator($fileIterator, '#.*#'); +foreach ($fileIterator as $key => $file) +{ +} +unset($regexpIterator); +unset($fileIterator); + +$dirIterator = new DirectoryIterator(__DIR__); +$regexpIterator2 = new RegexIterator($dirIterator, '#.*#'); +foreach ($dirIterator as $key => $file) +{ +} +unset($regexpIterator2); +unset($dirIterator); +?> +==DONE== +--EXPECT-- +==DONE== diff --git a/ext/spl/tests/bug61453.phpt b/ext/spl/tests/bug61453.phpt new file mode 100644 index 000000000..e5b1387fd --- /dev/null +++ b/ext/spl/tests/bug61453.phpt @@ -0,0 +1,19 @@ +--TEST-- +Bug #61453: SplObjectStorage does not identify objects correctly +--FILE-- +<?php +$limit = 1000; +$objects = new SplObjectStorage; +for($i = 0; $i < $limit; $i++){ + $object = new StdClass; + + if(isset($objects[$object])){ + die("this should never happen, but did after $i iteration"); + } + + $objects[$object] = 1; +} +?> +==DONE== +--EXPECT-- +==DONE== diff --git a/ext/spl/tests/filesystemiterator_flags.phpt b/ext/spl/tests/filesystemiterator_flags.phpt new file mode 100644 index 000000000..635345655 --- /dev/null +++ b/ext/spl/tests/filesystemiterator_flags.phpt @@ -0,0 +1,40 @@ +--TEST-- +SPL: FilesystemIterator::getFlags() basic tests +--CREDITS-- +Joshua Thijssen <jthijssen@noxlogic.nl> +--FILE-- +<?php + +$it = new FileSystemIterator("."); +printflags($it); + +$it->setFlags(FileSystemIterator::CURRENT_AS_SELF | + FileSystemIterator::KEY_AS_FILENAME | + FileSystemIterator::SKIP_DOTS | + FileSystemIterator::UNIX_PATHS); +printflags($it); + +$it->setFlags(-1); +printflags($it); + +function printflags($it) { + printf("%08X\n", $it->getFlags()); + printf("%08X\n", ($it->getFlags() & FileSystemIterator::CURRENT_MODE_MASK)); + printf("%08X\n", ($it->getFlags() & FileSystemIterator::KEY_MODE_MASK)); + printf("%08X\n", ($it->getFlags() & FileSystemIterator::OTHER_MODE_MASK)); +} + +?> +--EXPECT-- +00001000 +00000000 +00000000 +00001000 +00003110 +00000010 +00000100 +00003000 +00003FF0 +000000F0 +00000F00 +00003000 |
