コード例 #1
0
 /**
  * Test that the task runner runs all tasks in quiet mode.
  */
 public function testTaskRunnerRunsAllTasksInQuietMode()
 {
     $connection = $this->createMock(Connection::class);
     $entityManager = $this->createMock(EntityManagerInterface::class);
     $entityManager->expects($this->any())->method('getConnection')->will($this->returnValue($connection));
     $entityOne = new TaskEntity();
     if ('WIN' === strtoupper(substr(PHP_OS, 0, 3))) {
         $entityOne->setCommandline('dir');
     } else {
         $entityOne->setCommandline('ls -l');
     }
     $entityTwo = new TaskEntity();
     $entityTwo->setCommandline('foobarbaz');
     $taskManager = $this->createMock(TaskManager::class);
     $taskManager->expects($this->exactly(3))->method('findNextTask')->will($this->onConsecutiveCalls(new Task($entityManager, $entityOne), new Task($entityManager, $entityTwo), null));
     $output = $this->createMock(OutputInterface::class);
     $output->expects($this->atLeastOnce())->method('isQuiet')->will($this->returnValue(true));
     $logger = $this->createMock(LoggerInterface::class);
     $logger->expects($this->atLeastOnce())->method('log');
     $taskRunner = new TaskRunner($taskManager, $output, $logger);
     $taskRunner->runAll(60);
     $this->assertInternalType('integer', $entityOne->getPid());
     $this->assertEquals(0, $entityOne->getExitCode());
 }
コード例 #2
0
 /**
  * Create and persist new task.
  *
  * @param string   $commandline
  * @param int|null $priority
  *
  * @return Task
  */
 public function newTask($commandline, $priority = null)
 {
     if (null === $priority) {
         $priority = TaskEntity::DEFAULT_PRIORITY;
     }
     $entity = new TaskEntity();
     $entity->setCommandline($commandline);
     $entity->setPriority($priority);
     $this->entityManager->persist($entity);
     $this->entityManager->flush();
     return new Task($this->entityManager, $entity);
 }
コード例 #3
0
 /**
  * Test that the next entity can be found by commandline.
  */
 public function testFindingNextByCommandline()
 {
     $entityManager = $this->getEntityManager();
     $entityOne = new TaskEntity();
     $entityOne->setPriority(1000);
     $entityOne->setCommandline('foo');
     $entityTwo = new TaskEntity();
     $entityTwo->setPriority(1);
     $entityTwo->setCommandline('bar');
     $entityManager->persist($entityOne);
     $entityManager->persist($entityTwo);
     $entityManager->flush();
     $class = $entityManager->getClassMetadata(TaskEntity::class);
     $repository = new TaskEntityRepository($entityManager, $class);
     $entity = $repository->findNextByCommandline('foo');
     $this->assertInstanceOf(TaskEntity::class, $entity);
     $this->assertSame('foo', $entity->getCommandline());
 }