8000 refs #8313 · instaclick/symfony@cadb807 · GitHub
[go: up one dir, main page]

Skip to content

Commit cadb807

Browse files
committed
1 parent e0d3573 commit cadb807

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/Symfony/Component/Security/Acl/Domain/RoleSecurityIdentity.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
namespace Symfony\Component\Security\Acl\Domain;
1313

1414
use Symfony\Component\Security\Acl\Model\SecurityIdentityInterface;
15-
use Symfony\Component\Security\Core\Role\Role;
15+
use Symfony\Component\Security\Core\Role\RoleInterface;
1616

1717
/**
1818
* A SecurityIdentity implementation for roles
@@ -30,7 +30,7 @@ final class RoleSecurityIdentity implements SecurityIdentityInterface
3030
*/
3131
public function __construct($role)
3232
{
33-
if ($role instanceof Role) {
33+
if ($role instanceof RoleInterface) {
3434
$role = $role->getRole();
3535
}
3636

src/Symfony/Component/Security/Tests/Acl/Domain/RoleSecurityIdentityTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Symfony\Component\Security\Acl\Domain\UserSecurityIdentity;
1515
use Symfony\Component\Security\Core\Role\Role;
16+
use Symfony\Component\Security\Core\Role\RoleInterface;
1617
use Symfony\Component\Security\Acl\Domain\RoleSecurityIdentity;
1718

1819
class RoleSecurityIdentityTest extends \PHPUnit_Framework_TestCase
@@ -50,6 +51,31 @@ public function getCompareData()
5051
array(new RoleSecurityIdentity('ROLE_FOO'), new RoleSecurityIdentity(new Role('ROLE_FOO')), true),
5152
array(new RoleSecurityIdentity('ROLE_USER'), new RoleSecurityIdentity('ROLE_FOO'), false),
5253
array(new RoleSecurityIdentity('ROLE_FOO'), new UserSecurityIdentity('ROLE_FOO', 'Foo'), false),
54+
array(new RoleSecurityIdentity('ROLE_FOO'), new RoleSecurityIdentity(new MyRole('ROLE_FOO')), true),
55+
array(new RoleSecurityIdentity('ROLE_USER'), new RoleSecurityIdentity(new MyRole('ROLE_FOO')), false),
5356
);
5457
}
5558
}
59+
60+
class MyRole implements RoleInterface
61+
{
62+
private $role;
63+
64+
/**
65+
* Constructor.
66+
*
67+
* @param string $role The role name
68+
*/
69+
public function __construct($role)
70+
{
71+
$this->role = (string) $role;
72+
}
73+
74+
/**
75+
* {@inheritdoc}
76+
*/
77+
public function getRole()
78+
{
79+
return $this->role;
80+
}
81+
}

0 commit comments

Comments
 (0)
0