@@ -24,45 +24,87 @@ class test_wrapper {
24
24
}
25
25
}
26
26
27
- var_dump (stream_wrapper_register ('test ' , 'test_wrapper ' ));
27
+ var_dump (stream_wrapper_register ('testlocal ' , 'test_wrapper ' ));
28
+ var_dump (stream_wrapper_register ('testurl ' , 'test_wrapper ' , STREAM_IS_URL ));
28
29
29
- $ f = fopen ("test://foo " ,"r " );
30
+ foreach (['testlocal ' , 'testurl ' ] as $ stream_type ) {
31
+ $ f = fopen ("$ stream_type://foo " ,"r " );
30
32
31
- /* when the chunk size is 1, the read buffer is skipped, but the
32
- * the writes are made in chunks of size 1 (business as usual)
33
- * This should probably be revisited */
34
- echo "should return previous chunk size (8192) \n" ;
35
- var_dump (stream_set_chunk_size ($ f , 1 ));
36
- echo "should be read without buffer ( \$count == 10000) \n" ;
37
- var_dump (strlen (fread ($ f , 10000 )));
38
- echo "should have no effect on writes \n" ;
39
- var_dump (fwrite ($ f , str_repeat ('b ' , 3 )));
33
+ /* when the chunk size is 1, the read buffer is skipped, but the
34
+ * writes are made in chunks of size 1 (business as usual)
35
+ * This should probably be revisited */
36
+ echo "should return previous chunk size (8192) \n" ;
37
+ var_dump (stream_set_chunk_size ($ f , 1 ));
38
+ echo "should be read without buffer ( \$count == 10000) \n" ;
39
+ var_dump (strlen (fread ($ f , 10000 )));
40
+ echo "should have no effect on writes \n" ;
41
+ var_dump (fwrite ($ f , str_repeat ('b ' , 3 )));
40
42
41
- echo "should return previous chunk size (1) \n" ;
42
- var_dump (stream_set_chunk_size ($ f , 100 ));
43
- echo "should elicit one read of size 100 (chunk size) \n" ;
44
- var_dump (strlen (fread ($ f , 250 )));
45
- echo "should elicit one read of size 100 (chunk size) \n" ;
46
- var_dump (strlen (fread ($ f , 50 )));
47
- echo "should elicit no read because there is sufficient cached data \n" ;
48
- var_dump (strlen (fread ($ f , 50 )));
49
- echo "should have no effect on writes \n" ;
50
- var_dump (strlen (fwrite ($ f , str_repeat ('b ' , 250 ))));
43
+ echo "should return previous chunk size (1) \n" ;
44
+ var_dump (stream_set_chunk_size ($ f , 100 ));
45
+ if ($ stream_type === 'testurl ' ) {
46
+ echo "should elicit one read of size 100 (chunk size) \n" ;
47
+ var_dump (strlen (fread ($ f , 250 )));
48
+ echo "should elicit one read of size 100 (chunk size) \n" ;
49
+ var_dump (strlen (fread ($ f , 50 )));
50
+ echo "should elicit no read because there is sufficient cached data \n" ;
51
+ var_dump (strlen (fread ($ f , 50 )));
52
+ } else { // testlocal
53
+ echo "should elicit 3 reads of size 100 (chunk size) \n" ;
54
+ var_dump (strlen (fread ($ f , 250 )));
55
+ echo "should not elicit a read \n" ;
56
+ var_dump (strlen (fread ($ f , 50 )));
57
+ echo "should elicit a read because there is insufficient cached data \n" ;
58
+ var_dump (strlen (fread ($ f , 50 )));
59
+ }
60
+ echo "should have no effect on writes \n" ;
61
+ var_dump (strlen (fwrite ($ f , str_repeat ('b ' , 250 ))));
51
62
52
- echo "\nerror conditions \n" ;
53
- try {
54
- stream_set_chunk_size ($ f , 0 );
55
- } catch (ValueError $ exception ) {
56
- echo $ exception ->getMessage () . "\n" ;
57
- }
58
- try {
59
- stream_set_chunk_size ($ f , -1 );
60
- } catch (ValueError $ exception ) {
61
- echo $ exception ->getMessage () . "\n" ;
63
+ echo "\nerror conditions \n" ;
64
+ try {
65
+ stream_set_chunk_size ($ f , 0 );
66
+ } catch (ValueError $ exception ) {
67
+ echo $ exception ->getMessage () . "\n" ;
68
+ }
69
+ try {
70
+ stream_set_chunk_size ($ f , -1 );
71
+ } catch (ValueError $ exception ) {
72
+ echo $ exception ->getMessage () . "\n" ;
73
+ }
74
+
75
+ fclose ($ f );
62
76
}
63
77
?>
64
78
--EXPECT--
65
79
bool(true)
80
+ bool(true)
81
+ should return previous chunk size (8192)
82
+ int(8192)
83
+ should be read without buffer ($count == 10000)
84
+ read with size: 10000
85
+ int(10000)
86
+ should have no effect on writes
87
+ write with size: 3
88
+ int(3)
89
+ should return previous chunk size (1)
90
+ int(1)
91
+ should elicit 3 reads of size 100 (chunk size)
92
+ read with size: 100
93
+ read with size: 100
94
+ read with size: 100
95
+ int(250)
96
+ should not elicit a read
97
+ int(50)
98
+ should elicit a read because there is insufficient cached data
99
+ read with size: 100
100
+ int(50)
101
+ should have no effect on writes
102
+ write with size: 250
103
+ int(3)
104
+
105
+ error conditions
106
+ stream_set_chunk_size(): Argument #2 ($size) must be greater than 0
107
+ stream_set_chunk_size(): Argument #2 ($size) must be greater than 0
66
108
should return previous chunk size (8192)
67
109
int(8192)
68
110
should be read without buffer ($count == 10000)
0 commit comments