It obscures the fact that you're in a test session
by hiding it away in system folders. Having it in assets/
is confusing enough if your webroot isn't writeable.
/cc @wilr
I'd rather have Session::get('TestSessionId') being passed in
as an identifier, but the env object is passed around so much
as a singleton that its easy to forget that argument,
and cause hard to debug errors. We need a global "app" object
which all other objects can reference somehow.
In memory state can get out of date between CLI and web requests,
leading to hard to debug errors. The performance impact of this
should be low, given the size of the JSON file.
This is a major refactoring of the testsession module to use a persistent file
storage instead of using $_SESSION storage. The primary reason for this is for
out-of-band tests (e.g. simplifying Behat tests, and testing modules like
silverstripe-resque (https://github.com/stojg/silverstripe-resque)). Testing
the silverstripe-resque module without this is impossible as the PHP code
running the job has been started and loaded into memory long before you started
a testsession.
By default, this will create a TESTS_RUNNING.json file in your webroot, which
means that tests need to be run as a user who has permission to create files
there. In practice, this means your webroot needs to be owned by your webserver
user. The reason we store the file here is that it will show up as a changed
file in version control, so it’s more prominent if developers can’t figure out
why there are issues with database content.
API CHANGES:
- Add persistent file storage (using webroot/TESTS_RUNNING.json) as a base.
- Update TestSessionController to use new TestSessionEnvironment class.
- Moved extension points from TestSessionController to TestSessionEnvironment.
- Moved loadFixtureIntoDb from TestSessionController to TestSessionEnvironment.
- Moved setState from TestSessionController to TestSessionEnvironment.
- Deprecated the use of TestSessionController::setState()
FIXES:
- Fixes TestSessionRequestFilter to use new TestSessionEnvironment instead of
$_SESSION.
MINOR:
- Renamed TestSesssionRequestFilter.php to fix spelling error (three ’S’s)
- Class did not need renaming, just the file itself.