public function __construct(Clock $clock) { $this->timers = new SplObjectStorage(); $this->scheduler = new SplPriorityQueue(); $clock->on('tick', array($this, 'tick')); }
public function testBlockWithoutTimerIsNotBlocking() { $clock = new Clock(new Pulse()); $start = microtime(true); $clock->block(); $duration = microtime(true) - $start; $this->assertGreaterThan(0, $duration); $this->assertLessThan(0.001, $duration); }
public function testTickShouldNotEmitIfResumed() { $clock = new Clock($this->getPulseMock()); $boolean = false; $clock->on('tick', function () use(&$boolean) { $boolean = true; }); $clock->pause(); $clock->resume(); $clock->tick(); $this->assertTrue($boolean); }