Files
DrevOps\BehatSteps\Steps\Drupal\FileTrait - Source, Example, Helpers
Manage Drupal file entities with upload and storage operations.
- Create managed and unmanaged files with specific URIs and content.
- Verify file existence, content, and proper storage locations.
- Set up file system directories and clean up created files.
Skip processing with tag:
@behat-steps-skip:FileTrait.
Prerequisites
| Prerequisite | Capability |
|---|---|
| A backend in the scenario's list provides "FileCapabilityInterface" | FileCapabilityInterface |
| The core "file" module is enabled, for the managed file steps | ModuleCapabilityInterface |
Options
| Option | Type | Default | Tag | Description |
|---|---|---|---|---|
file.enabled | boolean | TRUE | @behat-steps-skip:FileTrait | Create the private and temporary directories before a scenario, and remove the unmanaged files it created afterwards. |
Steps
@Given the following managed files exist:
Create managed files with properties provided in the table
Given the following managed files exist:
| path | uri | status |
| document.pdf | public://document.pdf | 1 |
| image.jpg | public://images/pic.jpg| 1 |
@Given the following managed files do not exist:
Delete managed files defined by provided properties/fields
Given the following managed files do not exist:
| filename |
| myfile.jpg |
| otherfile.jpg |
Given the following managed files do not exist:
| uri |
| public://myfile.jpg |
| public://otherfile.jpg |
@Given the unmanaged file at the URI :uri exists
Create an unmanaged file
Given the unmanaged file at the URI "public://sample.txt" exists
@Given the unmanaged file at the URI :uri exists with the content :content
Create an unmanaged file with specified content
Given the unmanaged file at the URI "public://data.txt" exists with the content "Sample content"
@Then the unmanaged file at the URI :uri should exist
Assert that an unmanaged file with specified URI exists
Then the unmanaged file at the URI "public://sample.txt" should exist
@Then the unmanaged file at the URI :uri should not exist
Assert that an unmanaged file with specified URI does not exist
Then the unmanaged file at the URI "public://temp.txt" should not exist
@Then the unmanaged file at the URI :uri should contain :content
Assert that an unmanaged file exists and has specified content
Then the unmanaged file at the URI "public://config.txt" should contain "debug=true"
@Then the unmanaged file at the URI :uri should not contain :content
Assert that an unmanaged file exists and does not have specified content
Then the unmanaged file at the URI "public://config.txt" should not contain "debug=false"