コード例 #1
0
 /**
  * Test that all values can be set and are returned afterwards.
  */
 public function testTaskEntityAccessors()
 {
     $createdAt = new \DateTime('yesterday');
     $updatedAt = new \DateTime();
     $entity = new TaskEntity();
     $entity->setPriority(100)->setCommandline('commandline')->setPid(1001)->setExitCode(0)->setCreatedAt($createdAt)->setUpdatedAt($updatedAt);
     $this->assertNull($entity->getId());
     $this->assertSame(100, $entity->getPriority());
     $this->assertSame('commandline', $entity->getCommandline());
     $this->assertSame(1001, $entity->getPid());
     $this->assertSame(0, $entity->getExitCode());
     $this->assertSame($createdAt, $entity->getCreatedAt());
     $this->assertSame($updatedAt, $entity->getUpdatedAt());
 }
コード例 #2
0
ファイル: Task.php プロジェクト: gravitymedia/commander
 /**
  * Prioritize task.
  *
  * @param int $priority
  *
  * @return $this
  */
 public function prioritize($priority)
 {
     $this->entity->setPriority($priority);
     $this->entityManager->flush();
     return $this;
 }
コード例 #3
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);
 }
コード例 #4
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());
 }