You are here

public function QueueWorkerLockedTest::testDownloadLockedQueueAcquireLockAndProcessWithException in TMGMT Extension Suite 8.3

Download queue worker: lock acquired and item is processed with exception.

File

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

Class

QueueWorkerLockedTest
Tests locked queues.

Namespace

Drupal\Tests\tmgmt_extension_suit\Kernel

Code

public function testDownloadLockedQueueAcquireLockAndProcessWithException() {
  $this
    ->expectException(Exception::class);
  $this
    ->expectExceptionMessage("Failed to process item");
  $lockId = get_class($this->downloadQueueWorker) . ':processItem';
  $this->downloadQueueWorker
    ->expects($this
    ->once())
    ->method('doProcessItem')
    ->with([
    "foo" => "bar",
  ])
    ->willThrowException(new Exception("Failed to process item"));
  $this->lockMock
    ->expects($this
    ->once())
    ->method('acquire')
    ->with($lockId, 29)
    ->willReturn(TRUE);
  $this->lockMock
    ->expects($this
    ->once())
    ->method('release');
  $this->downloadQueueWorker
    ->processItem([
    "foo" => "bar",
  ]);
}