BUGFIX: Allow execution of a test without a current controller.

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@111044 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2010-09-21 20:29:09 +00:00 committed by Sam Minnee
parent 1b5ec9bd50
commit 23590932fa

View File

@ -126,7 +126,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
Versioned::reset();
DataObject::reset();
SiteTree::reset();
Controller::curr()->setSession(new Session(array()));
if(Controller::has_curr()) Controller::curr()->setSession(new Session(array()));
$this->originalTheme = SSViewer::current_theme();
@ -393,7 +393,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
// Stop the redirection that might have been requested in the test.
// Note: Ideally a clean Controller should be created for each test.
// Now all tests executed in a batch share the same controller.
$controller = Controller::curr();
$controller = Controller::has_curr() ? Controller::curr() : null;
if ( $controller && $controller->response && $controller->response->getHeader('Location') ) {
$controller->response->setStatusCode(200);
$controller->response->removeHeader('Location');