public function FeatureContext::cleanupQueue in Open Social 10.3.x
Same name and namespace in other branches
- 10.0.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::cleanupQueue()
- 10.1.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::cleanupQueue()
- 10.2.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::cleanupQueue()
Remove any queue items that were created.
@AfterScenario
File
- tests/
behat/ features/ bootstrap/ FeatureContext.php, line 758
Class
- FeatureContext
- Defines application features from the specific context.
Namespace
Drupal\social\BehatCode
public function cleanupQueue(AfterScenarioScope $scope) {
$workerManager = \Drupal::service('plugin.manager.queue_worker');
/** @var Drupal\Core\Queue\QueueFactory; $queue */
$queue = \Drupal::service('queue');
foreach ($workerManager
->getDefinitions() as $name => $info) {
/** @var Drupal\Core\Queue\QueueInterface $worker */
$worker = $queue
->get($name);
if ($worker
->numberOfItems() > 0) {
while ($item = $worker
->claimItem()) {
// If we don't just delete them, process the item first.
$worker
->deleteItem($item);
}
}
}
}