title: Hook into PHPUnit overall test state at runtime
body: <p>I have a PHPUnit bootstrap file that creates a test DB used for DB-related unit tests, and registers a shutdown function to destroy the DB once the tests complete. A fresh database for every run!</p>
  
  <p>The problem: when tests fail, I want to hold onto the database for debugging purposes. At present, I have to manually disable my <code>register_shutdown_function()</code> call and then rerun the tests.</p>
  
  <p><strong>If I could access PHPUnit's final success/fail state for the run, I could dynamically trigger the database destruction process based on a switch within the PHPUnit bootstrap file.</strong></p>
  
  <p>PHPUnit stores this info somewhere in order to trigger the proper outcome event, i.e. the output <code>OK</code> vs <code>FAILURES!</code>. However from what I've uncovered, this information is not exposed to a user-level bootstrap file. Anyone ever done anything like this?</p>
  
  <p>If you want to explore, here's a stack trace of PHPUnit that occurs when you run PHPUnit from the command line...</p>
  
  <pre><code>PHP   1. {main}() /usr/bin/phpunit:0
  PHP   2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
  PHP   3. PHPUnit_TextUI_Command-&gt;run() /usr/share/php/PHPUnit/TextUI/Command.php:130
  PHP   4. PHPUnit_TextUI_Command-&gt;handleArguments() /usr/share/php/PHPUnit/TextUI/Command.php:139
  PHP   5. PHPUnit_TextUI_Command-&gt;handleBootstrap() /usr/share/php/PHPUnit/TextUI/Command.php:620
  PHP   6. PHPUnit_Util_Fileloader::checkAndLoad() /usr/share/php/PHPUnit/TextUI/Command.php:867
  PHP   7. PHPUnit_Util_Fileloader::load() /usr/share/php/PHPUnit/Util/Fileloader.php:79
  PHP   8. include_once() /usr/share/php/PHPUnit/Util/Fileloader.php:95
  PHP   9. [YOUR PHPUNIT BOOTSTRAP RUNS HERE]
  </code></pre>