TDD With Joomla 3.2
- Category: Developers
- Published on Saturday, 08 March 2014 10:21
- Written by row1
- Hits: 5242
I have just started a new version of my Simple Review component for Joomla 3.2. This time to enable more assurance of quality and rapid development/changes I have decided to use Test-driven Development.
Joomla is quite a massive system, and in order to be able to write any tests you need to load a lot of the Joomla framework, so you need to create a bootstrap file for PHPUnit. I found a good blog post to get me started, but it didn't quite work for me (there were some problems with the defines and includes). The actual Joomla github project also has a bootstrap file that again doesn't quite work for me. So after learning from both resources, I was able to come up with the following configuration.
When running PHPUnit it is important to add the --stderr flag (php phpunit.phar --stderr mytests.php), otherwise you will get the following error:
session_start(): Cannot send session cookie - headers already sent by
So far I seem to have added everything required to bootstrap Joomla 3.2 successfully, but it is early days and you can keep track of my progress on my GitHub project.
The PHPUnit setup is shown in the bellow gist: