You are here

public function QueueWorkerLockedTest::testUploadLockedQueueAcquireLockAndProcessWithException in TMGMT Extension Suite 8.3

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

File

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

Class

QueueWorkerLockedTest
Tests locked queues.

Namespace

Drupal\Tests\tmgmt_extension_suit\Kernel

Code

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