/**
  * @test
  */
 public function eventloop_schedule()
 {
     $loop = Factory::create();
     $scheduler = new EventLoopScheduler($loop);
     $actionCalled = false;
     $action = function () use(&$actionCalled) {
         $actionCalled = true;
         return "test";
     };
     $disposable = $scheduler->schedule($action);
     $this->assertInstanceOf('Rx\\DisposableInterface', $disposable);
     $this->assertFalse($actionCalled);
     $loop->tick();
     $this->assertTrue($actionCalled);
 }
 public function testSchedulerWorkedWithScheduledEventOutsideItself()
 {
     $loop = Factory::create();
     $scheduler = new EventLoopScheduler($loop);
     $scheduler->start();
     $start = microtime(true);
     $called = null;
     $loop->addTimer(0.1, function () use($scheduler, &$called) {
         $scheduler->schedule(function () use(&$called) {
             $called = microtime(true);
         }, 100);
     });
     $loop->run();
     $this->assertEquals(0.2, $called - $start, '', 0.02);
 }