我有以下测试/文件夹:
测试/
ClassOne.test.php
ClassTwo.test.php
ClassThree.test.php
我必须将以下内容setUp()和tearDown()方法复制到每个文件中:
公共函数设置()
{
$this->dbTestData();
}
公共函数拆解()
{
$this->dbClear();
}
私有函数 dbTestData() {
// 用一些条目填充数据库
实体\AutocompleteValue::create(array('field_name' => 'testing1', 'entry_value' => 'Aisforapple'));
实体\AutocompleteValue::create(array('field_name' => 'testing2', 'entry_value' => 'Bisforball'));
实体\AutocompleteValue::create(array('field_name' => 'testing3', 'entry_value' => 'Cisforcat'));
实体\AutocompleteValue::create(array('field_name' => 'testing4', 'entry_value' => 'Disfordog'));
}
私有函数 dbClear() {
DB::table('autocomplete_values')->delete();
}
我考虑编写一个单独的类,其中包含这些方法、require()每个测试文件中的该文件,并从该类扩展而不是PHPUnit_Framework_Testcase. 有没有更简单的解决方案?
我无法轻松访问phpunit.xml,因为我的编码框架的 CLI 工具(Laravel,artisan)处理它的创建。因此,如果有不涉及该文件的解决方案会更好。