mirror of
https://github.com/silverstripe/silverstripe-testsession
synced 2024-10-22 14:06:00 +02:00
Merge pull request #1 from sminnee/testsession-status-output
NEW: Add status code comment to testsession/start output.
This commit is contained in:
commit
2015b89474
@ -12,6 +12,8 @@ class TestSessionController extends Controller {
|
||||
'clear',
|
||||
);
|
||||
|
||||
private static $alternative_database_name = -1;
|
||||
|
||||
public function init() {
|
||||
parent::init();
|
||||
|
||||
@ -37,6 +39,8 @@ class TestSessionController extends Controller {
|
||||
// Create a new one with a randomized name
|
||||
$dbname = SapphireTest::create_temp_db();
|
||||
DB::set_alternative_database_name($dbname);
|
||||
// Workaround for bug in Cookie::get(), fixed in 3.1-rc1
|
||||
self::$alternative_database_name = $dbname;
|
||||
}
|
||||
|
||||
$this->setState($request->getVars());
|
||||
@ -44,6 +48,18 @@ class TestSessionController extends Controller {
|
||||
return $this->renderWith('TestSession_start');
|
||||
}
|
||||
|
||||
public function DatabaseName() {
|
||||
// Workaround for bug in Cookie::get(), fixed in 3.1-rc1
|
||||
if(self::$alternative_database_name != -1) {
|
||||
return self::$alternative_database_name;
|
||||
} else if ($dbname = DB::get_alternative_database_name()) {
|
||||
return $dbname;
|
||||
} else {
|
||||
$db = DB::getConn();
|
||||
if(method_exists($db, 'currentDatabase')) return $db->currentDatabase();
|
||||
}
|
||||
}
|
||||
|
||||
public function set($request) {
|
||||
if(!SapphireTest::using_temp_db()) {
|
||||
throw new LogicException(
|
||||
@ -80,6 +96,8 @@ class TestSessionController extends Controller {
|
||||
|
||||
SapphireTest::kill_temp_db();
|
||||
DB::set_alternative_database_name(null);
|
||||
// Workaround for bug in Cookie::get(), fixed in 3.1-rc1
|
||||
self::$alternative_database_name = null;
|
||||
Session::clear('testsession');
|
||||
|
||||
return $this->renderWith('TestSession_end');
|
||||
@ -125,6 +143,8 @@ class TestSessionController extends Controller {
|
||||
throw new InvalidArgumentException("Invalid database name format");
|
||||
}
|
||||
DB::set_alternative_database_name($dbname);
|
||||
// Workaround for bug in Cookie::get(), fixed in 3.1-rc1
|
||||
self::$alternative_database_name = $dbname;
|
||||
}
|
||||
|
||||
// Fixtures
|
||||
|
@ -1,3 +1,4 @@
|
||||
<!-- SUCCESS: DBNAME=$DatabaseName -->
|
||||
<p>
|
||||
Started testing session.
|
||||
<% if Fixture %>Loaded fixture "$Fixture" into database.<% end_if %>
|
||||
|
Loading…
Reference in New Issue
Block a user