@@ -40,6 +40,85 @@ public function testStreamSelectTimeoutEmulation()
40
40
$ this ->assertGreaterThan (0.04 , $ interval );
41
41
}
42
42
43
+ public function testStreamSelectReportsWarningForStreamWithFilter ()
44
+ {
45
+ if (defined ('HHVM_VERSION ' )) {
46
+ $ this ->markTestSkipped ('Not supported on legacy HHVM ' );
47
+ }
48
+
49
+ $ stream = tmpfile ();
50
+ stream_filter_append ($ stream , 'string.rot13 ' );
51
+
52
+ $ this ->loop ->addReadStream ($ stream , $ this ->expectCallableNever ());
53
+
54
+ $ loop = $ this ->loop ;
55
+ $ this ->loop ->futureTick (function () use ($ loop , $ stream ) {
56
+ $ loop ->futureTick (function () use ($ loop , $ stream ) {
57
+ $ loop ->removeReadStream ($ stream );
58
+ });
59
+ });
60
+
61
+ $ error = null ;
62
+ $ previous = set_error_handler (function ($ _ , $ errstr ) use (&$ error ) {
63
+ $ error = $ errstr ;
64
+ });
65
+
66
+ try {
67
+ $ this ->loop ->run ();
68
+ } catch (\ValueError $ e ) {
69
+ // ignore ValueError for PHP 8+ due to empty stream array
70
+ }
71
+
72
+ restore_error_handler ();
73
+
74
+ $ this ->assertNotNull ($ error );
75
+
76
+ $ now = set_error_handler (function () { });
77
+ restore_error_handler ();
78
+ $ this ->assertEquals ($ previous , $ now );
79
+ }
80
+
81
+ public function testStreamSelectThrowsWhenCustomErrorHandlerThrowsForStreamWithFilter ()
82
+ {
83
+ if (defined ('HHVM_VERSION ' )) {
84
+ $ this ->markTestSkipped ('Not supported on legacy HHVM ' );
85
+ }
86
+
87
+ $ stream = tmpfile ();
88
+ stream_filter_append ($ stream , 'string.rot13 ' );
89
+
90
+ $ this ->loop ->addReadStream ($ stream , $ this ->expectCallableNever ());
91
+
92
+ $ loop = $ this ->loop ;
93
+ $ this ->loop ->futureTick (function () use ($ loop , $ stream ) {
94
+ $ loop ->futureTick (function () use ($ loop , $ stream ) {
95
+ $ loop ->removeReadStream ($ stream );
96
+ });
97
+ });
98
+
99
+ $ previous = set_error_handler (function ($ _ , $ errstr ) {
100
+ throw new \RuntimeException ($ errstr );
101
+ });
102
+
103
+ $ e = null ;
104
+ try {
105
+ $ this ->loop ->run ();
106
+ restore_error_handler ();
107
+ $ this ->fail ();
108
+ } catch (\RuntimeException $ e ) {
109
+ restore_error_handler ();
110
+ } catch (\ValueError $ e ) {
111
+ restore_error_handler (); // PHP 8+
112
+ $ e = $ e ->getPrevious ();
113
+ }
114
+
115
+ $ this ->assertInstanceOf ('RuntimeException ' , $ e );
116
+
117
+ $ now = set_error_handler (function () { });
118
+ restore_error_handler ();
119
+ $ this ->assertEquals ($ previous , $ now );
120
+ }
121
+
43
122
public function signalProvider ()
44
123
{
45
124
return array (
0 commit comments