문제

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top