This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace SheaDawson\Blocks\Test; |
||
4 | |||
5 | use SheaDawson\Blocks\Model\Block; |
||
6 | use SilverStripe\Dev\SapphireTest; |
||
7 | use SilverStripe\Forms\FieldList; |
||
8 | use SilverStripe\Security\Member; |
||
9 | |||
10 | class BlockTest extends SapphireTest |
||
11 | { |
||
12 | /** |
||
13 | * @var string |
||
14 | */ |
||
15 | protected static $fixture_file = 'fixtures.yml'; |
||
16 | |||
17 | /** |
||
18 | * |
||
19 | */ |
||
20 | public function testGetTypeForGridfield() |
||
21 | { |
||
22 | $object = $this->objFromFixture(Block::class, 'default'); |
||
23 | $this->assertEquals($object->getTypeForGridfield(), $object->singular_name()); |
||
24 | } |
||
25 | |||
26 | /** |
||
27 | * |
||
28 | */ |
||
29 | public function testGetCMSFields() |
||
30 | { |
||
31 | $object = $this->objFromFixture(Block::class, 'default'); |
||
32 | $fields = $object->getCMSFields(); |
||
33 | $this->assertInstanceOf(FieldList::class, $fields); |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * |
||
38 | */ |
||
39 | View Code Duplication | public function testCanView() |
|
0 ignored issues
–
show
|
|||
40 | { |
||
41 | $object = $this->objFromFixture(Block::class, 'default'); |
||
42 | $admin = $this->objFromFixture(Member::class, 'admin'); |
||
43 | $this->assertTrue($object->canView($admin)); |
||
0 ignored issues
–
show
It seems like
$admin defined by $this->objFromFixture(\S...Member::class, 'admin') on line 42 can also be of type object<SilverStripe\ORM\DataObject> ; however, SilverStripe\ORM\DataObject::canView() does only seem to accept object<SilverStripe\Security\Member>|null , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue. ![]() |
|||
44 | $member = $this->objFromFixture(Member::class, 'default'); |
||
45 | $this->assertTrue($object->canView($member)); |
||
0 ignored issues
–
show
It seems like
$member defined by $this->objFromFixture(\S...mber::class, 'default') on line 44 can also be of type object<SilverStripe\ORM\DataObject> ; however, SilverStripe\ORM\DataObject::canView() does only seem to accept object<SilverStripe\Security\Member>|null , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue. ![]() |
|||
46 | } |
||
47 | |||
48 | /** |
||
49 | * |
||
50 | */ |
||
51 | View Code Duplication | public function testCanEdit() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
52 | { |
||
53 | $object = $this->objFromFixture(Block::class, 'default'); |
||
54 | $admin = $this->objFromFixture(Member::class, 'admin'); |
||
55 | $this->assertTrue($object->canEdit($admin)); |
||
0 ignored issues
–
show
It seems like
$admin defined by $this->objFromFixture(\S...Member::class, 'admin') on line 54 can also be of type object<SilverStripe\ORM\DataObject> ; however, SilverStripe\ORM\DataObject::canEdit() does only seem to accept object<SilverStripe\Security\Member>|null , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue. ![]() |
|||
56 | $member = $this->objFromFixture(Member::class, 'default'); |
||
57 | $this->assertFalse($object->canEdit($member)); |
||
0 ignored issues
–
show
It seems like
$member defined by $this->objFromFixture(\S...mber::class, 'default') on line 56 can also be of type object<SilverStripe\ORM\DataObject> ; however, SilverStripe\ORM\DataObject::canEdit() does only seem to accept object<SilverStripe\Security\Member>|null , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue. ![]() |
|||
58 | } |
||
59 | |||
60 | /** |
||
61 | * |
||
62 | */ |
||
63 | View Code Duplication | public function testCanDelete() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
64 | { |
||
65 | $object = $this->objFromFixture(Block::class, 'default'); |
||
66 | $admin = $this->objFromFixture(Member::class, 'admin'); |
||
67 | $this->assertTrue($object->canDelete($admin)); |
||
0 ignored issues
–
show
It seems like
$admin defined by $this->objFromFixture(\S...Member::class, 'admin') on line 66 can also be of type object<SilverStripe\ORM\DataObject> ; however, SilverStripe\ORM\DataObject::canDelete() does only seem to accept object<SilverStripe\Security\Member>|null , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue. ![]() |
|||
68 | $member = $this->objFromFixture(Member::class, 'default'); |
||
69 | $this->assertFalse($object->canDelete($member)); |
||
0 ignored issues
–
show
It seems like
$member defined by $this->objFromFixture(\S...mber::class, 'default') on line 68 can also be of type object<SilverStripe\ORM\DataObject> ; however, SilverStripe\ORM\DataObject::canDelete() does only seem to accept object<SilverStripe\Security\Member>|null , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue. ![]() |
|||
70 | } |
||
71 | |||
72 | /** |
||
73 | * |
||
74 | */ |
||
75 | View Code Duplication | public function testCanCreate() |
|
0 ignored issues
–
show
This method seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
76 | { |
||
77 | $object = $this->objFromFixture(Block::class, 'default'); |
||
78 | $admin = $this->objFromFixture(Member::class, 'admin'); |
||
79 | $this->assertTrue($object->canCreate($admin)); |
||
0 ignored issues
–
show
It seems like
$admin defined by $this->objFromFixture(\S...Member::class, 'admin') on line 78 can also be of type object<SilverStripe\ORM\DataObject> ; however, SilverStripe\ORM\DataObject::canCreate() does only seem to accept object<SilverStripe\Security\Member>|null , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue. ![]() |
|||
80 | $member = $this->objFromFixture(Member::class, 'default'); |
||
81 | $this->assertFalse($object->canCreate($member)); |
||
0 ignored issues
–
show
It seems like
$member defined by $this->objFromFixture(\S...mber::class, 'default') on line 80 can also be of type object<SilverStripe\ORM\DataObject> ; however, SilverStripe\ORM\DataObject::canCreate() does only seem to accept object<SilverStripe\Security\Member>|null , maybe add an additional type check?
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check: /**
* @return array|string
*/
function returnsDifferentValues($x) {
if ($x) {
return 'foo';
}
return array();
}
$x = returnsDifferentValues($y);
if (is_array($x)) {
// $x is an array.
}
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue. ![]() |
|||
82 | } |
||
83 | |||
84 | /** |
||
85 | * |
||
86 | */ |
||
87 | public function testProvidePermissions() |
||
88 | { |
||
89 | $object = singleton(Block::class); |
||
90 | $expected = [ |
||
91 | 'BLOCK_EDIT' => [ |
||
92 | 'name' => _t('Block.EditBlock', 'Edit a Block'), |
||
93 | 'category' => _t('Block.PermissionCategory', 'Blocks'), |
||
94 | ], |
||
95 | 'BLOCK_DELETE' => [ |
||
96 | 'name' => _t('Block.DeleteBlock', 'Delete a Block'), |
||
97 | 'category' => _t('Block.PermissionCategory', 'Blocks'), |
||
98 | ], |
||
99 | 'BLOCK_CREATE' => [ |
||
100 | 'name' => _t('Block.CreateBlock', 'Create a Block'), |
||
101 | 'category' => _t('Block.PermissionCategory', 'Blocks'), |
||
102 | ], |
||
103 | 'BLOCK_PUBLISH' => [ |
||
104 | 'name' => _t('Block.PublishBlock', 'Publish a Block'), |
||
105 | 'category' => _t('Block.PermissionCategory', 'Blocks'), |
||
106 | ], |
||
107 | ]; |
||
108 | |||
109 | $this->assertEquals($expected, $object->providePermissions()); |
||
110 | } |
||
111 | } |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.