From 075d960e5d33ffe024eb9aeff0abc09117394a82 Mon Sep 17 00:00:00 2001 From: Bernard Hamlin Date: Wed, 13 Mar 2019 09:15:10 +1300 Subject: [PATCH] Connect to test database on session load --- src/TestSessionHTTPMiddleware.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/TestSessionHTTPMiddleware.php b/src/TestSessionHTTPMiddleware.php index 6dd69e0..c031558 100644 --- a/src/TestSessionHTTPMiddleware.php +++ b/src/TestSessionHTTPMiddleware.php @@ -71,6 +71,9 @@ class TestSessionHTTPMiddleware implements HTTPMiddleware 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 @@ -79,9 +82,6 @@ class TestSessionHTTPMiddleware implements HTTPMiddleware 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); } }