mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
Merge remote-tracking branch 'origin/3.0'
Conflicts: tests/model/SiteTreeTest.php
This commit is contained in:
commit
26bdee4f08
@ -7,11 +7,9 @@ class CMSMainTest extends FunctionalTest {
|
|||||||
|
|
||||||
static $fixture_file = 'CMSMainTest.yml';
|
static $fixture_file = 'CMSMainTest.yml';
|
||||||
|
|
||||||
protected $autoFollowRedirection = false;
|
|
||||||
|
|
||||||
static protected $orig = array();
|
static protected $orig = array();
|
||||||
|
|
||||||
static public function set_up_once() {
|
public function setUpOnce() {
|
||||||
self::$orig['CMSBatchActionHandler_batch_actions'] = CMSBatchActionHandler::$batch_actions;
|
self::$orig['CMSBatchActionHandler_batch_actions'] = CMSBatchActionHandler::$batch_actions;
|
||||||
CMSBatchActionHandler::$batch_actions = array(
|
CMSBatchActionHandler::$batch_actions = array(
|
||||||
'publish' => 'CMSBatchAction_Publish',
|
'publish' => 'CMSBatchAction_Publish',
|
||||||
@ -19,13 +17,13 @@ class CMSMainTest extends FunctionalTest {
|
|||||||
'deletefromlive' => 'CMSBatchAction_DeleteFromLive',
|
'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'];
|
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'));
|
$this->session()->inst_set('loggedInAs', $this->idFromFixture('Member', 'admin'));
|
||||||
|
|
||||||
$response = $this->get('admin/pages/publishall?confirm=1');
|
$response = $this->get('admin/pages/publishall?confirm=1');
|
||||||
|
|
||||||
$this->assertContains(
|
$this->assertContains(
|
||||||
'Done: Published 30 pages',
|
'Done: Published 30 pages',
|
||||||
$response->getBody()
|
$response->getBody()
|
||||||
@ -45,7 +42,7 @@ class CMSMainTest extends FunctionalTest {
|
|||||||
|
|
||||||
// Some modules (e.g., cmsworkflow) will remove this action
|
// Some modules (e.g., cmsworkflow) will remove this action
|
||||||
if(isset(CMSBatchActionHandler::$batch_actions['publish'])) {
|
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());
|
$responseData = Convert::json2array($response->getBody());
|
||||||
$this->assertArrayHasKey($page1->ID, $responseData['modified']);
|
$this->assertArrayHasKey($page1->ID, $responseData['modified']);
|
||||||
$this->assertArrayHasKey($page2->ID, $responseData['modified']);
|
$this->assertArrayHasKey($page2->ID, $responseData['modified']);
|
||||||
@ -193,6 +190,9 @@ class CMSMainTest extends FunctionalTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testCreationOfTopLevelPage(){
|
public function testCreationOfTopLevelPage(){
|
||||||
|
$origFollow = $this->autoFollowRedirection;
|
||||||
|
$this->autoFollowRedirection = false;
|
||||||
|
|
||||||
$cmsUser = $this->objFromFixture('Member', 'allcmssectionsuser');
|
$cmsUser = $this->objFromFixture('Member', 'allcmssectionsuser');
|
||||||
$rootEditUser = $this->objFromFixture('Member', 'rootedituser');
|
$rootEditUser = $this->objFromFixture('Member', 'rootedituser');
|
||||||
|
|
||||||
@ -220,9 +220,14 @@ class CMSMainTest extends FunctionalTest {
|
|||||||
$this->assertContains('/show/',$location, 'Must redirect to /show/ the new page');
|
$this->assertContains('/show/',$location, 'Must redirect to /show/ the new page');
|
||||||
// TODO Logout
|
// TODO Logout
|
||||||
$this->session()->inst_set('loggedInAs', NULL);
|
$this->session()->inst_set('loggedInAs', NULL);
|
||||||
|
|
||||||
|
$this->autoFollowRedirection = $origFollow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCreationOfRestrictedPage(){
|
public function testCreationOfRestrictedPage(){
|
||||||
|
$origFollow = $this->autoFollowRedirection;
|
||||||
|
$this->autoFollowRedirection = false;
|
||||||
|
|
||||||
$adminUser = $this->objFromFixture('Member', 'admin');
|
$adminUser = $this->objFromFixture('Member', 'admin');
|
||||||
$adminUser->logIn();
|
$adminUser->logIn();
|
||||||
|
|
||||||
@ -258,6 +263,8 @@ class CMSMainTest extends FunctionalTest {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$this->session()->inst_set('loggedInAs', NULL);
|
$this->session()->inst_set('loggedInAs', NULL);
|
||||||
|
|
||||||
|
$this->autoFollowRedirection = $origFollow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBreadcrumbs() {
|
public function testBreadcrumbs() {
|
||||||
|
@ -16,18 +16,6 @@ class SiteTreeActionsTest extends FunctionalTest {
|
|||||||
|
|
||||||
static $fixture_file = 'SiteTreeActionsTest.yml';
|
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() {
|
public function testActionsReadonly() {
|
||||||
if(class_exists('SiteTreeCMSWorkflow')) return true;
|
if(class_exists('SiteTreeCMSWorkflow')) return true;
|
||||||
|
|
||||||
|
@ -7,18 +7,6 @@ class SiteTreeBacklinksTest extends SapphireTest {
|
|||||||
'SiteTree' => array('SiteTreeBacklinksTest_DOD'),
|
'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() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
@ -6,18 +6,6 @@
|
|||||||
class SiteTreeBrokenLinksTest extends SapphireTest {
|
class SiteTreeBrokenLinksTest extends SapphireTest {
|
||||||
static $fixture_file = 'SiteTreeBrokenLinksTest.yml';
|
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() {
|
public function testBrokenLinksBetweenPages() {
|
||||||
$obj = $this->objFromFixture('Page','content');
|
$obj = $this->objFromFixture('Page','content');
|
||||||
|
|
||||||
|
@ -13,18 +13,6 @@ class SiteTreePermissionsTest extends FunctionalTest {
|
|||||||
'SiteTree' => array('SiteTreeSubsites')
|
'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() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
|
@ -20,55 +20,6 @@ class SiteTreeTest extends SapphireTest {
|
|||||||
'SiteTreeTest_StageStatusInherit',
|
'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() {
|
public function testCreateDefaultpages() {
|
||||||
$remove = DataObject::get('SiteTree');
|
$remove = DataObject::get('SiteTree');
|
||||||
if($remove) foreach($remove as $page) $page->delete();
|
if($remove) foreach($remove as $page) $page->delete();
|
||||||
|
Loading…
Reference in New Issue
Block a user