BuiltByCactus

Engineering Handbook

Testing

Themes

Unless there are complex sections of code, but these probably belong in a plugin, themes won’t be unit tested. Generally they’re not complex enough to require it. This may change on a project by project basis but this will be discussed beforehand.

Plugins

Plugins will generally require some form of unit testing. This helps us stop regressions when maintaining or building plugins.

There’s a great resource on unit testing plugins available here.

PHPUnit

PHPUnit can be downloaded and set up as per the instructions in the Tools section.

Unit tests should be grouped by application module, so one class is one module tested.

Behat

Behat is a BDD testing framework for PHP. We generally use this when testing APIs or complex pages.

The documentation is a great place to get an idea of how it works and Phil Sturgeon’s Build APIs You Won’t Hate is a great resource for learning about API builds and automated testing using Behat.