Skip to content

Commit

Permalink
FIX: TestRunner was not cleaning up DB on failure
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
crgwbr authored and chillu committed Jun 23, 2013
1 parent d1756a5 commit d8b106e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions dev/TestRunner.php
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,12 @@ class_exists($className);
$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
Expand Down

0 comments on commit d8b106e

Please sign in to comment.