diff --git a/tests/controller/CMSMainTest.php b/tests/controller/CMSMainTest.php index 01813b15..ade03182 100644 --- a/tests/controller/CMSMainTest.php +++ b/tests/controller/CMSMainTest.php @@ -7,11 +7,9 @@ class CMSMainTest extends FunctionalTest { static $fixture_file = 'CMSMainTest.yml'; - protected $autoFollowRedirection = false; - static protected $orig = array(); - static public function set_up_once() { + public function setUpOnce() { self::$orig['CMSBatchActionHandler_batch_actions'] = CMSBatchActionHandler::$batch_actions; CMSBatchActionHandler::$batch_actions = array( 'publish' => 'CMSBatchAction_Publish', @@ -19,13 +17,13 @@ class CMSMainTest extends FunctionalTest { 'deletefromlive' => 'CMSBatchAction_DeleteFromLive', ); - parent::set_up_once(); + parent::setUpOnce(); } - static public function tear_down_once() { + public function tearDownOnce() { CMSBatchActionHandler::$batch_actions = self::$orig['CMSBatchActionHandler_batch_actions']; - parent::tear_down_once(); + parent::tearDownOnce(); } /** @@ -37,7 +35,6 @@ class CMSMainTest extends FunctionalTest { $this->session()->inst_set('loggedInAs', $this->idFromFixture('Member', 'admin')); $response = $this->get('admin/pages/publishall?confirm=1'); - $this->assertContains( 'Done: Published 30 pages', $response->getBody() @@ -45,7 +42,7 @@ class CMSMainTest extends FunctionalTest { // Some modules (e.g., cmsworkflow) will remove this action if(isset(CMSBatchActionHandler::$batch_actions['publish'])) { - $response = Director::test('admin/pages/batchactions/publish', array('csvIDs' => implode(',', array($page1->ID, $page2->ID)), 'ajax' => 1), $this->session()); + $response = $this->get('admin/pages/batchactions/publish?ajax=1&csvIDs=' . implode(',', array($page1->ID, $page2->ID))); $responseData = Convert::json2array($response->getBody()); $this->assertArrayHasKey($page1->ID, $responseData['modified']); $this->assertArrayHasKey($page2->ID, $responseData['modified']); @@ -193,6 +190,9 @@ class CMSMainTest extends FunctionalTest { } public function testCreationOfTopLevelPage(){ + $origFollow = $this->autoFollowRedirection; + $this->autoFollowRedirection = false; + $cmsUser = $this->objFromFixture('Member', 'allcmssectionsuser'); $rootEditUser = $this->objFromFixture('Member', 'rootedituser'); @@ -220,9 +220,14 @@ class CMSMainTest extends FunctionalTest { $this->assertContains('/show/',$location, 'Must redirect to /show/ the new page'); // TODO Logout $this->session()->inst_set('loggedInAs', NULL); + + $this->autoFollowRedirection = $origFollow; } public function testCreationOfRestrictedPage(){ + $origFollow = $this->autoFollowRedirection; + $this->autoFollowRedirection = false; + $adminUser = $this->objFromFixture('Member', 'admin'); $adminUser->logIn(); @@ -258,6 +263,8 @@ class CMSMainTest extends FunctionalTest { ); $this->session()->inst_set('loggedInAs', NULL); + + $this->autoFollowRedirection = $origFollow; } public function testBreadcrumbs() { diff --git a/tests/model/SiteTreeActionsTest.php b/tests/model/SiteTreeActionsTest.php index 4a29ac62..e457d0b7 100644 --- a/tests/model/SiteTreeActionsTest.php +++ b/tests/model/SiteTreeActionsTest.php @@ -16,18 +16,6 @@ class SiteTreeActionsTest extends FunctionalTest { static $fixture_file = 'SiteTreeActionsTest.yml'; - static public function set_up_once() { - SiteTreeTest::set_up_once(); - - parent::set_up_once(); - } - - static public function tear_down_once() { - SiteTreeTest::tear_down_once(); - - parent::tear_down_once(); - } - public function testActionsReadonly() { if(class_exists('SiteTreeCMSWorkflow')) return true; diff --git a/tests/model/SiteTreeBacklinksTest.php b/tests/model/SiteTreeBacklinksTest.php index ff5f089e..9a4b58e8 100644 --- a/tests/model/SiteTreeBacklinksTest.php +++ b/tests/model/SiteTreeBacklinksTest.php @@ -7,18 +7,6 @@ class SiteTreeBacklinksTest extends SapphireTest { 'SiteTree' => array('SiteTreeBacklinksTest_DOD'), ); - static public function set_up_once() { - SiteTreeTest::set_up_once(); - - parent::set_up_once(); - } - - static public function tear_down_once() { - SiteTreeTest::tear_down_once(); - - parent::tear_down_once(); - } - public function setUp() { parent::setUp(); diff --git a/tests/model/SiteTreeBrokenLinksTest.php b/tests/model/SiteTreeBrokenLinksTest.php index 5333f3ab..ee8e763e 100644 --- a/tests/model/SiteTreeBrokenLinksTest.php +++ b/tests/model/SiteTreeBrokenLinksTest.php @@ -6,18 +6,6 @@ class SiteTreeBrokenLinksTest extends SapphireTest { static $fixture_file = 'SiteTreeBrokenLinksTest.yml'; - static public function set_up_once() { - SiteTreeTest::set_up_once(); - - parent::set_up_once(); - } - - static public function tear_down_once() { - SiteTreeTest::tear_down_once(); - - parent::tear_down_once(); - } - public function testBrokenLinksBetweenPages() { $obj = $this->objFromFixture('Page','content'); diff --git a/tests/model/SiteTreePermissionsTest.php b/tests/model/SiteTreePermissionsTest.php index 0992306e..582395c3 100644 --- a/tests/model/SiteTreePermissionsTest.php +++ b/tests/model/SiteTreePermissionsTest.php @@ -13,18 +13,6 @@ class SiteTreePermissionsTest extends FunctionalTest { 'SiteTree' => array('SiteTreeSubsites') ); - static public function set_up_once() { - SiteTreeTest::set_up_once(); - - parent::set_up_once(); - } - - static public function tear_down_once() { - SiteTreeTest::tear_down_once(); - - parent::tear_down_once(); - } - public function setUp() { parent::setUp(); diff --git a/tests/model/SiteTreeTest.php b/tests/model/SiteTreeTest.php index f60f8f54..b556b781 100644 --- a/tests/model/SiteTreeTest.php +++ b/tests/model/SiteTreeTest.php @@ -20,55 +20,6 @@ class SiteTreeTest extends SapphireTest { 'SiteTreeTest_StageStatusInherit', ); - /** - * @todo Necessary because of monolithic Translatable design - */ - static protected $origTranslatableSettings = array(); - - static public function set_up_once() { - // needs to recreate the database schema with language properties - self::kill_temp_db(); - - // store old defaults - if(class_exists('Translatable')) { - self::$origTranslatableSettings['has_extension'] = singleton('SiteTree')->hasExtension('Translatable'); - self::$origTranslatableSettings['default_locale'] = Translatable::default_locale(); - - // overwrite locale - Translatable::set_default_locale("en_US"); - - // refresh the extended statics - different fields in $db with Translatable enabled - if(self::$origTranslatableSettings['has_extension']) { - SiteTree::remove_extension('Translatable'); - SiteConfig::remove_extension('Translatable'); - } - } - - // recreate database with new settings - $dbname = self::create_temp_db(); - DB::set_alternative_database_name($dbname); - - parent::set_up_once(); - } - - static public function tear_down_once() { - if(class_exists('Translatable')) { - if(self::$origTranslatableSettings['has_extension']) { - SiteTree::add_extension('Translatable'); - SiteConfig::add_extension('Translatable'); - } - - - Translatable::set_default_locale(self::$origTranslatableSettings['default_locale']); - Translatable::set_current_locale(self::$origTranslatableSettings['default_locale']); - } - - self::kill_temp_db(); - self::create_temp_db(); - - parent::tear_down_once(); - } - public function testCreateDefaultpages() { $remove = DataObject::get('SiteTree'); if($remove) foreach($remove as $page) $page->delete();