Guide to setting up PHPUnit

For about 2 years now, I have been using Komodo IDE from ActiveState for web development, and on the whole I have been very satisfied with it. There are a couple of issues that have arisen, but normally there is some way to get around them with a minor change of workflow.
However, one issue has concisely bothered me, so I thought it was time I investigated a way to fix the issue: PHPUnit testing.
Out of the box, Komodo will not do unit testing for PHP, so the first thing I had to do was download PHPUnit. Do do this, I needed to install wget using home-brew (for more information about this, go to
So, once wget is installed, I followed the instructions on the PHPUnit website to install PHPUnit globally so that it would be accessible no matter where it was called from:

chmod +x phpunit.phar
sudo mv phpunit.phar /usr/local/bin/phpunit

Thinking that would be it, I created a small test case:

class TestClass extends PHPUnit_Framework_TestCase { 
   public function testMethod() {   

With a simple test plan:

Executing the test, however, resulted in no output. Obviously something was wrong.
After trawling through the Komodo forums and StackOverflow, and little bit of Googling… I came across an unofficial fix for this on GitHub: Komodo PHPUnit Harness
I had found other solutions, but this one seemed the simplest, and I like simple… less to go wrong.

After download the source from the github, and quickly reading the documentation, I realised that I needed to move the PHPUnit executable to part of the Komodo application package. Simply done with this:

sudo mv /usr/local/bin/phpunit '/Applications/Komodo IDE'

Note: if you are just doing this without making the mistake I originally made, you don’t need to move PHPUnit to /usr/local/bin, just copy it directly to ‘/Applications/Komodo IDE’

Then I copied the new versions of HarnessSelector.php and Printer.php into the same folder, over-writing the existing ones.

Again I tried the test plan in Komodo:

Yay! Success!

Now only two things remain:

An easy way to create unit test modules
Code completion for the unit test classes

The first part is easy. I created an empty test case class, basically the same as the class I created before. This I then saved in the templates folder: ~/Library/Application Support/KomodoIDE/9.3/templates/My Templates.
Now I can create a new test case file from the File Menu in Komodo, by selecting New->File From Template…

The code completion is a little trickier, but was still quite simple. Komodo has the ability to read in files from a folder to aid code completion. The setting for this can be found in the Preferences window of Komodo:

This setting allows us to point to the PHPUnit source, however, I didn’t have that yet… so back to Github to download the source: PHPUnit

Once I had that, and unzipped it, I wanted to keep everything neat and self contained, so I copied the relevant folder from the source to the test harness within the Komodo package. I only really needed the Framework folder in the source, so that’s all I copied to /Applications/Komodo IDE

Unfortunately, the preferences window wouldn’t allow me to select a folder within a bundle, so I ended up editing the prefs.xml stored in ~/Library/Application Support/KomodoIDE/9.3 manually. I found the String node of the XML with the id attribute of phpExtraPaths, and changed the value of that node to: /Applications/Komodo IDE

I actually did this last step twice because I had Komodo open the first time and it restored the original setting when I closed it. So, if you are doing this, make sure Komodo is not open when you edit the prefs.xml.

As you can see in the following shot, I now have code completion for PHPUnit.

The downside of all this is that I will need to redo these steps whenever Komodo IDE is updated, but it does now allow me to enjoy the benefits of unit testing in my PHP projects from within the Komodo IDE.

The original of this tutorial can be found on my blog: [Pengwin’s Dev Blog][1]

Please note: This is for the OS X version of Komodo IDE

1 Like

Thanks for sharing, you’re awesome :+1:

Just realised some of the links didn’t come through when I copied this from my blog, so here they are:

Komodo PHPUnit Harness

Downloading source from Github is a big no no. NO.
Use composer instead and install phpunit globally.

I only got the source for PHPunit from github so I could give Komodo somewhere to look for the code completion.
If you look at the beginning of the post, I followed the guidelines from the PHPUnit site to get the executable.

Even instructions in PHPUnit website are not the best.
The only way you should install every PHP third part library is composer. The only exception is composer itself.

Edit: indeed, the best way to get completion of your tests is simply requiring phpunit in your project’s composer.json.
A downside benefit is that you don’t mess with PHPUnit versions, e.g. you can get different version of PHPUnit in different projects.

Thanks for your guide! It helped me (who has next to no knowledge of PHP) update Komodo’s PHPUnit functionality. Our next version of Komodo will support PHPUnit 4+ natively.


My pleasure.

When you say “next version” are you referring to version 9.x or version 10?

The updated PHPUnit support has been slated for version 10. Sorry for the confusion.