GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

testWorkflowDefinitionCanPerms()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 9.488
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Symbiote\AdvancedWorkflow\Tests;
4
5
use SilverStripe\Dev\SapphireTest;
6
use Symbiote\AdvancedWorkflow\DataObjects\WorkflowDefinition;
7
8
/**
9
 * Tests for permissions on all Workflow Objects.
10
 * These will obviousely need to be modified should additional workflow permissions come online.
11
 *
12
 * @author     [email protected]
13
 * @license    BSD License (http://silverstripe.org/bsd-license/)
14
 * @package    advancedworkflow
15
 * @subpackage tests
16
 */
17
class WorkflowPermissionsTest extends SapphireTest
18
{
19
    /**
20
     * @var string
21
     */
22
    protected static $fixture_file = 'workflowpermissions.yml';
23
24
    /**
25
     * Tests whether members with differing permissions, should be able to create & edit WorkflowDefinitions
26
     */
27
    public function testWorkflowDefinitionCanPerms()
28
    {
29
        // Very limited perms. No create.
30
        $this->logInWithPermission('CMS_ACCESS_AdvancedWorkflowAdmin');
31
        $workflowdef = $this->objFromFixture(WorkflowDefinition::class, 'no-actions');
32
        $this->assertFalse($workflowdef->canCreate());
33
34
        // Limited perms. No create.
35
        $this->logInWithPermission('VIEW_ACTIVE_WORKFLOWS');
36
        $workflowdef = $this->objFromFixture(WorkflowDefinition::class, 'no-actions');
37
        $this->assertFalse($workflowdef->canCreate());
38
39
        // Has perms. Can create.
40
        $this->logInWithPermission('CREATE_WORKFLOW');
41
        $workflowdef = $this->objFromFixture(WorkflowDefinition::class, 'no-actions');
42
        $this->assertTrue($workflowdef->canCreate());
43
44
        // Limited perms. No delete
45
        $this->logInWithPermission('CREATE_WORKFLOW');
46
        $workflowdef = $this->objFromFixture(WorkflowDefinition::class, 'no-actions');
47
        $this->assertFalse($workflowdef->canDelete());
48
49
        // Has perms. No delete
50
        $this->logInWithPermission('DELETE_WORKFLOW');
51
        $workflowdef = $this->objFromFixture(WorkflowDefinition::class, 'no-actions');
52
        $this->assertTrue($workflowdef->canDelete());
53
    }
54
55
    /**
56
     * Tests whether members with differing permissions, should be able to create & edit WorkflowActions
57
     */
58
    public function testWorkflowActionCanPerms()
59
    {
60
        // Very limited perms. No create.
61
        $this->logInWithPermission('CMS_ACCESS_AdvancedWorkflowAdmin');
62
        $workflowdef = $this->objFromFixture(WorkflowDefinition::class, 'with-actions');
63
        $this->assertFalse($workflowdef->Actions()->first()->canCreate());
0 ignored issues
show
Bug introduced by
The method Actions() does not exist on SilverStripe\ORM\DataObject. Did you maybe mean getCMSActions()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
64
        $this->assertFalse($workflowdef->Actions()->first()->canEdit());
0 ignored issues
show
Bug introduced by
The method Actions() does not exist on SilverStripe\ORM\DataObject. Did you maybe mean getCMSActions()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
65
        $this->assertFalse($workflowdef->Actions()->first()->canDelete());
0 ignored issues
show
Bug introduced by
The method Actions() does not exist on SilverStripe\ORM\DataObject. Did you maybe mean getCMSActions()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
66
67
        // Limited perms. No create or delete.
68
        $this->logInWithPermission('VIEW_ACTIVE_WORKFLOWS');
69
        $workflowdef = $this->objFromFixture(WorkflowDefinition::class, 'with-actions');
70
        $this->assertFalse($workflowdef->Actions()->first()->canCreate());
0 ignored issues
show
Bug introduced by
The method Actions() does not exist on SilverStripe\ORM\DataObject. Did you maybe mean getCMSActions()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
71
        $this->assertFalse($workflowdef->Actions()->first()->canCreate());
0 ignored issues
show
Bug introduced by
The method Actions() does not exist on SilverStripe\ORM\DataObject. Did you maybe mean getCMSActions()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
72
        $this->assertFalse($workflowdef->Actions()->first()->canDelete());
0 ignored issues
show
Bug introduced by
The method Actions() does not exist on SilverStripe\ORM\DataObject. Did you maybe mean getCMSActions()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
73
74
        // Has perms. Can create.
75
        $this->logInWithPermission('CREATE_WORKFLOW');
76
        $workflowdef = $this->objFromFixture(WorkflowDefinition::class, 'with-actions');
77
        $this->assertTrue($workflowdef->Actions()->first()->canCreate());
0 ignored issues
show
Bug introduced by
The method Actions() does not exist on SilverStripe\ORM\DataObject. Did you maybe mean getCMSActions()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
78
        $this->assertTrue($workflowdef->Actions()->first()->canEdit());
0 ignored issues
show
Bug introduced by
The method Actions() does not exist on SilverStripe\ORM\DataObject. Did you maybe mean getCMSActions()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
79
80
        // Limited perms. No Delete
81
        $this->assertFalse($workflowdef->Actions()->first()->canDelete());
0 ignored issues
show
Bug introduced by
The method Actions() does not exist on SilverStripe\ORM\DataObject. Did you maybe mean getCMSActions()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
82
    }
83
84
    /**
85
     * Tests whether members with differing permissions, should be able to create & edit WorkflowActions
86
     */
87
    public function testWorkflowTransitionPerms()
88
    {
89
        // Very limited perms. No create.
90
        $this->logInWithPermission('CMS_ACCESS_AdvancedWorkflowAdmin');
91
        $workflowdef = $this->objFromFixture(WorkflowDefinition::class, 'with-actions-and-transitions');
92
        $this->assertFalse($workflowdef->Actions()->first()->Transitions()->first()->canCreate());
0 ignored issues
show
Bug introduced by
The method Actions() does not exist on SilverStripe\ORM\DataObject. Did you maybe mean getCMSActions()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
93
        $this->assertFalse($workflowdef->Actions()->first()->Transitions()->first()->canEdit());
0 ignored issues
show
Bug introduced by
The method Actions() does not exist on SilverStripe\ORM\DataObject. Did you maybe mean getCMSActions()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
94
        $this->assertFalse($workflowdef->Actions()->first()->Transitions()->first()->canDelete());
0 ignored issues
show
Bug introduced by
The method Actions() does not exist on SilverStripe\ORM\DataObject. Did you maybe mean getCMSActions()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
95
96
        // Limited perms. No create.
97
        $this->logInWithPermission('VIEW_ACTIVE_WORKFLOWS');
98
        $workflowdef = $this->objFromFixture(WorkflowDefinition::class, 'with-actions-and-transitions');
99
        $this->assertFalse($workflowdef->Actions()->first()->Transitions()->first()->canCreate());
0 ignored issues
show
Bug introduced by
The method Actions() does not exist on SilverStripe\ORM\DataObject. Did you maybe mean getCMSActions()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
100
        $this->assertFalse($workflowdef->Actions()->first()->Transitions()->first()->canEdit());
0 ignored issues
show
Bug introduced by
The method Actions() does not exist on SilverStripe\ORM\DataObject. Did you maybe mean getCMSActions()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
101
        $this->assertFalse($workflowdef->Actions()->first()->Transitions()->first()->canDelete());
0 ignored issues
show
Bug introduced by
The method Actions() does not exist on SilverStripe\ORM\DataObject. Did you maybe mean getCMSActions()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
102
103
        // Has perms. Can create.
104
        $this->logInWithPermission('CREATE_WORKFLOW');
105
        $workflowdef = $this->objFromFixture(WorkflowDefinition::class, 'with-actions-and-transitions');
106
        $this->assertTrue($workflowdef->Actions()->first()->Transitions()->first()->canCreate());
0 ignored issues
show
Bug introduced by
The method Actions() does not exist on SilverStripe\ORM\DataObject. Did you maybe mean getCMSActions()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
107
        $this->assertTrue($workflowdef->Actions()->first()->Transitions()->first()->canEdit());
0 ignored issues
show
Bug introduced by
The method Actions() does not exist on SilverStripe\ORM\DataObject. Did you maybe mean getCMSActions()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
108
        $this->assertTrue($workflowdef->Actions()->first()->Transitions()->first()->canDelete());
0 ignored issues
show
Bug introduced by
The method Actions() does not exist on SilverStripe\ORM\DataObject. Did you maybe mean getCMSActions()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
109
    }
110
}
111