MINOR Added SiteTreeActionsTest

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@69840 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-01-07 06:08:10 +00:00 committed by Sam Minnee
parent 52857cce8f
commit 0ac94ba03e
2 changed files with 120 additions and 0 deletions

View File

@ -0,0 +1,109 @@
<?php
/**
* Possible actions:
* - action_save
* - action_publish
* - action_unpublish
* - action_delete
* - action_deletefromlive
* - action_rollback
* - action_revert
*
* @package sapphire
* @subpackage tests
*/
if(class_exists('SiteTreeCMSWorkflow')) {
class SiteTreeActionsTest extends FunctionalTest {
function testDummy() {}
}
} else {
class SiteTreeActionsTest extends FunctionalTest {
static $fixture_file = 'sapphire/tests/SiteTreeActionsTest.yml';
function testActionsNewPage() {
$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() {
$page = new Page();
$page->write();
$page->publish('Stage', 'Live');
$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->assertNotContains('action_rollback',$actionsArr);
$this->assertNotContains('action_revert',$actionsArr);
}
function testActionsDeletedFromStageRecord() {
$page = new Page();
$page->write();
$page->publish('Stage', 'Live');
$page->deleteFromStage('Stage');
$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() {
$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);
}
}
}
?>

View File

@ -0,0 +1,11 @@
Permission:
cmsmain:
Code: CMS_ACCESS_CMSMain
Group:
cmseditors:
Title: CMS Editors
Permissions: =>Permission.cmsmain
Member:
cmseditor:
Email: cmseditor@test.com
Groups: =>Group.cmseditors