Skip to content

Commit

Permalink
Merge pull request #63 from blueo/pulls/db-connection-on-state-load
Browse files Browse the repository at this point in the history
Connect to test database on session load
  • Loading branch information
dnsl48 authored May 10, 2019
2 parents efb6777 + 075d960 commit 0c479ad
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/TestSessionHTTPMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ protected function loadTestState(HTTPRequest $request)
Email::config()->set("send_all_emails_to", null);
}

// Connect to the test session database
$this->testSessionEnvironment->connectToDatabase();

// Allows inclusion of a PHP file, usually with procedural commands
// to set up required test state. The file can be generated
// through {@link TestSessionStubCodeWriter}, and the session state
Expand All @@ -79,9 +82,6 @@ protected function loadTestState(HTTPRequest $request)
if (isset($testState->stubfile)) {
$file = $testState->stubfile;
if (!Director::isLive() && $file && file_exists($file)) {
// Connect to the database so the included code can interact with it
$this->testSessionEnvironment->connectToDatabase();

include_once($file);
}
}
Expand Down

0 comments on commit 0c479ad

Please sign in to comment.