BUGFIX: Allow execution of a test without a current controller. (from r111044)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112882 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2010-10-19 03:36:12 +00:00
parent fa5db43d76
commit 67b5116702

View File

@ -134,7 +134,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
DataObject::reset();
SiteTree::reset();
Hierarchy::reset();
Controller::curr()->setSession(new Session(array()));
if(Controller::has_curr()) Controller::curr()->setSession(new Session(array()));
$this->originalTheme = SSViewer::current_theme();
@ -401,7 +401,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');