Beispiel #1
0
 public function onDispatch(MvcEvent $e)
 {
     if (!$e->getRequest() instanceof ConsoleRequest) {
         throw new RuntimeException('Only requests form console are allowed.');
     }
     $this->cronService->run();
 }
Beispiel #2
0
 public function testRunWithTimeout()
 {
     $cron = $this->prophesize(Cron::class);
     $executor = $this->prophesize(Executor::class);
     $job = $this->prophesize(ShellJob::class);
     $process = $this->prophesize(Process::class);
     $cron->run()->willReturn(null);
     $cron->isRunning()->willReturn(false);
     $service = new CronService(0.5, $cron->reveal());
     $jobs = [$job->reveal()];
     $process->getCommandLine()->willReturn('ls -la');
     $job->getProcess()->willReturn($process->reveal());
     $executor->getRunningJobs()->willReturn($jobs);
     $cron->getExecutor()->willReturn($executor->reveal());
     $this->setExpectedException(TimeoutException::class);
     $service->run();
 }