Esempio n. 1
0
 /**
  * Test that the task can be created.
  */
 public function testTaskCreation()
 {
     $entityManager = $this->createMock(EntityManagerInterface::class);
     $entity = $this->createMock(TaskEntity::class);
     $task = new Task($entityManager, $entity);
     $this->assertSame($entity, $task->getEntity());
 }
Esempio n. 2
0
 /**
  * Run single task.
  *
  * @param Task $task
  * @param int  $timeout
  *
  * @return void
  */
 public function run($task, $timeout)
 {
     $process = new Process($task->getEntity()->getCommandline());
     $process->setTimeout($timeout);
     $process->start($this);
     $task->defer($process->getPid(), function () use($process) {
         $process->wait($this);
         return $process->getExitCode();
     });
 }