silverstripe-testsession/code/TestSesssionRequestFilter.php
Ingo Schommer 81d39c2350 NEW Write PHP code for later inclusion
Useful for out-of-process stubs with Behat+Selenium
2013-11-27 19:29:44 +01:00

23 lines
736 B
PHP

<?php
/**
* 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
* set through {@link TestSessionController->set()} and the
* 'testsessio.stubfile' state parameter.
*/
class TestSessionRequestFilter {
public function preRequest($req, $session, $model) {
$file = $session->inst_get('testsession.stubfile');
if(!Director::isLive() && $file && file_exists($file)) {
// Connect to the database so the included code can interact with it
global $databaseConfig;
if ($databaseConfig) DB::connect($databaseConfig);
include_once($file);
}
}
public function postRequest() {
}
}