1
0
Fork 0
mirror of https://github.com/DanielnetoDotCom/YouPHPTube synced 2025-10-05 19:42:38 +02:00
Oinktube/vendor/react/event-loop/tests/Timer/TimersTest.php
2021-10-05 13:04:32 -03:00

40 lines
929 B
PHP

<?php
namespace React\Tests\EventLoop\Timer;
use React\Tests\EventLoop\TestCase;
use React\EventLoop\Timer\Timer;
use React\EventLoop\Timer\Timers;
class TimersTest extends TestCase
{
public function testBlockedTimer()
{
$timers = new Timers();
$timers->tick();
// simulate a bunch of processing on stream events,
// part of which schedules a future timer...
sleep(1);
$timers->add(new Timer(0.5, function () {
$this->fail("Timer shouldn't be called");
}));
$timers->tick();
$this->assertTrue(true);
}
public function testContains()
{
$timers = new Timers();
$timer1 = new Timer(0.1, function () {});
$timer2 = new Timer(0.1, function () {});
$timers->add($timer1);
self::assertTrue($timers->contains($timer1));
self::assertFalse($timers->contains($timer2));
}
}