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