0

我使用 Simpletest 编写了一个测试类。这是我的PHP代码:

<?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());
    }
  }

但是当我执行这个脚本时。有一个错误:

Fatal error: Call to undefined function get_instance() in 
D:\xampp\htdocs\simpleCI\test\exam.php on line 10

为什么 get_instance 未定义,我怎样才能使它可用?

4

1 回答 1

0

Simpletest 不是 CodeIgniter 的一部分。扩展 UnitTestCase 不会从 CI 继承任何东西。也许你可以试试这个库:https ://github.com/ericbarnes/codeigniter-simpletest

于 2013-11-12T09:33:58.557 回答