使phpunit忽略包括?
我有一个文件,其中有一个包含,如下所示: file.php使phpunit忽略包括?,php,phpunit,travis-ci,Php,Phpunit,Travis Ci,我有一个文件,其中有一个包含,如下所示: file.php include(dirname(_文件)。“/anotherfile.php”); 类文件{ 函数myfunction(){ $class=新的另一个文件(); $class->functionfromanotherfile(); } 函数myfunctionToBeTested(){ //在这里做事 } } 我正在使用travis ci使用phpunit运行测试,问题是我没有提交“anotherfile.php”(具有连接到数据库的
include(dirname(_文件)。“/anotherfile.php”);
类文件{
函数myfunction(){
$class=新的另一个文件();
$class->functionfromanotherfile();
}
函数myfunctionToBeTested(){
//在这里做事
}
}
我正在使用travis ci使用phpunit运行测试,问题是我没有提交“anotherfile.php”(具有连接到数据库的逻辑和凭据),这使得我尝试在测试脚本中包含此文件时无法工作
tests.php
类测试扩展了PHPUnit_框架_测试用例{
公共功能测试_函数(){
包括(dirname(_文件)“/FILE.php”);
$class=新文件();
}
}
我可以用我需要测试的功能制作另一个文件,但也许你们可以使用其他awnser。使用某种:
- 修改要测试的类,使其接受凭据作为构造函数的参数
- 在测试中,创建假的或真的凭据,并将它们传递给类的构造函数
- 修改要测试的类,使其接受凭据作为构造函数的参数
- 在测试中,创建假的或真的凭据,并将它们传递给类的构造函数