How to implement unit testing Model in PHPUnit with Codeigniter

This topic is related to my last topic on How to Implement unit testing Controller in PHPUnit with Codeigniter.

First, creating a model file name Result.php. In this file will contain only one function call get_result.

Result.php

Let’s use the same controller as we use in my previous topic. This time we will implement new function call get_message that call the Result model.

Hello.php

Creating a new test file in application/tests/models call Result_test. The test function can be implemented as follows:

It’s Easy As Pie !

:)