From 6d18e3827866759c61e61e7703f32d98e641b32a Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Wed, 23 Mar 2011 11:49:44 +1300 Subject: [PATCH] MINOR Checking for optional classes in 'cms' module in SapphireTest --- dev/SapphireTest.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/dev/SapphireTest.php b/dev/SapphireTest.php index 7eb626c28..88944194c 100755 --- a/dev/SapphireTest.php +++ b/dev/SapphireTest.php @@ -128,18 +128,20 @@ class SapphireTest extends PHPUnit_Framework_TestCase { Member::set_password_validator(null); Cookie::set_report_errors(false); - RootURLController::reset(); + if(class_exists('RootURLController')) RootURLController::reset(); if(class_exists('Translatable')) Translatable::reset(); Versioned::reset(); DataObject::reset(); - SiteTree::reset(); + if(class_exists('SiteTree')) SiteTree::reset(); Hierarchy::reset(); if(Controller::has_curr()) Controller::curr()->setSession(new Session(array())); $this->originalTheme = SSViewer::current_theme(); - // Save nested_urls state, so we can restore it later - $this->originalNestedURLsState = SiteTree::nested_urls(); + if(class_exists('SiteTree')) { + // Save nested_urls state, so we can restore it later + $this->originalNestedURLsState = SiteTree::nested_urls(); + } $className = get_class($this); $fixtureFile = eval("return {$className}::\$fixture_file;"); @@ -393,11 +395,13 @@ class SapphireTest extends PHPUnit_Framework_TestCase { // Reset mocked datetime SS_Datetime::clear_mock_now(); - // Restore nested_urls state - if ( $this->originalNestedURLsState ) - SiteTree::enable_nested_urls(); - else - SiteTree::disable_nested_urls(); + if(class_exists('SiteTree')) { + // Restore nested_urls state + if ( $this->originalNestedURLsState ) + SiteTree::enable_nested_urls(); + else + SiteTree::disable_nested_urls(); + } // Stop the redirection that might have been requested in the test. // Note: Ideally a clean Controller should be created for each test.