调用codeigniter中未定义的函数get_instance
我使用Simpletest编写一个测试类。以下是我的PHP代码:调用codeigniter中未定义的函数get_instance,codeigniter,simpletest,Codeigniter,Simpletest,我使用Simpletest编写一个测试类。以下是我的PHP代码: <?php require_once '../simpletest/autorun.php'; class Exam extends UnitTestCase { private $CI; function testUser() { $this->CI = & get_instance(); $this->CI->load->model('use
<?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());
}
}
为什么get_实例未定义,如何使其可用?Simpletest不是CodeIgniter的一部分。扩展UnitTestCase不会从CI继承任何内容。也许你可以试试这个库:谢谢你的回答,我已经用过了,但是我不知道怎么做,但是当我运行文件test\u users\u model.php时,我遇到了另一个问题:致命错误:在第3行的D:\xampp\htdocs\simpleCI\tests\models\test\u users\u model.php中找不到类'codeignitrunitestcase',我不知道如何用simpletest编写一个简单的测试。你能给我看一个小的测试演示吗?你有没有得到这个问题的答案?
Fatal error: Call to undefined function get_instance() in
D:\xampp\htdocs\simpleCI\test\exam.php on line 10