Blocks
DrevOps\BehatSteps\Steps\Drupal\BlockTrait - Source, Example, Helpers
Manage Drupal blocks.
- Create and configure blocks with custom visibility conditions.
- Place blocks in regions and assert their configured region.
- Created blocks are automatically removed at the end of the scenario.
Prerequisites
| Prerequisite | Capability |
|---|---|
| A backend in the scenario's list provides "BlockCapabilityInterface" | BlockCapabilityInterface |
| The core "block" module is enabled | ModuleCapabilityInterface |
Steps
@Given the instance of the block :admin_label with the following configuration exists:
Create a block instance
Given the instance of the block "My block" with the following configuration exists:
| label | My block |
| label_display | 1 |
| region | content |
| status | 1 |
@Given the block :label has the following configuration:
Configure an existing block identified by label
Given the block "My block" has the following configuration:
| label_display | 1 |
| region | content |
| status | 1 |
@Given the block :label does not exist
Remove every block in the default theme with the label
Given the block "My block" does not exist
@Given the block :label is enabled
Enable a block specified by label
Given the block "My block" is enabled
@Given the block :label is disabled
Disable a block specified by label
Given the block "My block" is disabled
@Given the block :label has the condition :condition with the following configuration:
Set a visibility condition for a block
Given the block "My block" has the condition "request_path" with the following configuration:
| pages | /node/1\r\n/about |
| negate | 0 |
@Given the block :label has the condition :condition removed
Remove a visibility condition from the specified block
Given the block "My block" has the condition "request_path" removed
@Then the block :label should exist
Assert that a block with the specified label exists
Then the block "My block" should exist
@Then the block :label should not exist
Assert that a block with the specified label does not exist
Then the block "My block" should not exist
@Then the block :label in the region :region should exist
Assert that a block with the specified label exists in a region
Then the block "My block" in the region "content" should exist
@Then the block :label in the region :region should not exist
Assert that a block with the specified label does not exist in a region
Then the block "My block" in the region "content" should not exist