Permalink
Browse files

MINOR Checking for optional classes in 'cms' module in SapphireTest

  • Loading branch information...
1 parent 1c21390 commit 6d18e3827866759c61e61e7703f32d98e641b32a @chillu chillu committed Mar 22, 2011
Showing with 13 additions and 9 deletions.
  1. +13 −9 dev/SapphireTest.php
View
@@ -128,18 +128,20 @@ function setUp() {
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 @@ function tearDown() {
// 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.

0 comments on commit 6d18e38

Please sign in to comment.