Skip to main content

Writing tests for Tome

I have recently migrated my daily email archive to Drupal and Tome.

The result is the same - a static website that I can upload onto my server, but it's created with Drupal 11 locally and exported to a static website.

Similar to being able to extend Sculpin with PHP, I get the same benefit with Tome.

I can write the same PHP code and custom Drupal modules as I would with a non-Tome Drupal website.

To count the number of sent daily emails, I created a opd_daily_emails module with a token that generates the number of emails, and displays it on the page.

I can also write the same automated tests.

I have a functional test that confirms the token result is generated and rendered correctly using TokenTestTrait - supported by some kernel tests and a custom DailyEmailTestTrait that makes it easier to create daily email nodes within the tests.

I have all the power and flexibility of Drupal locally and the benefits of a static site when it's deployed.

P.S. If you want to learn how to write automated tests in Drupal, subscribe to my free 10-day email course.

About me

Picture of Oliver

I'm an certified Drupal Triple Expert with 18 years of experience, a Drupal core contributor, public speaker, live streamer, and host of the Beyond Blocks podcast.