我正在尝试使用 PHPUnit 为 10 月 CMS 插件的自定义路由编写一些测试,但遇到了一些错误,以使测试正确运行。
每个测试单独运行时通过,但作为一个组运行时,第一个测试将通过,其余测试失败,出现 500 个错误。失败测试的错误消息是:
in Resolver.php line 44
at HandleExceptions->handleError('8', 'Undefined index: myThemeName',
'/Users/me/src/myProject/vendor/october/rain/src/Halcyon/Datasource/
Resolver.php', '44', array('name' => 'myThemeName')) in Resolver.php line
44
测试用例如下所示:
class RoutesTest extends PluginTestCase
{
protected $baseUrl = "/";
public function setUp() {
parent::setUp();
DB::beginTransaction();
}
public function tearDown()
{
DB::rollBack();
parent::tearDown();
}
public function testRootPath()
{
$response = $this->call('GET', '/');
$this->assertEquals(200, $response->status());
}
public function testIntroPath()
{
$response = $this->call('GET', '/intro');
$this->assertEquals(200, $response->status());
}
etc...
}