Source of file WorkflowRequestTest.php
Size: 2,825 Bytes - Last Modified: 2021-12-23T10:28:49+00:00
/var/www/docs.ssmods.com/process/src/tests/WorkflowRequestTest.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 | <?php /** * @package cmsworkflow * @subpackage tests */ class WorkflowRequestTest extends FunctionalTest { public static $fixture_file = 'cmsworkflow/tests/SiteTreeCMSWorkflowTest.yml'; protected $requiredExtensions = array( 'SiteTree' => array('SiteTreeCMSTwoStepWorkflow'), 'SiteConfig' => array('SiteConfigTwoStepWorkflow'), 'WorkflowRequest' => array('WorkflowTwoStepRequest'), ); protected $illegalExtensions = array( 'SiteTree' => array('SiteTreeCMSThreeStepWorkflow'), 'WorkflowRequest' => array('WorkflowThreeStepRequest'), 'LeftAndMain' => array('LeftAndMainCMSThreeStepWorkflow'), 'SiteConfig' => array('SiteConfigThreeStepWorkflow'), ); protected $requireDefaultRecordsFrom = array( 'WorkflowSystemMember' ); public function setUp() { // Static publishing will just confuse things StaticPublisher::$disable_realtime = true; parent::setUp(); } public function tearDown() { parent::tearDown(); // Static publishing will just confuse things StaticPublisher::$disable_realtime = false; } public function testEachPageCanHaveOnlyOpenOpenRequest() { $page = $this->objFromFixture('SiteTree', 'custompublisherpage'); $custompublisher = $this->objFromFixture('Member', 'custompublisher'); $customauthor = $this->objFromFixture('Member', 'customauthor'); $this->session()->inst_set('loggedInAs', $customauthor->ID); $request1 = $page->openOrNewWorkflowRequest('WorkflowPublicationRequest'); $page = $this->objFromFixture('SiteTree', 'custompublisherpage'); $request2 = $page->openOrNewWorkflowRequest('WorkflowPublicationRequest'); $this->assertNotNull($request1); $this->assertEquals( $request1->ID, $request2->ID, 'Each page can only have one open (not approved or declined) request' ); $this->session()->inst_set('loggedInAs', null); } /** * Test that openWorklow() and openOrNewWorkflow() function. */ public function testOpenWorkflowRequest() { // Check a page that has an existing publication workflow $page = $this->objFromFixture('SiteTree', 'openpublishworkflowpage'); $existingWorkflow = $this->objFromFixture('WorkflowPublicationRequest', 'openpublishworkflow'); $this->assertEquals($existingWorkflow->ID, $page->openWorkflowRequest('WorkflowPublicationRequest')->ID); $this->assertEquals($existingWorkflow->ID, $page->openOrNewWorkflowRequest('WorkflowPublicationRequest')->ID); $this->assertNull($page->openWorkflowRequest('WorkflowDeletionRequest')); } } |