PHPUnit testing bootstrap improvements
What I Did
-
Don’t redirect when migrations are out of date for unit tests -
Don’t use database sessions when running unit tests -
Throw a PHPUnit_Framework_Exception
instead of redirecting so you can track why PHPUnit silently stopped executing
Implications
It's possible that someone might want to legitimately test that the redirect function was called. I'm not sure & haven't tested how this might work, but there may be a way to mock the redirect function or something. In any case, you wouldn't be cant test the redirect function in this way without something similar even before this patch.
Testing
Easiest way to test is against the AFES PHPUnit tests: feature/unit_testing
. Completely empty the afes_unit_testing
database and try run the unit tests. Before this patch, this would silently fail.
-
Ensure that the unit tests populate the database and complete successfully -
Add a test with a call to redirect
and check that execution stops, but prints anWarning
to the terminal.