diff options
| author | Ondřej Surý <ondrej@sury.org> | 2011-02-16 10:13:02 +0100 |
|---|---|---|
| committer | Ondřej Surý <ondrej@sury.org> | 2011-02-16 10:13:02 +0100 |
| commit | fd5a0b31640419ca63d1ddeaffd6d3cf2a741814 (patch) | |
| tree | bfd17d84c5181d7b98d7d66f56573f4fc897e31c /ext/spl/tests | |
| parent | 01fcdff3849c3691d9aaeaab735846ab6d8895ca (diff) | |
| download | php-upstream/5.3.5.tar.gz | |
Imported Upstream version 5.3.5upstream/5.3.5
Diffstat (limited to 'ext/spl/tests')
| -rw-r--r-- | ext/spl/tests/SplFileObject_fgetcsv_escape_default.phpt | 24 | ||||
| -rw-r--r-- | ext/spl/tests/arrayObject_count_basic1.phpt | 8 | ||||
| -rw-r--r-- | ext/spl/tests/bug50579.phpt | 40 | ||||
| -rw-r--r-- | ext/spl/tests/bug52573.phpt | 18 | ||||
| -rw-r--r-- | ext/spl/tests/bug53071.phpt | 26 | ||||
| -rw-r--r-- | ext/spl/tests/bug53144.phpt | 20 | ||||
| -rw-r--r-- | ext/spl/tests/bug53362.phpt | 22 | ||||
| -rw-r--r-- | ext/spl/tests/fileobject_005.phpt | 6 | ||||
| -rwxr-xr-x | ext/spl/tests/spl_fileinfo_getlinktarget_basic.phpt | 2 |
9 files changed, 161 insertions, 5 deletions
diff --git a/ext/spl/tests/SplFileObject_fgetcsv_escape_default.phpt b/ext/spl/tests/SplFileObject_fgetcsv_escape_default.phpt new file mode 100644 index 000000000..b3b6c7c60 --- /dev/null +++ b/ext/spl/tests/SplFileObject_fgetcsv_escape_default.phpt @@ -0,0 +1,24 @@ +--TEST-- +SplFileObject::fgetcsv with default escape character +--FILE-- +<?php +$fp = fopen('SplFileObject::fgetcsv.csv', 'w+'); +fwrite($fp, '"aa\"","bb","\"c"'); +fclose($fp); + +$fo = new SplFileObject('SplFileObject::fgetcsv.csv'); +var_dump($fo->fgetcsv()); +?> +--CLEAN-- +<?php +unlink('SplFileObject::fgetcsv.csv'); +?> +--EXPECTF-- +array(3) { + [0]=> + string(4) "aa\"" + [1]=> + string(2) "bb" + [2]=> + string(3) "\"c" +} diff --git a/ext/spl/tests/arrayObject_count_basic1.phpt b/ext/spl/tests/arrayObject_count_basic1.phpt index 1a3b84d50..a003c2cf6 100644 --- a/ext/spl/tests/arrayObject_count_basic1.phpt +++ b/ext/spl/tests/arrayObject_count_basic1.phpt @@ -67,7 +67,9 @@ int(99) int(2) int(99) int(1) -int(1) + +Warning: ArrayObject::count() expects exactly 0 parameters, 1 given in %s on line %d +NULL ==ArrayIterator== int(99) int(0) @@ -77,4 +79,6 @@ int(99) int(2) int(99) int(1) -int(1)
\ No newline at end of file + +Warning: ArrayIterator::count() expects exactly 0 parameters, 1 given in %s on line %d +NULL
\ No newline at end of file diff --git a/ext/spl/tests/bug50579.phpt b/ext/spl/tests/bug50579.phpt new file mode 100644 index 000000000..e32262a74 --- /dev/null +++ b/ext/spl/tests/bug50579.phpt @@ -0,0 +1,40 @@ +--TEST-- +Bug #50579 (RegexIterator::REPLACE doesn't work) +--FILE-- +<?php + +class foo extends ArrayIterator { + public function __construct( ) { + parent::__construct(array( + 'test1'=>'test888', + 'test2'=>'what?', + 'test3'=>'test999')); + } +} +$h = new foo; +$i = new RegexIterator($h, '/^test(.*)/', RegexIterator::REPLACE); +$i->replacement = '[$0]'; +foreach ($i as $name=>$value) { + echo $name . '=>' . $value . "\n"; +} + +$i->replacement = '$1'; +foreach ($i as $name=>$value) { + echo $name . '=>' . $value . "\n"; +} + +$h = new foo; +$i = new RegexIterator($h, '/^test(.*)/', RegexIterator::REPLACE); +$i->replacement = '[$1]'; +foreach ($i as $name=>$value) { + echo $name . '=>' . $value . "\n"; +} + +?> +--EXPECTF-- +test1=>[test888] +test3=>[test999] +test1=>888 +test3=>999 +test1=>[888] +test3=>[999] diff --git a/ext/spl/tests/bug52573.phpt b/ext/spl/tests/bug52573.phpt new file mode 100644 index 000000000..54587fae1 --- /dev/null +++ b/ext/spl/tests/bug52573.phpt @@ -0,0 +1,18 @@ +--TEST-- +Bug #52573 (SplFileObject::fscanf Segmentation fault) +--FILE-- +<?php // test + +$result = null; +$f = new SplFileObject(__FILE__, 'r'); +var_dump($f->fscanf('<?php // %s', $result)); +var_dump($result); +var_dump($f->fscanf('<?php // %s')); +?> +--EXPECTF-- +int(1) +string(4) "test" +array(1) { + [0]=> + NULL +} diff --git a/ext/spl/tests/bug53071.phpt b/ext/spl/tests/bug53071.phpt new file mode 100644 index 000000000..b0ea3aad8 --- /dev/null +++ b/ext/spl/tests/bug53071.phpt @@ -0,0 +1,26 @@ +--TEST--
+Bug #53071 (Usage of SPLObjectStorage defeats gc_collect_cycles)
+--FILE--
+<?php
+class myClass
+{
+ public $member;
+}
+function LimitedScope()
+{
+ $myA = new myClass();
+ $myB = new SplObjectStorage();
+ $myC = new myClass();
+ $myC->member = $myA; // myC has a referece to myA
+ $myB->Attach($myC); // myB attaches myC
+ $myA->member = $myB; // myA has myB, comleting the cycle
+}
+LimitedScope();
+var_dump(gc_collect_cycles());
+
+echo "Done.\n";
+
+?>
+--EXPECTF--
+int(5)
+Done.
diff --git a/ext/spl/tests/bug53144.phpt b/ext/spl/tests/bug53144.phpt new file mode 100644 index 000000000..7cf179b3e --- /dev/null +++ b/ext/spl/tests/bug53144.phpt @@ -0,0 +1,20 @@ +--TEST-- +Bug #53144 (Segfault in SplObjectStorage::removeAll) +--FILE-- +<?php + +$o1 = new StdClass; +$o2 = new StdClass; + +$b = new SplObjectStorage(); +$b[$o1] = "bar"; +$b[$o2] = "baz"; + +var_dump(count($b)); +$b->removeAll($b); +var_dump(count($b)); + +?> +--EXPECTF-- +int(2) +int(0)
\ No newline at end of file diff --git a/ext/spl/tests/bug53362.phpt b/ext/spl/tests/bug53362.phpt new file mode 100644 index 000000000..70ba6e203 --- /dev/null +++ b/ext/spl/tests/bug53362.phpt @@ -0,0 +1,22 @@ +--TEST-- +Bug #53362 (Segmentation fault when extending SplFixedArray) +--FILE-- +<?php + +class obj extends SplFixedArray{ + public function offsetSet($offset, $value) { + var_dump($offset); + } +} + +$obj = new obj; + +$obj[]=2; +$obj[]=2; +$obj[]=2; + +?> +--EXPECTF-- +NULL +NULL +NULL diff --git a/ext/spl/tests/fileobject_005.phpt b/ext/spl/tests/fileobject_005.phpt index b3882e940..fa9e6db17 100644 --- a/ext/spl/tests/fileobject_005.phpt +++ b/ext/spl/tests/fileobject_005.phpt @@ -33,8 +33,10 @@ unlink($path); ?> --EXPECTF-- bool(true) -string(4) "blah" + +Warning: SplFileObject::fgets() expects exactly 0 parameters, 1 given in %s on line %d +NULL Warning: SplFileObject::ftruncate() expects exactly 1 parameter, 0 given in %s on line %d NULL -==DONE== +==DONE==
\ No newline at end of file diff --git a/ext/spl/tests/spl_fileinfo_getlinktarget_basic.phpt b/ext/spl/tests/spl_fileinfo_getlinktarget_basic.phpt index 399d9a31a..cee557e33 100755 --- a/ext/spl/tests/spl_fileinfo_getlinktarget_basic.phpt +++ b/ext/spl/tests/spl_fileinfo_getlinktarget_basic.phpt @@ -8,7 +8,7 @@ if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms ?> --FILE-- <?php -$link = 'test_link'; +$link = __DIR__ . '/test_link'; symlink(__FILE__, $link ); $fileInfo = new SplFileInfo($link); |
