mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Fixed SiteTreeActionsTest to use unconditional class defintion - was failing due to recent changes in ClassInfo and class_exists()
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@83969 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
26d7985877
commit
9ae437e577
@ -12,102 +12,104 @@
|
|||||||
* @package sapphire
|
* @package sapphire
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
*/
|
*/
|
||||||
if(class_exists('SiteTreeCMSWorkflow')) {
|
class SiteTreeActionsTest extends FunctionalTest {
|
||||||
class SiteTreeActionsTest extends FunctionalTest {
|
|
||||||
function testDummy() {}
|
static $fixture_file = 'sapphire/tests/SiteTreeActionsTest.yml';
|
||||||
}
|
|
||||||
} else {
|
function testActionsNewPage() {
|
||||||
class SiteTreeActionsTest extends FunctionalTest {
|
if(class_exists('SiteTreeCMSWorkflow')) return true;
|
||||||
|
|
||||||
|
$className = 'Page';
|
||||||
|
$page = new $className();
|
||||||
|
$page->Title = 'New ' . $className;
|
||||||
|
$page->URLSegment = "new-" . strtolower($className);
|
||||||
|
$page->ClassName = $className;
|
||||||
|
$page->ParentID = 0;
|
||||||
|
$page->ID = 'new-Page-1';
|
||||||
|
|
||||||
static $fixture_file = 'sapphire/tests/SiteTreeActionsTest.yml';
|
$author = $this->objFromFixture('Member', 'cmseditor');
|
||||||
|
$this->session()->inst_set('loggedInAs', $author->ID);
|
||||||
|
|
||||||
function testActionsNewPage() {
|
$actionsArr = $page->getCMSActions()->column('Name');
|
||||||
$className = 'Page';
|
|
||||||
$page = new $className();
|
|
||||||
$page->Title = 'New ' . $className;
|
|
||||||
$page->URLSegment = "new-" . strtolower($className);
|
|
||||||
$page->ClassName = $className;
|
|
||||||
$page->ParentID = 0;
|
|
||||||
$page->ID = 'new-Page-1';
|
|
||||||
|
|
||||||
$author = $this->objFromFixture('Member', 'cmseditor');
|
|
||||||
$this->session()->inst_set('loggedInAs', $author->ID);
|
|
||||||
|
|
||||||
$actionsArr = $page->getCMSActions()->column('Name');
|
|
||||||
|
|
||||||
$this->assertContains('action_save',$actionsArr);
|
|
||||||
$this->assertContains('action_publish',$actionsArr);
|
|
||||||
$this->assertNotContains('action_unpublish',$actionsArr);
|
|
||||||
$this->assertContains('action_delete',$actionsArr);
|
|
||||||
$this->assertNotContains('action_deletefromlive',$actionsArr);
|
|
||||||
$this->assertNotContains('action_rollback',$actionsArr);
|
|
||||||
$this->assertNotContains('action_revert',$actionsArr);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testActionsPublishedRecord() {
|
$this->assertContains('action_save',$actionsArr);
|
||||||
$page = new Page();
|
$this->assertContains('action_publish',$actionsArr);
|
||||||
$page->write();
|
$this->assertNotContains('action_unpublish',$actionsArr);
|
||||||
$page->publish('Stage', 'Live');
|
$this->assertContains('action_delete',$actionsArr);
|
||||||
|
$this->assertNotContains('action_deletefromlive',$actionsArr);
|
||||||
|
$this->assertNotContains('action_rollback',$actionsArr);
|
||||||
|
$this->assertNotContains('action_revert',$actionsArr);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testActionsPublishedRecord() {
|
||||||
|
if(class_exists('SiteTreeCMSWorkflow')) return true;
|
||||||
|
|
||||||
$author = $this->objFromFixture('Member', 'cmseditor');
|
$page = new Page();
|
||||||
$this->session()->inst_set('loggedInAs', $author->ID);
|
$page->write();
|
||||||
|
$page->publish('Stage', 'Live');
|
||||||
$actionsArr = $page->getCMSActions()->column('Name');
|
|
||||||
|
|
||||||
$this->assertContains('action_save',$actionsArr);
|
|
||||||
$this->assertContains('action_publish',$actionsArr);
|
|
||||||
$this->assertContains('action_unpublish',$actionsArr);
|
|
||||||
$this->assertContains('action_delete',$actionsArr);
|
|
||||||
$this->assertNotContains('action_deletefromlive',$actionsArr);
|
|
||||||
$this->assertNotContains('action_rollback',$actionsArr);
|
|
||||||
$this->assertNotContains('action_revert',$actionsArr);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testActionsDeletedFromStageRecord() {
|
|
||||||
$page = new Page();
|
|
||||||
$page->write();
|
|
||||||
$pageID = $page->ID;
|
|
||||||
$page->publish('Stage', 'Live');
|
|
||||||
$page->deleteFromStage('Stage');
|
|
||||||
|
|
||||||
// Get the live version of the page
|
|
||||||
$page = Versioned::get_one_by_stage("SiteTree", "Live", "\"SiteTree\".ID = $pageID");
|
|
||||||
|
|
||||||
$author = $this->objFromFixture('Member', 'cmseditor');
|
|
||||||
$this->session()->inst_set('loggedInAs', $author->ID);
|
|
||||||
|
|
||||||
$actionsArr = $page->getCMSActions()->column('Name');
|
|
||||||
|
|
||||||
$this->assertNotContains('action_save',$actionsArr);
|
|
||||||
$this->assertNotContains('action_publish',$actionsArr);
|
|
||||||
$this->assertNotContains('action_unpublish',$actionsArr);
|
|
||||||
$this->assertNotContains('action_delete',$actionsArr);
|
|
||||||
$this->assertContains('action_deletefromlive',$actionsArr);
|
|
||||||
$this->assertNotContains('action_rollback',$actionsArr);
|
|
||||||
$this->assertContains('action_revert',$actionsArr);
|
|
||||||
}
|
|
||||||
|
|
||||||
function testActionsChangedOnStageRecord() {
|
$author = $this->objFromFixture('Member', 'cmseditor');
|
||||||
$page = new Page();
|
$this->session()->inst_set('loggedInAs', $author->ID);
|
||||||
$page->write();
|
|
||||||
$page->publish('Stage', 'Live');
|
$actionsArr = $page->getCMSActions()->column('Name');
|
||||||
$page->Content = 'Changed on Stage';
|
|
||||||
$page->write();
|
$this->assertContains('action_save',$actionsArr);
|
||||||
$page->flushCache();
|
$this->assertContains('action_publish',$actionsArr);
|
||||||
|
$this->assertContains('action_unpublish',$actionsArr);
|
||||||
$author = $this->objFromFixture('Member', 'cmseditor');
|
$this->assertContains('action_delete',$actionsArr);
|
||||||
$this->session()->inst_set('loggedInAs', $author->ID);
|
$this->assertNotContains('action_deletefromlive',$actionsArr);
|
||||||
|
$this->assertNotContains('action_rollback',$actionsArr);
|
||||||
$actionsArr = $page->getCMSActions()->column('Name');
|
$this->assertNotContains('action_revert',$actionsArr);
|
||||||
|
}
|
||||||
$this->assertContains('action_save',$actionsArr);
|
|
||||||
$this->assertContains('action_publish',$actionsArr);
|
function testActionsDeletedFromStageRecord() {
|
||||||
$this->assertContains('action_unpublish',$actionsArr);
|
if(class_exists('SiteTreeCMSWorkflow')) return true;
|
||||||
$this->assertContains('action_delete',$actionsArr);
|
|
||||||
$this->assertNotContains('action_deletefromlive',$actionsArr);
|
$page = new Page();
|
||||||
$this->assertContains('action_rollback',$actionsArr);
|
$page->write();
|
||||||
$this->assertNotContains('action_revert',$actionsArr);
|
$pageID = $page->ID;
|
||||||
}
|
$page->publish('Stage', 'Live');
|
||||||
|
$page->deleteFromStage('Stage');
|
||||||
|
|
||||||
|
// Get the live version of the page
|
||||||
|
$page = Versioned::get_one_by_stage("SiteTree", "Live", "\"SiteTree\".ID = $pageID");
|
||||||
|
|
||||||
|
$author = $this->objFromFixture('Member', 'cmseditor');
|
||||||
|
$this->session()->inst_set('loggedInAs', $author->ID);
|
||||||
|
|
||||||
|
$actionsArr = $page->getCMSActions()->column('Name');
|
||||||
|
|
||||||
|
$this->assertNotContains('action_save',$actionsArr);
|
||||||
|
$this->assertNotContains('action_publish',$actionsArr);
|
||||||
|
$this->assertNotContains('action_unpublish',$actionsArr);
|
||||||
|
$this->assertNotContains('action_delete',$actionsArr);
|
||||||
|
$this->assertContains('action_deletefromlive',$actionsArr);
|
||||||
|
$this->assertNotContains('action_rollback',$actionsArr);
|
||||||
|
$this->assertContains('action_revert',$actionsArr);
|
||||||
|
}
|
||||||
|
|
||||||
|
function testActionsChangedOnStageRecord() {
|
||||||
|
if(class_exists('SiteTreeCMSWorkflow')) return true;
|
||||||
|
|
||||||
|
$page = new Page();
|
||||||
|
$page->write();
|
||||||
|
$page->publish('Stage', 'Live');
|
||||||
|
$page->Content = 'Changed on Stage';
|
||||||
|
$page->write();
|
||||||
|
$page->flushCache();
|
||||||
|
|
||||||
|
$author = $this->objFromFixture('Member', 'cmseditor');
|
||||||
|
$this->session()->inst_set('loggedInAs', $author->ID);
|
||||||
|
|
||||||
|
$actionsArr = $page->getCMSActions()->column('Name');
|
||||||
|
|
||||||
|
$this->assertContains('action_save',$actionsArr);
|
||||||
|
$this->assertContains('action_publish',$actionsArr);
|
||||||
|
$this->assertContains('action_unpublish',$actionsArr);
|
||||||
|
$this->assertContains('action_delete',$actionsArr);
|
||||||
|
$this->assertNotContains('action_deletefromlive',$actionsArr);
|
||||||
|
$this->assertContains('action_rollback',$actionsArr);
|
||||||
|
$this->assertNotContains('action_revert',$actionsArr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
Loading…
Reference in New Issue
Block a user