Drupal 8 Forms and TDD, part 3: form validation

  • Drupal 8
  • Automated Testing
  • Wisdom
  • PHP

In part 1, I showed how you can start using TDD when writing Drupal code, and how to apply it to testing a custom file validation callback. In part 2, we tackled testing the form building. In this part, I'll show how you can test the form validation.

I also decided to shoot a quick bonus video with a functional test, to demonstrate the difference in time execution. Food for thought: in our particular example, the functional tests take ~300x longer than the unit tests, without adding any more value. As I mention towards the end, you could probably get that down to “only” 60x times longer, at the cost of maintainability.

Links

Enjoyed this post? Grab the RSS feed or follow me on Twitter!

Found a typo ? Correct it, submit a pull-request and get credited here!