Beispiel #1
0
 /**
  * Test if batch can be set for an unsaved job.
  */
 public function testBatchCanBeSetForUnqueuedJob()
 {
     $batch = $this->dispatcher->batch('Testing batch');
     $this->assertEquals(1, $batch->getQueueId());
     $job = new Inc(['number' => 123]);
     $this->assertNull($job->getBatchId());
     $job->setBatch($batch);
     $this->assertEquals($batch->getQueueId(), $job->getBatchId());
 }
 /**
  * Test attempts is set using attempts data property.
  */
 public function testAttemptsIsSetUsingData()
 {
     $job = new Inc(['number' => 123, 'attempts' => 13]);
     $this->assertEquals(13, $job->getAttempts());
 }
 /**
  * Test if we can use first_attempt_delay to set a delay of the first attempt.
  */
 public function testNewJobsCanBeDelayedWithFirstAttemptExecutedNow()
 {
     $inc_job_with_no_first_attempt_delay = new Inc(['number' => 123, 'delay' => 5, 'first_attempt_delay' => 0]);
     $this->assertEquals(5, $inc_job_with_no_first_attempt_delay->getDelay());
     $this->assertEquals(0, $inc_job_with_no_first_attempt_delay->getFirstJobDelay());
     $this->assertEquals(1, $this->dispatcher->dispatch($inc_job_with_no_first_attempt_delay));
     /** @var DateTime $available_at */
     $available_at = $this->connection->executeFirstCell('SELECT `available_at` FROM `' . MySqlQueue::JOBS_TABLE_NAME . '` WHERE `id` = ?', 1);
     $this->assertInstanceOf('DateTime', $available_at);
     $this->assertLessThanOrEqual(time(), $available_at->getTimestamp());
 }
 /**
  * Test delay is set using delay data property.
  */
 public function testDelayIsSetUsingData()
 {
     $job = new Inc(['number' => 123, 'delay' => 15]);
     $this->assertEquals(15, $job->getDelay());
 }