mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
add test for bug 27508
This commit is contained in:
parent
9187fc4fc0
commit
867e619154
69
ext/standard/tests/file/bug27508.phpt
Normal file
69
ext/standard/tests/file/bug27508.phpt
Normal file
@ -0,0 +1,69 @@
|
||||
--TEST--
|
||||
Bug #27508 (userspace wrappers have bogus eof indicator)
|
||||
--FILE--
|
||||
<?php # vim:ft=php
|
||||
class FileStream {
|
||||
public $fp;
|
||||
|
||||
function stream_open($path, $mode, $options, &$opened_path)
|
||||
{
|
||||
$url = urldecode(substr($path, 9));
|
||||
$this->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
|
Loading…
Reference in New Issue
Block a user