@@ -27,7 +27,7 @@ class AclVoterTest extends \PHPUnit_Framework_TestCase
27
27
*/
28
28
public function testSupportsAttribute ($ attribute , $ supported )
29
29
{
30
- list ($ voter ,, $ permissionMap ,,) = $ this ->getVoter ();
30
+ list ($ voter ,, $ permissionMap ,,) = $ this ->getVoter (true , false );
31
31
32
32
$ permissionMap
33
33
->expects ($ this ->once ())
@@ -39,6 +39,16 @@ public function testSupportsAttribute($attribute, $supported)
39
39
$ this ->assertSame ($ supported , $ voter ->supportsAttribute ($ attribute ));
40
40
}
41
41
42
+ /**
43
+ * @dataProvider getSupportsAttributeNonStringTests
44
+ */
45
+ public function testSupportsAttributeNonString ($ attribute )
46
+ {
47
+ list ($ voter ,,,,,) = $ this ->getVoter (true , false );
48
+
49
+ $ this ->assertFalse ($ voter ->supportsAttribute ($ attribute ));
50
+ }
51
+
42
52
public function getSupportsAttributeTests ()
43
53
{
44
54
return array (
@@ -47,6 +57,16 @@ public function getSupportsAttributeTests()
47
57
);
48
58
}
49
59
60
+ public function getSupportsAttributeNonStringTests ()
61
+ {
62
+ return array (
63
+ array (new \stdClass ()),
64
+ array (1 ),
65
+ array (true ),
66
+ array (array ()),
67
+ );
68
+ }
69
+
50
70
/**
51
71
* @dataProvider getSupportsClassTests
52
72
*/
@@ -387,13 +407,20 @@ protected function getToken()
387
407
return $ this ->getMock ('Symfony\Component\Security\Core\Authentication\Token\TokenInterface ' );
388
408
}
389
409
390
- protected function getVoter ($ allowIfObjectIdentityUnavailable = true )
410
+ protected function getVoter ($ allowIfObjectIdentityUnavailable = true , $ alwaysContains = true )
391
411
{
392
412
$ provider = $ this ->getMock ('Symfony\Component\Security\Acl\Model\AclProviderInterface ' );
393
413
$ permissionMap = $ this ->getMock ('Symfony\Component\Security\Acl\Permission\PermissionMapInterface ' );
394
414
$ oidStrategy = $ this ->getMock ('Symfony\Component\Security\Acl\Model\ObjectIdentityRetrievalStrategyInterface ' );
395
415
$ sidStrategy = $ this ->getMock ('Symfony\Component\Security\Acl\Model\SecurityIdentityRetrievalStrategyInterface ' );
396
416
417
+ if ($ alwaysContains ) {
418
+ $ permissionMap
419
+ ->expects ($ this ->any ())
420
+ ->method ('contains ' )
421
+ ->will ($ this ->returnValue (true ));
422
+ }
423
+
397
424
return array (
398
425
new AclVoter ($ provider , $ oidStrategy , $ sidStrategy , $ permissionMap , null , $ allowIfObjectIdentityUnavailable ),
399
426
$ provider ,
0 commit comments