function testLoop() { $callable = function () { }; $loop = new Loop(); $loop->addCallback($callable); $loop->addInterval(0.1, $callable); $loop->addPeriodic(new \DateTime(), new \DateTime(), 1, $callable); $loop->addSignal(SIGCHLD, $callable); $loop->addScheduled(new \DateTime(), $callable); $this->assertSame(count($loop), 5); $this->assertInstanceOf('PBergman\\EventLoop\\Watchers\\CallbackWatcher', $loop->peekBottom()); $this->assertInstanceOf('PBergman\\EventLoop\\Watchers\\ScheduledWatcher', $loop->peekTop()); $loop->filter(function ($w) { return $w instanceof \PBergman\EventLoop\Watchers\CallbackWatcher; }); $this->assertSame(count($loop), 1); $loop->run(2); $this->assertSame($loop->getTicks(), 2); }