1
我有一個文件,一個包括像這樣的:讓phpunit忽略include?
file.php
include(dirname(__FILE__)."/anotherfile.php");
class file {
function myfunction() {
$class = new anotherfile();
$class->functionfromanotherfile();
}
function myfunctionToBeTested() {
// do things here
}
}
我使用特拉維斯慈運行我與PHPUnit測試,問題是,我不提交「anotherfile.php」(具有連接到數據庫的邏輯和證書),這使得我試圖在測試腳本中包含此文件時無法工作。
tests.php
class tests extends PHPUnit_Framework_TestCase {
public function test_function() {
include(dirname(__FILE__)."/file.php");
$class = new file();
}
}
我可以做另外一個文件,只有我需要測試,並用它去,但也許你們可以拿出其他awnser功能。