File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -1214,6 +1214,31 @@ function testLoopStopPreventsTimerExecution()
1214
1214
$ this ->assertTrue ($ t + 0.1 > microtime (1 ));
1215
1215
}
1216
1216
1217
+ function testDeferEnabledInNextTick () {
1218
+ $ tick = function () {
1219
+ $ this ->loop ->defer (function () {
1220
+ $ this ->loop ->stop ();
1221
+ });
1222
+ $ this ->loop ->run ();
1223
+ };
1224
+
1225
+ $ invoked = 0 ;
1226
+
1227
+ $ repeat = $ this ->loop ->repeat ($ delay = 0 , function () use (&$ invoked ) {
1228
+ $ invoked ++;
1229
+ });
1230
+
1231
+ $ tick ();
1232
+ $ tick ();
1233
+ $ tick ();
1234
+
1235
+ $ this ->loop ->disable ($ repeat );
1236
+ $ this ->loop ->enable ($ repeat );
1237
+ $ tick (); // disable + immediate enable after a tick should have no effect either
1238
+
1239
+ $ this ->assertEquals (4 , $ invoked );
1240
+ }
1241
+
1217
1242
// getState and setState are final, but test it here again to be sure
1218
1243
function testRegistry () {
1219
1244
$ this ->assertNull ($ this ->loop ->getState ("foo " ));
You can’t perform that action at this time.
0 commit comments