1 | <?php |
||
11 | class WorkflowPermissionsTest extends SapphireTest { |
||
|
|||
12 | |||
13 | /** |
||
14 | * @var string |
||
15 | */ |
||
16 | public static $fixture_file = 'advancedworkflow/tests/workflowpermissions.yml'; |
||
17 | |||
18 | /** |
||
19 | * Tests whether members with differing permissions, should be able to create & edit WorkflowDefinitions |
||
20 | */ |
||
21 | public function testWorkflowDefinitionCanPerms() { |
||
22 | // Very limited perms. No create. |
||
23 | $this->logInWithPermission('CMS_ACCESS_AdvancedWorkflowAdmin'); |
||
24 | $workflowdef = $this->objFromFixture('WorkflowDefinition', 'no-actions'); |
||
25 | $this->assertFalse($workflowdef->canCreate()); |
||
26 | |||
27 | // Limited perms. No create. |
||
28 | $this->logInWithPermission('VIEW_ACTIVE_WORKFLOWS'); |
||
29 | $workflowdef = $this->objFromFixture('WorkflowDefinition', 'no-actions'); |
||
30 | $this->assertFalse($workflowdef->canCreate()); |
||
31 | |||
32 | // Has perms. Can create. |
||
33 | $this->logInWithPermission('CREATE_WORKFLOW'); |
||
34 | $workflowdef = $this->objFromFixture('WorkflowDefinition', 'no-actions'); |
||
35 | $this->assertTrue($workflowdef->canCreate()); |
||
36 | |||
37 | // Limited perms. No delete |
||
38 | $this->logInWithPermission('CREATE_WORKFLOW'); |
||
39 | $workflowdef = $this->objFromFixture('WorkflowDefinition', 'no-actions'); |
||
40 | $this->assertFalse($workflowdef->canDelete()); |
||
41 | |||
42 | // Has perms. No delete |
||
43 | $this->logInWithPermission('DELETE_WORKFLOW'); |
||
44 | $workflowdef = $this->objFromFixture('WorkflowDefinition', 'no-actions'); |
||
45 | $this->assertTrue($workflowdef->canDelete()); |
||
46 | } |
||
47 | |||
48 | /** |
||
49 | * Tests whether members with differing permissions, should be able to create & edit WorkflowActions |
||
50 | */ |
||
51 | public function testWorkflowActionCanPerms() { |
||
52 | // Very limited perms. No create. |
||
53 | $this->logInWithPermission('CMS_ACCESS_AdvancedWorkflowAdmin'); |
||
54 | $workflowdef = $this->objFromFixture('WorkflowDefinition', 'with-actions'); |
||
55 | $this->assertFalse($workflowdef->Actions()->first()->canCreate()); |
||
56 | $this->assertFalse($workflowdef->Actions()->first()->canEdit()); |
||
57 | $this->assertFalse($workflowdef->Actions()->first()->canDelete()); |
||
58 | |||
59 | // Limited perms. No create or delete. |
||
60 | $this->logInWithPermission('VIEW_ACTIVE_WORKFLOWS'); |
||
61 | $workflowdef = $this->objFromFixture('WorkflowDefinition', 'with-actions'); |
||
62 | $this->assertFalse($workflowdef->Actions()->first()->canCreate()); |
||
63 | $this->assertFalse($workflowdef->Actions()->first()->canCreate()); |
||
64 | $this->assertFalse($workflowdef->Actions()->first()->canDelete()); |
||
65 | |||
66 | // Has perms. Can create. |
||
67 | $this->logInWithPermission('CREATE_WORKFLOW'); |
||
68 | $workflowdef = $this->objFromFixture('WorkflowDefinition', 'with-actions'); |
||
69 | $this->assertTrue($workflowdef->Actions()->first()->canCreate()); |
||
70 | $this->assertTrue($workflowdef->Actions()->first()->canEdit()); |
||
71 | |||
72 | // Limited perms. No Delete |
||
73 | $this->assertFalse($workflowdef->Actions()->first()->canDelete()); |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * Tests whether members with differing permissions, should be able to create & edit WorkflowActions |
||
78 | */ |
||
79 | public function testWorkflowTransitionPerms() { |
||
101 | |||
102 | } |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.