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',
|
'clear',
|
||||||
);
|
);
|
||||||
|
|
||||||
|
private static $alternative_database_name = -1;
|
||||||
|
|
||||||
public function init() {
|
public function init() {
|
||||||
parent::init();
|
parent::init();
|
||||||
|
|
||||||
@ -37,6 +39,8 @@ class TestSessionController extends Controller {
|
|||||||
// Create a new one with a randomized name
|
// Create a new one with a randomized name
|
||||||
$dbname = SapphireTest::create_temp_db();
|
$dbname = SapphireTest::create_temp_db();
|
||||||
DB::set_alternative_database_name($dbname);
|
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());
|
$this->setState($request->getVars());
|
||||||
@ -44,6 +48,18 @@ class TestSessionController extends Controller {
|
|||||||
return $this->renderWith('TestSession_start');
|
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) {
|
public function set($request) {
|
||||||
if(!SapphireTest::using_temp_db()) {
|
if(!SapphireTest::using_temp_db()) {
|
||||||
throw new LogicException(
|
throw new LogicException(
|
||||||
@ -80,6 +96,8 @@ class TestSessionController extends Controller {
|
|||||||
|
|
||||||
SapphireTest::kill_temp_db();
|
SapphireTest::kill_temp_db();
|
||||||
DB::set_alternative_database_name(null);
|
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');
|
Session::clear('testsession');
|
||||||
|
|
||||||
return $this->renderWith('TestSession_end');
|
return $this->renderWith('TestSession_end');
|
||||||
@ -125,6 +143,8 @@ class TestSessionController extends Controller {
|
|||||||
throw new InvalidArgumentException("Invalid database name format");
|
throw new InvalidArgumentException("Invalid database name format");
|
||||||
}
|
}
|
||||||
DB::set_alternative_database_name($dbname);
|
DB::set_alternative_database_name($dbname);
|
||||||
|
// Workaround for bug in Cookie::get(), fixed in 3.1-rc1
|
||||||
|
self::$alternative_database_name = $dbname;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fixtures
|
// Fixtures
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
<!-- SUCCESS: DBNAME=$DatabaseName -->
|
||||||
<p>
|
<p>
|
||||||
Started testing session.
|
Started testing session.
|
||||||
<% if Fixture %>Loaded fixture "$Fixture" into database.<% end_if %>
|
<% if Fixture %>Loaded fixture "$Fixture" into database.<% end_if %>
|
||||||
|
Loading…
Reference in New Issue
Block a user