protected function tearDown() { foreach ($this->tmpFiles as $eachFile) { @unlink($eachFile); } $this->tmpFiles = array(); // Only commit if the transaction hasn't failed. // This is because tearDown() is also executed on a failed tests, // and we don't want to call ConnectionInterface::commit() in that case // since it will trigger an exception on its own // ('Cannot commit because a nested transaction was rolled back') if (null !== $this->con) { if ($this->con->isCommitable()) { $this->con->commit(); } $this->con = null; } }