Skip to content

Commit 3b797b9

Browse files
author
Andrew Minerd
committed
add test for #42 (timer added after blocking event handler)
1 parent cbab35f commit 3b797b9

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

tests/Timer/TimersTest.php

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

0 commit comments

Comments
 (0)