FIX: Add workaround for Cookie bug.

This patch adds a workaround for the Cookie bug, so that we don't need 3.1+ in
order to test.
This commit is contained in:
Sam Minnee 2013-06-07 11:36:55 +12:00 committed by Ingo Schommer
parent 78062a093c
commit e326e02532

View File

@ -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());
@ -45,7 +49,10 @@ class TestSessionController extends Controller {
}
public function DatabaseName() {
if($dbname = DB::get_alternative_database_name()) {
// 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();
@ -89,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');
@ -133,6 +142,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