Given how WordPress is written and how it interacts with a database and given how its not very much OOP oriented, is there a way to unit test a theme? is there a way unit test a framework (not a theme framework) that interacts with WordPress, that is, for example, can you write a unit test for dealing with the loop, dealing with the widgets?
If so does any one have any examples? I know how to write unit tests, but I have never tried to write one for a theme.
Thoughts?
There is nothing stopping you from writing your own unit testing for themes/plugins using PHPUnit or some other testing platform.
As for WordPress, it has an official Unit Tests here:
- http://unit-tests.svn.wordpress.org/trunk/
- https://github.com/kurtpayne/wordpress-unit-tests (github mirror)
There are several build scripts that can automate unit testing found here, including WP-CLI that have built in unit testing, though you have to obviously write your own code.
I also found this plugin today via scibu’s twitter rant 🙂
http://wordpress.org/extend/plugins/razor/
There are a few more in the repo:
http://wordpress.org/extend/plugins/tags/phpunit
Also check out this: Tutorials for Unit-Testing in WordPress and for unit-test.svn.wordpress.org?