public function ProcessorTest::testRetry in Advanced Queue 8
@covers ::processQueue
@dataProvider retryJobProvider
File
- tests/
src/ Kernel/ ProcessorTest.php, line 110
Class
- ProcessorTest
- @coversDefaultClass \Drupal\advancedqueue\Processor @group advancedqueue
Namespace
Drupal\Tests\advancedqueue\KernelCode
public function testRetry(Job $job) {
$this->queue
->enqueueJob($job);
// Confirm that the job has been requeued.
$num_processed = $this->processor
->processQueue($this->queue);
$this
->assertEquals(1, $num_processed);
$counts = $this->queue
->getBackend()
->countJobs();
$this
->assertEquals([
Job::STATE_QUEUED => 1,
], array_filter($counts));
// Confirm that the job is skipped due to $retry_delay.
$num_processed = $this->processor
->processQueue($this->queue);
$this
->assertEquals(0, $num_processed);
// Confirm that the job was re-processed, and left after the $retry_limit.
sleep(1);
$num_processed = $this->processor
->processQueue($this->queue);
$this
->assertEquals(1, $num_processed);
$counts = $this->queue
->getBackend()
->countJobs();
$this
->assertEquals([
Job::STATE_FAILURE => 1,
], array_filter($counts));
/** @var \Drupal\Core\Database\Connection $connection */
$connection = $this->container
->get('database');
$raw_jobs = $connection
->query('SELECT job_id, state, num_retries FROM {advancedqueue}')
->fetchAllAssoc('job_id', \PDO::FETCH_ASSOC);
$this
->assertEquals([
'job_id' => '1',
'state' => Job::STATE_FAILURE,
'num_retries' => 1,
], $raw_jobs[1]);
}