Skip to main content

Queues

DrevOps\BehatSteps\Steps\Drupal\QueueTrait - Source, Example, Helpers

Manage and assert Drupal queue state.

  • Add items to a queue and empty queues.
  • Process queue items during tests.
  • Assert queue item counts.

Every queue a step names is deleted once the scenario finishes. Skip the deletion with @behat-steps-skip:QueueTrait.

Prerequisites​

PrerequisiteCapability
A backend in the scenario's list provides "QueueCapabilityInterface"QueueCapabilityInterface

Options​

OptionTypeDefaultTagDescription
queue.enabledbooleanTRUE@behat-steps-skip:QueueTraitDelete the queues a scenario used once it finishes.
queue.process_limitinteger1000-Maximum number of items a single queue-processing step handles.
queue.lease_timeinteger30-Time, in seconds, a claimed queue item stays leased.

Steps​

@Given the following item is in the queue :queue:

Add an item to a queue

Given the following item is in the queue "myqueue":
| data | {"nid":1} |
@Given the queue :queue is empty

Empty a queue

Given the queue "myqueue" is empty
@When the queue :queue processes :count item(s)

Process a specific number of items from a queue

When the queue "myqueue" processes 5 items
When the queue "myqueue" processes 1 item
@When the queue :queue is processed

Process all items from a queue

When the queue "myqueue" is processed
@Then the queue :queue should have :count item(s)

Assert that a queue has a specific number of items

Then the queue "myqueue" should have 5 items
Then the queue "myqueue" should have 1 item
@Then the queue :queue should be empty

Assert that a queue is empty

Then the queue "myqueue" should be empty