Annotation of embedaddon/php/ext/standard/tests/streams/stream_get_meta_data_file_variation2.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Testing stream_get_meta_data() "unread_bytes" field
! 3: --FILE--
! 4: <?php
! 5:
! 6: $filename = __FILE__ . '.tmp';
! 7:
! 8: $fp = fopen($filename, "w+");
! 9:
! 10: echo "Write some data to the file:\n";
! 11: $i = 0;
! 12: while ($i++ < 20) {
! 13: fwrite($fp, "a line of data\n");
! 14: }
! 15:
! 16: var_dump(stream_get_meta_data($fp));
! 17:
! 18: //seek to start of file
! 19: rewind($fp);
! 20:
! 21: echo "\n\nRead a line of the file, causing data to be buffered:\n";
! 22: var_dump(fgets($fp));
! 23:
! 24: var_dump(stream_get_meta_data($fp));
! 25:
! 26: echo "\n\nRead 20 bytes from the file:\n";
! 27: fread($fp, 20);
! 28:
! 29: var_dump(stream_get_meta_data($fp));
! 30:
! 31: echo "\n\nRead entire file:\n";
! 32: while(!feof($fp)) {
! 33: fread($fp, 1);
! 34: }
! 35:
! 36: var_dump(stream_get_meta_data($fp));
! 37:
! 38: fclose($fp);
! 39:
! 40: unlink($filename);
! 41:
! 42: ?>
! 43: --EXPECTF--
! 44: Write some data to the file:
! 45: array(9) {
! 46: ["wrapper_type"]=>
! 47: string(9) "plainfile"
! 48: ["stream_type"]=>
! 49: string(5) "STDIO"
! 50: ["mode"]=>
! 51: string(2) "w+"
! 52: ["unread_bytes"]=>
! 53: int(0)
! 54: ["seekable"]=>
! 55: bool(true)
! 56: ["uri"]=>
! 57: string(%i) "%s.tmp"
! 58: ["timed_out"]=>
! 59: bool(false)
! 60: ["blocked"]=>
! 61: bool(true)
! 62: ["eof"]=>
! 63: bool(false)
! 64: }
! 65:
! 66:
! 67: Read a line of the file, causing data to be buffered:
! 68: string(15) "a line of data
! 69: "
! 70: array(9) {
! 71: ["wrapper_type"]=>
! 72: string(9) "plainfile"
! 73: ["stream_type"]=>
! 74: string(5) "STDIO"
! 75: ["mode"]=>
! 76: string(2) "w+"
! 77: ["unread_bytes"]=>
! 78: int(285)
! 79: ["seekable"]=>
! 80: bool(true)
! 81: ["uri"]=>
! 82: string(%i) "%s.tmp"
! 83: ["timed_out"]=>
! 84: bool(false)
! 85: ["blocked"]=>
! 86: bool(true)
! 87: ["eof"]=>
! 88: bool(false)
! 89: }
! 90:
! 91:
! 92: Read 20 bytes from the file:
! 93: array(9) {
! 94: ["wrapper_type"]=>
! 95: string(9) "plainfile"
! 96: ["stream_type"]=>
! 97: string(5) "STDIO"
! 98: ["mode"]=>
! 99: string(2) "w+"
! 100: ["unread_bytes"]=>
! 101: int(265)
! 102: ["seekable"]=>
! 103: bool(true)
! 104: ["uri"]=>
! 105: string(%i) "%s.tmp"
! 106: ["timed_out"]=>
! 107: bool(false)
! 108: ["blocked"]=>
! 109: bool(true)
! 110: ["eof"]=>
! 111: bool(false)
! 112: }
! 113:
! 114:
! 115: Read entire file:
! 116: array(9) {
! 117: ["wrapper_type"]=>
! 118: string(9) "plainfile"
! 119: ["stream_type"]=>
! 120: string(5) "STDIO"
! 121: ["mode"]=>
! 122: string(2) "w+"
! 123: ["unread_bytes"]=>
! 124: int(0)
! 125: ["seekable"]=>
! 126: bool(true)
! 127: ["uri"]=>
! 128: string(%i) "%s.tmp"
! 129: ["timed_out"]=>
! 130: bool(false)
! 131: ["blocked"]=>
! 132: bool(true)
! 133: ["eof"]=>
! 134: bool(true)
! 135: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>