/** * This is run after each unit test. It empties the database. */ protected function tearDown() { // 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 ($this->con->isCommitable()) { $this->con->commit(); } $this->con = null; }