You are here

public function QueueWorkerLockedTest::testDownloadLockedDoNotProcessQueueIfLockIsAlreadyAcquired in TMGMT Extension Suite 8.3

Download queue worker: do not process queue if lock is already acquired.

File

tests/src/Kernel/QueueWorkerLockedTest.php, line 235

Class

QueueWorkerLockedTest
Tests locked queues.

Namespace

Drupal\Tests\tmgmt_extension_suit\Kernel

Code

public function testDownloadLockedDoNotProcessQueueIfLockIsAlreadyAcquired() {
  $lockId = get_class($this->downloadQueueWorker) . ':processItem';
  $this->downloadQueueWorker
    ->expects($this
    ->never())
    ->method('doProcessItem');
  $this->lockMock
    ->expects($this
    ->once())
    ->method('acquire')
    ->with($lockId, 29)
    ->willReturn(FALSE);
  $this->lockMock
    ->expects($this
    ->never())
    ->method('release');
  try {
    $this->downloadQueueWorker
      ->processItem([
      "foo" => "bar",
    ]);
  } catch (RequeueException $e) {
    $this
      ->assertEquals("Attempting to re-acquire {$lockId}.", $e
      ->getMessage());
  }
}