// Create a queue worker definition for testing purposes.
$queue_worker =
$this->
randomMachineName();
$queue_worker_definition =
[ 'id' =>
$queue_worker,
'cron' =>
[ 'time' => &
$this->claimTime,
],
];
// Create a queue instance for this queue worker.
$this->queue =
new Memory($queue_worker);
$queue_factory->
get($queue_worker)->
willReturn($this->queue
);
// Create a mock queue worker plugin instance based on above definition.
$queue_worker_plugin =
$this->
prophesize('Drupal\Core\Queue\QueueWorkerInterface'
);
$queue_worker_plugin->
getPluginId()->
willReturn($queue_worker);
$queue_worker_plugin->
getPluginDefinition()->
willReturn($queue_worker_definition);
$queue_worker_plugin->
processItem('Complete'
)->
willReturn();
$queue_worker_plugin->
processItem('Exception'
)->
willThrow(\Exception::
class);
$queue_worker_plugin->
processItem('DelayedRequeueException'
)->
willThrow(DelayedRequeueException::
class);
$queue_worker_plugin->
processItem('SuspendQueueException'
)->
willThrow(SuspendQueueException::
class);
// 'RequeueException' would normally result in an infinite loop.