Matt Button

Testing Kohana3 with PHPUnit

Unit testing is great, period. It allows you to test different parts of your application independently of the rest of the system. Any changes that will cause problems elsewhere can be identified almost instantly (if you’re doing it right!).

Up until recently Kohana3 was using a home-grown  module for unit testing - It was ok, but lacked some of the more advanced features of independent testing suites - however now the project has now adopted PHPUnit as its official test framework!

PHPUnit is one of the more popular testing suites for PHP, it has full support for FixturesMock ObjectsCode Coverage and a lot of other cool stuff.

The module only requires a few changes to the bootstrap in order to integrate Kohana with PHPUnit, and afterwards you can run tests from the cli, IDE or our custom web runner. All available tests are loaded from Kohana’s cascading filesystem and can be filtered using PHPUnit’s –group switch.

Go and git it while it’s hot!