/** * 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()); }
/** * 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()); }