@@ -167,7 +167,7 @@ public function testScheduledItemsFromOutsideOfSchedulerDontCreateExtraTimers()
167
167
$ this ->assertEquals ($ timersExecuted , 3 );
168
168
}
169
169
170
- public function testMultipleSchedulersFromOutsideInSameTickDontCreateExtraTimers ()
170
+ public function testMultipleSchedulesFromOutsideInSameTickDontCreateExtraTimers ()
171
171
{
172
172
$ timersCreated = 0 ;
173
173
$ timersExecuted = 0 ;
@@ -190,13 +190,13 @@ public function testMultipleSchedulersFromOutsideInSameTickDontCreateExtraTimers
190
190
$ scheduler ->schedule (function () {}, 25 )->dispose ();
191
191
$ scheduler ->schedule (function () {}, 24 )->dispose ();
192
192
$ scheduler ->schedule (function () {}, 23 )->dispose ();
193
- $ scheduler ->schedule (function () {}, 22 )->dispose ();
193
+ $ scheduler ->schedule (function () {}, 25 )->dispose ();
194
194
});
195
195
196
196
$ loop ->run ();
197
197
198
- $ this ->assertEquals ($ timersCreated , 3 );
199
- $ this ->assertEquals ($ timersExecuted , 3 );
198
+ $ this ->assertEquals (3 , $ timersCreated );
199
+ $ this ->assertEquals (3 , $ timersExecuted );
200
200
}
201
201
202
202
public function testThatStuffScheduledWayInTheFutureDoesntKeepTheLoopRunningIfDisposed ()
@@ -244,4 +244,23 @@ public function testThatDisposalOfSingleScheduledItemOutsideOfInvokeCancelsTimer
244
244
245
245
$ this ->assertLessThan (2 , $ endTime - $ startTime );
246
246
}
247
+
248
+ public function testScheduledItemPastNextScheduledItemKillsItOwnTimerIfItBecomesTheNextOneAndIsDisposed ()
249
+ {
250
+ $ loop = Factory::create ();
251
+ $ scheduler = new EventLoopScheduler ($ loop );
252
+
253
+ $ startTime = microtime (true );
254
+
255
+ $ scheduler ->schedule (function () {}, 30 );
256
+ $ disp = $ scheduler ->schedule (function () {}, 3000 );
257
+ $ loop ->addTimer (0.050 , function () use ($ disp ) {
258
+ $ disp ->dispose ();
259
+ });
260
+
261
+ $ loop ->run ();
262
+ $ endTime = microtime (true );
263
+
264
+ $ this ->assertLessThan (2 , $ endTime - $ startTime );
265
+ }
247
266
}
0 commit comments