An example of test case in n CodeIgniter.
class Testcase extends CI_Controller
{
public function get_testcase(){
$this ->load ->view('view_testcase');
}
}
To run Codeigniter PHPunit testing, add the above code in testcase.php file. Now, create checkunit_text.php to test the get_testcase() by adding this code:
class Checkunit_test extends UnitTest
{
public function unit_test_check()
{
$output=$this -> request('GET',['Testcase','get_testcase']);
$expected = 'Unit Test';
$this -> assertContains($expected,$output);
}
}
Use this code to create view
<?php
define('BASEPATH') OR exit('access not allowed');
?>
Now run the test
type the command $cd application/testcase/(application folder name) command to run the test → $ phpunit –phpunit