The WebApp Wizard Web development made magical


PHPUnit / Zend Studio 7 configuration

Everybody knows about unit testing. Some people know about PHPUnit, a unit testing library for PHP. There are people who tried it, and among those, people who where disappointed because they didn't manage to get it to work.

Well, I almost fell into this last category. But then I found the solution.

If, like me, you're using Zend Studio, that's no big deal, really. But here are a few pointers that might help you achieving your goal.

First, you'll have to install and configure ZendDebugger.

Once you managed to debug and profile a few pages, you can go on and try the following:

Good news! PHPUnit is already installed with Zend Studio 7, so you just have to play with the configuration.

Right click on your project, then "Properties", then go under the "PHP Include Path" section.

Click "Add Library"

Chose "PHPUnit 3.x"

Click "Next", then "Finish"

Zend Studio searches for the PHPUnit installation and sets the include path automatically.

You should see something like this now:

That's it, you can start writing your unit tests right now and run them right away.

If you're lucky, you might stop reading here. But if, like me, you're not (or, more likely, you mis configured something), you might have an error like "Session could not be started. In order to generate debug information, please make sure that the debugger is properly configured as a php.ini directive."

Maybe the following will help:

Go under "Run" -> "Run configurations..."

Go under the "PHP Scripts" tab

In the "PHP Executable" section, you must chose the right version of PHP, in CGI mode

Now you should be able to run your unit tests. :-)

Comments (1) Trackbacks (2)
  1. Hallo, Ich finde den Aufbau der Seite sehr gut. Macht weiter so.

Leave a comment


You can use basic HTML to enlighten your comments. If you want to post some code, please use the <pre> tag. You can also use syntax coloring by adding class="syntax [language]". <pre class="syntax js"> will color your code as if it was JS code for instance.