public function testSetTimeout() { $et = new ET(); $output = []; $et->setTimeout(function ($e) use(&$output) { $output[] = 'one'; }, 0.05); $et->setTimeout(function ($e) use(&$output) { $output[] = 'two'; }, 0.03); $et->setTimeout(function ($e) use($et) { $this->assertSame($e->originalObject, $et); }, 0.03); $this->assertSame(3, count($et->timeouts())); for ($i = 0; $i < 7; $i++) { $output[] = $i; usleep(10000); $et->tick(); } $this->assertSame(0, count($et->timeouts())); $this->assertSame($output, [0, 1, 2, 'two', 3, 4, 'one', 5, 6]); }