Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Push — master ( 861d7d...2ad8d1 )
by Cristian
04:38
created

CrudPanelAccessTest::testHasAccessOrFailDenied()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 2
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 9.4285
1
<?php
2
3
namespace Backpack\CRUD\Tests\Unit\CrudPanel;
4
5
use Backpack\CRUD\Exception\AccessDeniedException;
6
7
class CrudPanelAccessTest extends BaseCrudPanelTest
8
{
9
    private $unknownPermission = 'unknownPermission';
10
11
    private $defaultAccessList = [
12
        'list',
13
        'create',
14
        'update',
15
        'delete',
16
    ];
17
18
    private $fullAccessList = [
19
        'list',
20
        'create',
21
        'update',
22
        'delete',
23
        'revisions',
24
        'reorder',
25
        'show',
26
        'details_row',
27
    ];
28
29
    public function testDefaultAccess()
30
    {
31
        $this->assertEquals($this->defaultAccessList, $this->crudPanel->access);
32
    }
33
34
    public function testHasAccess()
35
    {
36
        foreach ($this->defaultAccessList as $permission) {
37
            $this->assertTrue($this->crudPanel->hasAccess($permission));
38
        }
39
40
        foreach (array_diff($this->fullAccessList, $this->defaultAccessList) as $permission) {
41
            $this->assertFalse($this->crudPanel->hasAccess($permission));
42
        }
43
    }
44
45
    public function testAllowAccess()
46
    {
47
        $permission = 'reorder';
48
49
        $this->crudPanel->allowAccess($permission);
50
51
        $this->assertTrue($this->crudPanel->hasAccess($permission));
52
    }
53
54
    public function testAllowAccessToUnknownPermission()
55
    {
56
        $this->crudPanel->allowAccess($this->unknownPermission);
57
58
        $this->assertTrue($this->crudPanel->hasAccess($this->unknownPermission));
59
    }
60
61
    public function testDenyAccess()
62
    {
63
        $permission = 'delete';
64
65
        $this->crudPanel->denyAccess($permission);
66
67
        $this->assertFalse($this->crudPanel->hasAccess($permission));
68
        $this->assertEquals(array_diff($this->crudPanel->access, [$permission]), $this->crudPanel->access);
69
    }
70
71
    public function testDenyAccessToUnknownPermission()
72
    {
73
        $this->crudPanel->denyAccess($this->unknownPermission);
74
75
        $this->assertFalse($this->crudPanel->hasAccess($this->unknownPermission));
76
        $this->assertEquals($this->defaultAccessList, $this->crudPanel->access);
77
    }
78
79
    public function testHasAccessToAny()
80
    {
81
        $this->assertTrue($this->crudPanel->hasAccessToAny($this->fullAccessList));
82
    }
83
84
    public function testHasAccessToAnyDenied()
85
    {
86
        $this->assertFalse($this->crudPanel->hasAccessToAny(array_diff($this->fullAccessList, $this->defaultAccessList)));
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 122 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
87
    }
88
89
    public function testHasAccessToAll()
90
    {
91
        $this->assertTrue($this->crudPanel->hasAccessToAll($this->defaultAccessList));
92
    }
93
94
    public function testHasAccessToAllDenied()
95
    {
96
        $this->assertFalse($this->crudPanel->hasAccessToAll($this->fullAccessList));
97
    }
98
99
    public function testHasAccessOrFail()
100
    {
101
        foreach ($this->defaultAccessList as $permission) {
102
            $this->assertTrue($this->crudPanel->hasAccessOrFail($permission));
103
        }
104
    }
105
106
    public function testHasAccessOrFailDenied()
107
    {
108
        $this->setExpectedException(AccessDeniedException::class);
109
110
        $this->crudPanel->hasAccessOrFail($this->unknownPermission);
111
    }
112
}
113