// This is avoided by throwing RequeueException for the first few calls to
// ::processItem() and then returning void. ::testRequeueException()
// establishes sanity assertions for this case.
$queue_worker_plugin->
processItem('RequeueException'
)->
will(function D
$args,
$mock,
$method) { // Fetch the number of calls to this prophesied method. This value will
// start at zero during the first call.
$method_calls =
count($mock->
findProphecyMethodCalls($method->
getMethodName(),
new ArgumentsWildcard($args)));
// Throw the expected exception on the first few calls.
if ($method_calls < self::REQUEUE_COUNT
) { \Drupal::
state()->
set('cron_test.requeue_count',
$method_calls + 1
);
throw new RequeueException();
} });
// Set the mock queue worker manager to return the definition/plugin.
$queue_worker_manager->
getDefinitions()->
willReturn([$queue_worker =>
$queue_worker_definition]);
$queue_worker_manager->
createInstance($queue_worker)->
willReturn($queue_worker_plugin->
reveal());
// Construct the Cron class to test.
$this->cron =
new Cron($module_handler->
reveal(),
$lock_backend->
reveal(),
$queue_factory->
reveal(),
$state->
reveal(),
$account_switcher->
reveal(),
$logger->
reveal(),
$queue_worker_manager->
reveal(),
$time->
reveal(),
$queueConfig);
}