diff --git a/tests/integration/Espo/Core/Job/JobTest.php b/tests/integration/Espo/Core/Job/JobTest.php new file mode 100644 index 0000000000..673e88fc4c --- /dev/null +++ b/tests/integration/Espo/Core/Job/JobTest.php @@ -0,0 +1,98 @@ +jobManager = $this->getContainer()->get('jobManager'); + + $this->entityManager = $this->getContainer()->get('entityManager'); + } + + public function testProcessQueue() : void + { + $job = $this->entityManager->createEntity('Job', [ + 'job' => 'Dummy', + 'queue' => 'q0', + ]); + + $this->jobManager->processQueue('q0', 10); + + $jobReloaded = $this->entityManager->getEntity('Job', $job->id); + + $this->assertEquals(JobManager::SUCCESS, $jobReloaded->getStatus()); + } + + public function testRunJobById() : void + { + $job = $this->entityManager->createEntity('Job', [ + 'job' => 'Dummy', + 'status' => JobManager::READY, + ]); + + $this->jobManager->runJobById($job->id); + + $jobReloaded = $this->entityManager->getEntity('Job', $job->id); + + $this->assertEquals(JobManager::SUCCESS, $jobReloaded->getStatus()); + } + + public function testRunJobByEntity() : void + { + $job = $this->entityManager->createEntity('Job', [ + 'job' => 'Dummy', + ]); + + $this->jobManager->runJob($job); + + $jobReloaded = $this->entityManager->getEntity('Job', $job->id); + + $this->assertEquals(JobManager::SUCCESS, $jobReloaded->getStatus()); + } +}