public function DatabaseBackendTest::testQueueCleanup in Advanced Queue 8
@covers ::cleanupQueue
File
- tests/
src/ Kernel/ DatabaseBackendTest.php, line 204
Class
- DatabaseBackendTest
- @coversDefaultClass \Drupal\advancedqueue\Plugin\AdvancedQueue\Backend\Database @group advancedqueue
Namespace
Drupal\Tests\advancedqueue\KernelCode
public function testQueueCleanup() {
$job = Job::create('simple', [
'test' => '1',
]);
$this->firstQueue
->getBackend()
->enqueueJob($job);
// Update the job to match how it will look when claimed.
$job
->setState(Job::STATE_PROCESSING);
$job
->setExpiresTime(635814000 + 5);
$claimed_job = $this->firstQueue
->getBackend()
->claimJob();
$this
->assertEquals($job, $claimed_job);
$this
->rewindTime(635814000 + 6);
$this
->assertNull($this->firstQueue
->getBackend()
->claimJob());
// Running cleanup should expire the lease, making it possible to claim
// the job for processing again.
$this->firstQueue
->getBackend()
->cleanupQueue();
$job
->setExpiresTime(635814000 + 6 + 5);
$claimed_job = $this->firstQueue
->getBackend()
->claimJob();
$this
->assertEquals($job, $claimed_job);
}