2
因此,我有一个CodeIgniter项目,我试图使用PHPUnit。我的目录看起来像无法在测试文件夹外运行PHPUnit
application
node_modules
Gruntfile.js
scripts
vendor
tests
PostTest.php
phpunit.phar
bootstrap.php
phpunit.xml
composer.json
package.json
当我在测试文件夹内,我可以做“phpunit”。或“php phpunit.phar”。运行测试PostTest.php内和工作正常,但是当我在根文件夹,并尝试做“PHPUnit测试”,我得到的错误:
ERROR: Not Found
The controller/method pair you requested was not found.
PostTest.php
<?php
class PostTest extends PHPUnit_Framework_TestCase {
private $CI;
public function setUp() {
$this->CI = &get_instance();
}
public function testNotes() {
$this->CI->load->model('class');
$students = $this->CI->class->getStudents('11');
$this->assertEquals(3, count($students->result_array()));
}
}
phpunit.xml
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
verbose="true">
</phpunit>
没有人有任何想法,为什么我收到错误?
所以我试图将phpunit.xml移入根目录,当我这样做时,错误更改为'致命错误:调用/Applications/XAMPP/xamppfiles/htdocs/project/tests/PostTest.php中的未定义函数get_instance()在线7',我跑过这个错误之前,但我无法找出一个永久的解决方案。 – Jon
@Jon - 刚刚意识到这是CodeIgniter,我对CI项目的设置一无所知,所以我不打算。 – markdwhite