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!
Unit testing is an approach to software development in which tests are written for each function in your application. If you are not familiar with the concept you might do a little googling on the subject. CodeIgniter's Unit Test class is quite simple, consisting of an evaluation function and two result functions.
withURI(string $uri) This is helpful if you need to check URI segments within your controller. The only parameter is a string representing a valid URI: <? php $results = $this->withURI('http://example.com/forums/categories') ->controller(\App\Controllers\ForumController::class) ->execute('showCategories');
The main objective of unit testing is to isolate written code to test and determine if it works as intended. Unit testing is an important step in the development process, because if done correctly, it can help detect early flaws in code which may be more difficult to find in later testing stages.
First of all, I feel like a real idiot. Here's how I fixed my problem:
The guide is written for netbeans, but works (almost) the same as PHPStorm. Works like a charm now!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With