From 999ce51178750e7a55c8fe884af447687bbbeff0 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Tue, 23 Mar 2021 15:14:55 +0200 Subject: [PATCH] job manager test --- tests/integration/Espo/Core/Job/JobTest.php | 98 +++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 tests/integration/Espo/Core/Job/JobTest.php 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()); + } +}