I use Simpletest to write a test class. Here is my PHP code:
<?php
require_once '../simpletest/autorun.php';
class Exam extends UnitTestCase {
private $CI;
function testUser() {
$this->CI = & get_instance();
$this->CI->load->model('user_model');
$this->assertTrue($this->CI->user_model->listAll());
}
}
But when I excute this script. There's an error:
Fatal error: Call to undefined function get_instance() in
D:\xampp\htdocs\simpleCI\test\exam.php on line 10
Why is get_instance undefined and how can I make it available?
Simpletest is not part of CodeIgniter. Extending UnitTestCase won't inherit anything from CI. Maybe you can try this library:https://github.com/ericbarnes/codeigniter-simpletest