我可以轻松检测到第一次测试:
public static $databaseMigrated = false;
protected function setUp()
{
parent::setUp();
if (TestCase::$databaseMigrated === false) {
$this->migrateDatabase();
TestCase::$databaseMigrated = true;
}
}
但有人知道如何检测上次测试吗?
protected function tearDown()
{
// something here ? ?
}
答案 0 :(得分:0)
解决方案是:
public static $databaseMigrated = false;
public function setUp()
{
parent::setUp();
if (TestCase::$databaseMigrated === false) {
TestCase::$databaseMigrated = true;
register_shutdown_function(function(){
//register wanted code here
});
});
}