NEW: Add status code comment to testsession/start output.

testsession/start now includes a comment of the form <!-- SUCCESS: DBNAME=DatabaseName -->,
which can be used by behat and other consumers to validate that the tesession was actually
started.

It's included the database name in its output, which is a small piece of information
disclosure, but not a big deal compared to the generally dev-only nature of this module.

It requires a fix to Cookie::set(), to ensure that set cookies also apperar immediately
in $_COOKIE.  Otherwise the call to DB::get_alternative_database_name() after it is set
won't return a value.
This commit is contained in:
Sam Minnee 2013-06-07 11:22:18 +12:00 committed by Ingo Schommer
parent 9a8d24c116
commit 78062a093c
2 changed files with 10 additions and 0 deletions

View File

@ -44,6 +44,15 @@ class TestSessionController extends Controller {
return $this->renderWith('TestSession_start');
}
public function DatabaseName() {
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(

View File

@ -1,3 +1,4 @@
<!-- SUCCESS: DBNAME=$DatabaseName -->
<p>
Started testing session.
<% if Fixture %>Loaded fixture "$Fixture" into database.<% end_if %>