问题
I can easily detect first test:
public static $databaseMigrated = false;
protected function setUp()
{
parent::setUp();
if (TestCase::$databaseMigrated === false) {
$this->migrateDatabase();
TestCase::$databaseMigrated = true;
}
}
But does anybody have idea how to detect last test ?
protected function tearDown()
{
// something here ? ?
}
回答1:
Solution is:
public static $databaseMigrated = false;
public function setUp()
{
parent::setUp();
if (TestCase::$databaseMigrated === false) {
TestCase::$databaseMigrated = true;
register_shutdown_function(function(){
//register wanted code here
});
});
}
来源:https://stackoverflow.com/questions/37485223/how-to-detect-last-test-from-testcase-in-laravel