mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX: TestRunner was not cleaning up DB on failure
When a unit test being run by PHPUnit encountered a fatal error, TestRunner::tearDown was never being called. This resulted in tmpdb schemas littering the database from failed test runs. This changeset fixes the issue by registering TestRunner::tearDown as a shutdown function, so that it gets called even in the event of a PHP Fatal Error.
This commit is contained in:
parent
d1756a5a58
commit
d8b106e6ee
6
dev/TestRunner.php
Normal file → Executable file
6
dev/TestRunner.php
Normal file → Executable file
@ -315,6 +315,12 @@ class TestRunner extends Controller {
|
||||
$phpunitwrapper->setSuite($suite);
|
||||
$phpunitwrapper->setCoverageStatus($coverage);
|
||||
|
||||
// Make sure TearDown is called (even in the case of a fatal error)
|
||||
$self = $this;
|
||||
register_shutdown_function(function() use ($self) {
|
||||
$self->tearDown();
|
||||
});
|
||||
|
||||
$phpunitwrapper->runTests();
|
||||
|
||||
// get results of the PhpUnitWrapper class
|
||||
|
Loading…
Reference in New Issue
Block a user