[英]Simpletest Cannot redeclare simpletest_autorun()
在MyTest.php中運行的Simpletest測試沒有錯誤:
require_once ('simpletest/autorun.php');
class MyTest extends UnitTestCase {
function test() {
//Test...
}
}
一個SimpleTest測試套件
require_once ('simpletest/autorun.php');
class AllTests extends TestSuite {
function __construct() {
$this->TestSuite('All tests');
$this->addFile('MyTest.php');
}
}
錯誤:
致命錯誤:無法在/Library/WebServer/Documents/options/tests/simpletest/autorun.php中重新聲明/Library/WebServer/Documents/options/tests/simpletest/autorun.php中的simpletest_autorun()(先前在/Library/WebServer/Documents/Options/tests/simpletest/autorun.php:26中聲明) 34
(可怕的)解決方案,將MyTest.php更改為:
if (!function_exists("simpletest_autorun")) {
require_once ('simpletest/autorun.php');
}
class MyTest extends UnitTestCase {
function test() {
//Test...
}
}
看來此示例遵循了文檔,不是嗎或SimpleTest是否存在此錯誤?
我只能假設您有SimpleTest autorun.php
腳本的多個副本。
在測試用例文件中執行require
嘗試包括第二個autorun.php
文件(與測試套件中包含的文件不同simpletest_autorun()
,該文件第二次定義了simpletest_autorun()
。
行號不匹配的事實增加了我的假設的可信度。
查看錯誤消息中的完整路徑 ,應該可以告訴您最新情況。
確定要保留的副本並刪除另一個副本,更新代碼或配置中的所有不正確路徑,包括php.ini
的include_path
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.