public function testcheckExecutions()
 {
     $config = new LoopConfig();
     $event = new LoopEvent($this->getMock(LoopInterface::class), $config);
     $config->setRepeat(10);
     $this->assertNull($this->instance->checkExecutions($event));
     $this->assertAttributeEquals(1, 'executions', $this->instance);
     $this->setExpectedException(LoopException::class);
     $config->setRepeat(1);
     $this->instance->checkExecutions($event);
 }
 public function testSleep()
 {
     $config = new LoopConfig();
     $event = new LoopEvent($this->getMock(LoopInterface::class), $config);
     $time = microtime(true);
     $this->instance->sleep($event);
     $this->assertGreaterThanOrEqual(microtime(true), $time + 0.01);
     $config->setInterval(100);
     $time = microtime(true);
     $this->instance->sleep($event);
     $this->assertGreaterThanOrEqual(microtime(true), $time + 0.15);
 }
Beispiel #3
0
 /**
  * attach listeners from config to event emitter
  */
 private function attachListeners()
 {
     foreach ($this->config->getListeners() as $listener) {
         if (is_string($listener)) {
             $listener = new $listener();
         }
         $listener->attach($this->emitter);
     }
 }
Beispiel #4
0
 /**
  * @dataProvider listenerErrorDataProvider
  */
 public function testListenerAccessorErrors($listener)
 {
     $this->setExpectedException(LogicException::class);
     $this->instance->addListener($listener);
 }