我的PHP项目有一些测试。我的测试:
class myTests extends PHPunit_Framework_Testcase{
public function testValidateInventoryNumber(){
include('includes/functions.php');
$con = connectToDatabase();
$resultTest1 = validateInventoryNumber("001234", $con);
$this->assertEquals("001234", $resultTest1['data']);
}
public function testValidateLabel(){
include('includes/functions.php');
$resultTest1 = validateLabel("Sample Label.");
$this->assertEquals("Sample Label.", $resultTest1['data']);
}
}
功能
validateInventoryNumber()
和
validateLabel()
在中声明
includes/functions.php
,所以我需要在两个测试中都包含此文件,对吗?
如果要运行测试文件,则会出现以下错误:
Fatal error: Cannot redeclare connectToDatabase() (previously declared in C:\xampp\htdocs\prototype\includes\functions.php:4) in C:\xampp\htdocs\prototype\includes\functions.php on line 10
我认为这与测试开始时的include有关,因为如果我注释掉其中一个测试,它就会正常工作。你知道怎么修复吗?