function _workflow_test_entity_allowable in Workflow 7.2
File
- ./
workflow.test.inc, line 155 - Contains test functions.
Code
function _workflow_test_entity_allowable() {
global $user;
$workflow = workflow_create('workflow_test_' . REQUEST_TIME);
$workflow
->save();
$s1 = $workflow
->createState('to be opened');
$s2 = $workflow
->createState('open');
$s3 = $workflow
->createState('closed');
$s1
->save();
$s2
->save();
$s3
->save();
$roles = array(
1,
2,
);
// anon, auth user.
$t1 = $t = $workflow
->createTransition(WORKFLOW_CREATION_STATE_NAME, 'to be opened');
$t->roles = $roles;
$t
->save();
$t2 = $t = $workflow
->createTransition('to be opened', 'open');
$t->roles = $roles;
$t
->save();
$t3 = $t = $workflow
->createTransition('open', 'closed');
$t->roles = $roles;
DPM($t3);
$t
->save();
DPM($t3);
$t4 = $t = $workflow
->createTransition('closed', 'open');
$t->roles = $roles;
$t
->save();
dpm($s2
->getOptions('', NULL, '', $user, FALSE));
// returns TRUE if the role is allowed to do the transition.
$rc = $t3
->isAllowed($role = 2);
dpm($t3);
dpm('this result must be TRUE: ' . (int) $rc);
$rc = $t3
->isAllowed($role = 3);
dpm('this result must be FALSE: ' . (int) $rc);
$rc = $workflow
->GetTransitionsBySid($s3->sid);
dpm($rc, 'allowed transitions from ' . $s3
->label());
$ts = $workflow
->getTransitions();
dpm($ts);
$ts = $workflow
->getTransitionsBySid($s3->sid);
dpm($ts);
$workflow
->delete();
}