summaryrefslogtreecommitdiffstats
path: root/Tests/Core
diff options
context:
space:
mode:
authorRyan Weaver <ryan@thatsquality.com>2015-09-22 20:34:17 -0400
committerFabien Potencier <fabien.potencier@gmail.com>2015-09-24 08:33:58 +0200
commit8c2b94f409a3fc2b1c752939f01252549d822b93 (patch)
treea38d92b38894ea9aa3c76d91b10ac5af89ef4569 /Tests/Core
parentda308625d391f2c0d5df061fb2e13119a40c8729 (diff)
downloadsymfony-security-8c2b94f409a3fc2b1c752939f01252549d822b93.zip
symfony-security-8c2b94f409a3fc2b1c752939f01252549d822b93.tar.gz
symfony-security-8c2b94f409a3fc2b1c752939f01252549d822b93.tar.bz2
Updating AbstractVoter so that the method receives the TokenInterface
Diffstat (limited to 'Tests/Core')
-rw-r--r--Tests/Core/Authentication/Voter/AbstractVoterTest.php32
1 files changed, 32 insertions, 0 deletions
diff --git a/Tests/Core/Authentication/Voter/AbstractVoterTest.php b/Tests/Core/Authentication/Voter/AbstractVoterTest.php
index af7b82f..ecf82fb 100644
--- a/Tests/Core/Authentication/Voter/AbstractVoterTest.php
+++ b/Tests/Core/Authentication/Voter/AbstractVoterTest.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Security\Tests\Core\Authentication\Voter;
+use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\Voter\AbstractVoter;
/**
@@ -46,6 +47,17 @@ class AbstractVoterTest extends \PHPUnit_Framework_TestCase
$this->assertEquals($expectedVote, $this->voter->vote($this->token, $object, $attributes), $message);
}
+ /**
+ * @dataProvider getData
+ * @group legacy
+ */
+ public function testVoteUsingDeprecatedIsGranted($expectedVote, $object, $attributes, $message)
+ {
+ $voter = new DeprecatedVoterFixture();
+
+ $this->assertEquals($expectedVote, $voter->vote($this->token, $object, $attributes), $message);
+ }
+
public function getData()
{
return array(
@@ -75,6 +87,26 @@ class VoterFixture extends AbstractVoter
return array('foo', 'bar', 'baz');
}
+ protected function voteOnAttribute($attribute, $object, TokenInterface $token)
+ {
+ return $attribute === 'foo';
+ }
+}
+
+class DeprecatedVoterFixture extends AbstractVoter
+{
+ protected function getSupportedClasses()
+ {
+ return array(
+ 'Symfony\Component\Security\Tests\Core\Authentication\Voter\ObjectFixture',
+ );
+ }
+
+ protected function getSupportedAttributes()
+ {
+ return array('foo', 'bar', 'baz');
+ }
+
protected function isGranted($attribute, $object, $user = null)
{
return $attribute === 'foo';