Search code examples
phpcodeigniterphpunitphpstorm

PHPUnit and CodeIgniter


for a couple of days I'm trying to get PHPUnit working with Codeigniter in PHPStorm. I've installed PHPUnit via Composer and this seems to work fine on simple unit tests which don't involve CodeIgniter.

I've followed a (simple) guide on how to set up PHPUnit with Codeigniter in an IDE, found here: http://www.jamesfairhurst.co.uk/posts/view/codeigniter_phpunit_and_netbeans

But the debugger in PHPStorm keeps returning the same error, the HTML and CSS of the 404 page (of codeigniter) and 'Process finished with exit code 0'. The same goes when trying to run from the Terminal.

As described in the guide I've set up an .xml configuration file for PHPUnit wich loads an bootstrap file which should initialise Codeigniter.

<phpunit bootstrap="bootstrap.php"
     colors="true"
     convertErrorsToExceptions="true"
     convertNoticesToExceptions="true"
     convertWarningsToExceptions="true"
     processIsolation="false"
     stopOnFailure="false"
     syntaxCheck="false"
     verbose="true">
</phpunit>

I'm quite lost right now, how can I make PHPUnit work with Codeigniter in PHPStorm? I'm suspecting it has something to do with the output class. But then again, I'm new to PHPUnit and just recently started with CodeIgniter.

Any help would be welcome!


Solution

  • First of all, I feel like a real idiot. Here's how I fixed my problem:

    1. Updated XAMPP. I had PHP 5.3.1, while 5.3.3 was required for PHPUnit.
    2. I followed this guide in detail: http://www.jamesfairhurst.co.uk/posts/view/codeigniter_phpunit_and_netbeans

    The guide is written for netbeans, but works (almost) the same as PHPStorm. Works like a charm now!