25 lines
1,020 B
Text
25 lines
1,020 B
Text
Use Drupal Test Traits
|
|
|
|
Date: 2025-06-10
|
|
|
|
Status: accepted
|
|
|
|
Context:
|
|
|
|
Drupal Test Traits is a module that provides a number of traits to make it easier to write automated tests for an existing website.
|
|
|
|
Decision:
|
|
|
|
Adopt Drupal Test Traits for any custom module tests that won't be contributed back to Drupal.org - e.g. the opd_presentations module.
|
|
|
|
Consequences:
|
|
|
|
Using Drupal Test Traits will make it simpler to write tests without needing to create test-specific modules that only create configuration like content types and fields.
|
|
|
|
In some cases, I will need to change the approach for a test.
|
|
|
|
For example, I can't create a single presentation node in a test and assert there is only one presentation as there will be existing presentations in the database.
|
|
|
|
Also, because Tome automatically exports content to JSON files, it will export any content created within the tests.
|
|
|
|
I'll need to reset the files within the `content` directory and run `drush tome:import` to reset the database with the required content.
|