Beispiel #1
0
 public function __construct(Clock $clock)
 {
     $this->timers = new SplObjectStorage();
     $this->scheduler = new SplPriorityQueue();
     $clock->on('tick', array($this, 'tick'));
 }
Beispiel #2
0
 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);
 }
Beispiel #3
0
 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);
 }