Skip to content

Commit c29941d

Browse files
ivkalitajsor
authored andcommitted
Add StreamSelectLoop test for timer with small interval.
1 parent 9504651 commit c29941d

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/StreamSelectLoopTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use React\EventLoop\LoopInterface;
66
use React\EventLoop\StreamSelectLoop;
7+
use React\EventLoop\Timer\Timer;
78

89
class StreamSelectLoopTest extends AbstractLoopTest
910
{
@@ -145,4 +146,34 @@ protected function forkSendSignal($signal)
145146
die();
146147
}
147148
}
149+
150+
/**
151+
* https://github.com/reactphp/event-loop/issues/48
152+
*
153+
* Tests that timer with very small interval uses at least 1 microsecond
154+
* timeout.
155+
*/
156+
public function testSmallTimerInterval()
157+
{
158+
/** @var StreamSelectLoop|\PHPUnit_Framework_MockObject_MockObject $loop */
159+
$loop = $this->getMock('React\EventLoop\StreamSelectLoop', ['streamSelect']);
160+
$loop
161+
->expects($this->at(0))
162+
->method('streamSelect')
163+
->with([], [], 1);
164+
$loop
165+
->expects($this->at(1))
166+
->method('streamSelect')
167+
->with([], [], 0);
168+
169+
$callsCount = 0;
170+
$loop->addPeriodicTimer(Timer::MIN_INTERVAL, function() use (&$loop, &$callsCount) {
171+
$callsCount++;
172+
if ($callsCount == 2) {
173+
$loop->stop();
174+
}
175+
});
176+
177+
$loop->run();
178+
}
148179
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy