These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | /* |
||
6 | * This file is part of the Sonata Project package. |
||
7 | * |
||
8 | * (c) Thomas Rabaix <[email protected]> |
||
9 | * |
||
10 | * For the full copyright and license information, please view the LICENSE |
||
11 | * file that was distributed with this source code. |
||
12 | */ |
||
13 | |||
14 | namespace Sonata\AdminBundle\Tests\Security\Permission; |
||
15 | |||
16 | use PHPUnit\Framework\TestCase; |
||
17 | use Sonata\AdminBundle\Security\Acl\Permission\AdminPermissionMap; |
||
18 | use Sonata\AdminBundle\Security\Acl\Permission\MaskBuilder; |
||
19 | |||
20 | class AdminPermissionMapTest extends TestCase |
||
21 | { |
||
22 | protected function setUp(): void |
||
23 | { |
||
24 | $this->permissionMap = new AdminPermissionMap(); |
||
25 | } |
||
26 | |||
27 | public function testGetMaskReturnsAnArrayOfMasks(): void |
||
28 | { |
||
29 | $reflection = new \ReflectionClass(AdminPermissionMap::class); |
||
30 | foreach ($reflection->getConstants() as $permission) { |
||
31 | $masks = $this->permissionMap->getMasks( |
||
32 | $permission, |
||
33 | new \stdClass() |
||
34 | ); |
||
35 | |||
36 | $this->assertInternalType('array', $masks); |
||
0 ignored issues
–
show
|
|||
37 | |||
38 | foreach ($masks as $mask) { |
||
39 | $this->assertInternalType('string', MaskBuilder::getCode($mask)); |
||
0 ignored issues
–
show
The method
PHPUnit\Framework\Assert::assertInternalType() has been deprecated with message: https://github.com/sebastianbergmann/phpunit/issues/3369
This method has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.
Loading history...
|
|||
40 | } |
||
41 | } |
||
42 | } |
||
43 | |||
44 | public function testGetMaskReturnsNullIfPermissionIsNotSupported(): void |
||
45 | { |
||
46 | $this->assertNull($this->permissionMap->getMasks( |
||
47 | 'unknown permission', |
||
48 | new \stdClass() |
||
49 | )); |
||
50 | } |
||
51 | |||
52 | public function permissionProvider() |
||
53 | { |
||
54 | $dataSet = []; |
||
55 | $reflection = new \ReflectionClass(AdminPermissionMap::class); |
||
56 | |||
57 | foreach ($reflection->getConstants() as $permission) { |
||
58 | $dataSet[$permission] = [true, $permission]; |
||
59 | } |
||
60 | |||
61 | return $dataSet + [ |
||
62 | 'unknown permission' => [false, 'unknown permission'], |
||
63 | ]; |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @dataProvider permissionProvider |
||
68 | */ |
||
69 | public function testContainsReturnsABoolean($expectedResult, $permission): void |
||
70 | { |
||
71 | $this->assertSame($expectedResult, $this->permissionMap->contains($permission)); |
||
72 | } |
||
73 | } |
||
74 |
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.