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 Kunstmaan\AdminBundle\Tests\Helper\Creators; |
||
4 | |||
5 | use Kunstmaan\AdminBundle\Entity\User; |
||
6 | use Kunstmaan\AdminBundle\Helper\Creators\ACLPermissionCreator; |
||
7 | use PHPUnit\Framework\TestCase; |
||
8 | use Symfony\Component\Security\Acl\Domain\RoleSecurityIdentity; |
||
9 | use Symfony\Component\Security\Acl\Exception\AclNotFoundException; |
||
10 | use Symfony\Component\Security\Acl\Model\EntryInterface; |
||
11 | use Symfony\Component\Security\Acl\Model\MutableAclInterface; |
||
12 | use Symfony\Component\Security\Acl\Model\MutableAclProviderInterface; |
||
13 | use Symfony\Component\Security\Acl\Model\ObjectIdentityInterface; |
||
14 | use Symfony\Component\Security\Acl\Model\ObjectIdentityRetrievalStrategyInterface; |
||
15 | |||
16 | /** |
||
17 | * Class ACLPermissionCreatorTest |
||
18 | */ |
||
19 | class ACLPermissionCreatorTest extends TestCase |
||
20 | { |
||
21 | public function testInitByExample() |
||
22 | { |
||
23 | $security = new RoleSecurityIdentity('ADMIN'); |
||
24 | $entry = $this->createMock(EntryInterface::class); |
||
25 | $user = $this->createMock(ObjectIdentityInterface::class); |
||
26 | $provider = $this->createMock(MutableAclProviderInterface::class); |
||
27 | $strategy = $this->createMock(ObjectIdentityRetrievalStrategyInterface::class); |
||
28 | $mutableAcl = $this->createMock(MutableAclInterface::class); |
||
29 | |||
30 | $entry->expects($this->once())->method('getSecurityIdentity')->willReturn($security); |
||
31 | $mutableAcl->expects($this->once())->method('getObjectAces')->willReturn([$entry]); |
||
32 | $strategy->expects($this->exactly(2))->method('getObjectIdentity')->willReturn($user); |
||
33 | $provider->expects($this->once())->method('findAcl')->willReturn($mutableAcl); |
||
34 | $provider->expects($this->once())->method('createAcl')->willReturn($mutableAcl); |
||
35 | $provider->expects($this->once())->method('updateAcl')->willReturn($mutableAcl); |
||
36 | |||
37 | $aclCreator = new ACLPermissionCreator($provider, $strategy); |
||
0 ignored issues
–
show
$strategy is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Symfony\Component...ievalStrategyInterface> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
38 | $aclCreator->initByExample($user, new User(), true); |
||
39 | } |
||
40 | |||
41 | public function testInitByMap() |
||
42 | { |
||
43 | $user = $this->createMock(ObjectIdentityInterface::class); |
||
44 | $provider = $this->createMock(MutableAclProviderInterface::class); |
||
45 | $strategy = $this->createMock(ObjectIdentityRetrievalStrategyInterface::class); |
||
46 | $mutableAcl = $this->createMock(MutableAclInterface::class); |
||
47 | |||
48 | $strategy->expects($this->once())->method('getObjectIdentity')->willReturn($user); |
||
49 | $provider->expects($this->once())->method('createAcl')->willReturn($mutableAcl); |
||
50 | $provider->expects($this->once())->method('updateAcl')->willReturn($mutableAcl); |
||
51 | $provider->expects($this->once())->method('deleteAcl')->willThrowException(new AclNotFoundException()); |
||
52 | |||
53 | $aclCreator = new ACLPermissionCreator($provider, $strategy); |
||
0 ignored issues
–
show
$provider is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Symfony\Component...leAclProviderInterface> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() $strategy is of type object<PHPUnit\Framework\MockObject\MockObject> , but the function expects a object<Symfony\Component...ievalStrategyInterface> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
54 | $aclCreator->initByMap($user, ['key' => 'value'], true); |
||
55 | } |
||
56 | } |
||
57 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: