I have a PHPUnit bootstrap file that creates a test database used for unit tests related to the database and registers a shutdown function to destroy the database after the tests are completed. New database for every launch!
Problem: when tests fail, I want to save the database for debugging purposes. Currently, I have to manually disconnect my register_shutdown_function() call and then run the tests again.
If I could access the final PHPUnit success / failure state to run, I could dynamically initiate the switch-based database destruction process in the PHPUnit bootstrap file.
PHPUnit stores this information somewhere to trigger the correct source event, i.e. exit OK vs FAILURES! . However, from what I discovered, this information does not appear on the user level boot file. Has anyone ever done anything like this?
If you want to learn, here is the PHPUnit stack trace that occurs when starting PHPUnit from the command line ...
PHP 1. {main}() /usr/bin/phpunit:0 PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46 PHP 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:130 PHP 4. PHPUnit_TextUI_Command->handleArguments() /usr/share/php/PHPUnit/TextUI/Command.php:139 PHP 5. PHPUnit_TextUI_Command->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]
source share