Updates to Tomato RAF including NGINX && PHP
[tomato.git] / release / src / router / php / ext / standard / tests / streams / bug60455_03.phpt
blob2429d31008c191004d2c36dbf20538e5ad9058b0
1 --TEST--
2 Bug #60455: stream_get_line and 2 lines, one possibly empty
3 --FILE--
4 <?php
5 class TestStream {
6         private $lines = array();
7         private $s = 0;
8         private $eofth = 3;
9         function stream_open($path, $mode, $options, &$opened_path) {
10                         $this->lines[] = "a\n";
11                         $this->lines[] = ($path == "test://nonempty2nd" ? "b\n" : "\n");
12                         if ($path == "test://eofafter2nd")
13                                 $this->eofth = 2;
14                 return true;
15         }
16         function stream_read($count) {
17                 if (key_exists($this->s++, $this->lines))
18                         return $this->lines[$this->s - 1];
20                 return "";
21         }
22         function stream_eof() {
23                 return $this->s >= $this->eofth;
24         }
25         
28 stream_wrapper_register("test", "TestStream");
30 $f = fopen("test://nonempty2nd", "r");
31 while (!feof($f)) {
32     $line = stream_get_line($f, 99, "\n");
33     var_dump($line);
35 $f = fopen("test://", "r");
36 while (!feof($f)) {
37     $line = stream_get_line($f, 99, "\n");
38     var_dump($line);
40 $f = fopen("test://eofafter2nd", "r");
41 while (!feof($f)) {
42     $line = stream_get_line($f, 99, "\n");
43     var_dump($line);
47 --EXPECT--
48 string(1) "a"
49 string(1) "b"
50 bool(false)
51 string(1) "a"
52 string(0) ""
53 bool(false)
54 string(1) "a"
55 string(0) ""