From: Wez Furlong Date: Wed, 11 May 2005 02:01:44 +0000 (+0000) Subject: add test for bug 27508 X-Git-Tag: php-5.0.1b1~259 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=867e61915471847b1a23238635c4411649cec2ea;p=php add test for bug 27508 --- diff --git a/ext/standard/tests/file/bug27508.phpt b/ext/standard/tests/file/bug27508.phpt new file mode 100644 index 0000000000..5374a0dcbc --- /dev/null +++ b/ext/standard/tests/file/bug27508.phpt @@ -0,0 +1,69 @@ +--TEST-- +Bug #27508 (userspace wrappers have bogus eof indicator) +--FILE-- +fp = fopen($url, $mode); + + return true; + } + + function stream_read($count) + { + return fread($this->fp, $count); + } + + function stream_write($data) + { + return fwrite($this->fp, $data); + } + + function stream_tell() + { + return ftell($this->fp); + } + + function stream_eof() + { + return feof($this->fp); + } + + function stream_seek($offset, $whence) + { + return fseek($this->fp, $offset, $whence) == 0 ? true : false; + } +} + +stream_wrapper_register("myFile", "FileStream") + or die("Failed to register protocol"); + +$tn = tempnam('/tmp', 'foo'); + +$fp = fopen("myFile://" . urlencode($tn), "w+"); + +fwrite($fp, "line1\n"); +fwrite($fp, "line2\n"); +fwrite($fp, "line3\n"); + +debug_zval_dump(feof($fp)); +rewind($fp); +echo ftell($fp) . "\n"; +debug_zval_dump(feof($fp)); +while (!feof($fp)) { + echo fgets($fp); +} +fclose($fp); + +unlink($tn); +--EXPECT-- +bool(false) refcount(1) +0 +bool(false) refcount(1) +line1 +line2 +line3