2009-01-08 00:00:54 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Possible actions:
|
|
|
|
* - action_save
|
|
|
|
* - action_publish
|
|
|
|
* - action_unpublish
|
|
|
|
* - action_delete
|
|
|
|
* - action_deletefromlive
|
|
|
|
* - action_rollback
|
|
|
|
* - action_revert
|
|
|
|
*
|
|
|
|
* @package sapphire
|
|
|
|
* @subpackage tests
|
|
|
|
*/
|
2009-08-06 23:39:04 +02:00
|
|
|
class SiteTreeActionsTest extends FunctionalTest {
|
|
|
|
|
|
|
|
static $fixture_file = 'sapphire/tests/SiteTreeActionsTest.yml';
|
|
|
|
|
|
|
|
function testActionsPublishedRecord() {
|
|
|
|
if(class_exists('SiteTreeCMSWorkflow')) return true;
|
|
|
|
|
|
|
|
$page = new Page();
|
2009-08-08 06:21:51 +02:00
|
|
|
$page->CanEditType = 'LoggedInUsers';
|
2009-08-06 23:39:04 +02:00
|
|
|
$page->write();
|
2009-08-08 06:21:51 +02:00
|
|
|
$page->doPublish();
|
2009-08-06 23:39:04 +02:00
|
|
|
|
|
|
|
$author = $this->objFromFixture('Member', 'cmseditor');
|
|
|
|
$this->session()->inst_set('loggedInAs', $author->ID);
|
2009-01-08 00:00:54 +01:00
|
|
|
|
2009-08-06 23:39:04 +02:00
|
|
|
$actionsArr = $page->getCMSActions()->column('Name');
|
2009-01-08 00:00:54 +01:00
|
|
|
|
2009-08-06 23:39:04 +02:00
|
|
|
$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() {
|
|
|
|
if(class_exists('SiteTreeCMSWorkflow')) return true;
|
2009-01-08 00:00:54 +01:00
|
|
|
|
2009-08-06 23:39:04 +02:00
|
|
|
$page = new Page();
|
2009-08-08 06:21:51 +02:00
|
|
|
$page->CanEditType = 'LoggedInUsers';
|
2009-08-06 23:39:04 +02:00
|
|
|
$page->write();
|
|
|
|
$pageID = $page->ID;
|
2009-08-08 06:21:51 +02:00
|
|
|
$page->doPublish();
|
2009-08-06 23:39:04 +02:00
|
|
|
$page->deleteFromStage('Stage');
|
2009-01-08 00:00:54 +01:00
|
|
|
|
2009-08-06 23:39:04 +02:00
|
|
|
// Get the live version of the page
|
2009-09-17 02:17:06 +02:00
|
|
|
$page = Versioned::get_one_by_stage("SiteTree", "Live", "\"SiteTree\".\"ID\" = $pageID");
|
2009-01-08 00:00:54 +01:00
|
|
|
|
2009-08-06 23:39:04 +02:00
|
|
|
$author = $this->objFromFixture('Member', 'cmseditor');
|
|
|
|
$this->session()->inst_set('loggedInAs', $author->ID);
|
2009-01-08 00:00:54 +01:00
|
|
|
|
2009-08-06 23:39:04 +02:00
|
|
|
$actionsArr = $page->getCMSActions()->column('Name');
|
2009-01-08 00:00:54 +01:00
|
|
|
|
2009-08-06 23:39:04 +02:00
|
|
|
$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;
|
2009-01-08 00:00:54 +01:00
|
|
|
|
2009-08-06 23:39:04 +02:00
|
|
|
$page = new Page();
|
2009-08-08 06:21:51 +02:00
|
|
|
$page->CanEditType = 'LoggedInUsers';
|
2009-08-06 23:39:04 +02:00
|
|
|
$page->write();
|
2009-08-08 06:21:51 +02:00
|
|
|
$page->doPublish();
|
2009-08-06 23:39:04 +02:00
|
|
|
$page->Content = 'Changed on Stage';
|
|
|
|
$page->write();
|
|
|
|
$page->flushCache();
|
2009-01-08 00:00:54 +01:00
|
|
|
|
2009-08-06 23:39:04 +02:00
|
|
|
$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);
|
2009-01-08 00:00:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|