TimersTest.php 705 B

123456789101112131415161718192021222324252627282930
  1. <?php
  2. namespace React\Tests\EventLoop\Timer;
  3. use React\Tests\EventLoop\TestCase;
  4. use React\EventLoop\Timer\Timer;
  5. use React\EventLoop\Timer\Timers;
  6. class TimersTest extends TestCase
  7. {
  8. public function testBlockedTimer()
  9. {
  10. $loop = $this
  11. ->getMockBuilder('React\EventLoop\LoopInterface')
  12. ->getMock();
  13. $timers = new Timers();
  14. $timers->tick();
  15. // simulate a bunch of processing on stream events,
  16. // part of which schedules a future timer...
  17. sleep(1);
  18. $timers->add(new Timer($loop, 0.5, function () {
  19. $this->fail("Timer shouldn't be called");
  20. }));
  21. $timers->tick();
  22. }
  23. }