summaryrefslogtreecommitdiffstats
path: root/Core/Tests/Authorization
diff options
context:
space:
mode:
authorFabien Potencier <fabien.potencier@gmail.com>2015-09-25 13:44:05 +0200
committerFabien Potencier <fabien.potencier@gmail.com>2015-09-25 13:44:05 +0200
commitd250979823c59287ae69988bc9898632a2eea201 (patch)
treea1a61c102a8bf72d623ebbc0dc37004f999e06ad /Core/Tests/Authorization
parenta99b4984c7212fa88858e26526e4d8e6d4af7a39 (diff)
parent0189f2b2191ba9cec13b7e53265824943d12700f (diff)
downloadsymfony-security-d250979823c59287ae69988bc9898632a2eea201.zip
symfony-security-d250979823c59287ae69988bc9898632a2eea201.tar.gz
symfony-security-d250979823c59287ae69988bc9898632a2eea201.tar.bz2
feature #15151 [Security] Deprecated supportsAttribute and supportsClass methods (WouterJ)
This PR was squashed before being merged into the 2.8 branch (closes #15151). Discussion ---------- [Security] Deprecated supportsAttribute and supportsClass methods These methods aren't used at all in a Symfony application and don't make sense to use in the application. They are only used internally in the voters. This means the voter interface can be made much easier. I'm not sure how we do these deprecations, should we remove the methods from the interface now already? Also, I don't think it's possible to trigger deprecation notices for the voter methods? | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | one of #11742 | License | MIT | Doc PR | - Abstract Voter --- There is one remaining question about the abstract voter. This currently has abstract `getSupportedAttributes()` and `getSupportedClass()` methods. One of the reasons to remove the methods for the interface was that these methods are not flexible. Does it make sense to deprecate these methods as well and replace them by an abstract `protected vote(array $attributes, $class)` method in the `AbstractVoter` (which is called from `AbstractVoter#vote()`) ? Commits ------- 6588708 [Security] Deprecated supportsAttribute and supportsClass methods
Diffstat (limited to 'Core/Tests/Authorization')
-rw-r--r--Core/Tests/Authorization/AccessDecisionManagerTest.php6
-rw-r--r--Core/Tests/Authorization/Voter/AbstractVoterTest.php2
-rw-r--r--Core/Tests/Authorization/Voter/LegacyAbstractVoterTest.php33
3 files changed, 40 insertions, 1 deletions
diff --git a/Core/Tests/Authorization/AccessDecisionManagerTest.php b/Core/Tests/Authorization/AccessDecisionManagerTest.php
index bd876c7..08bbc58 100644
--- a/Core/Tests/Authorization/AccessDecisionManagerTest.php
+++ b/Core/Tests/Authorization/AccessDecisionManagerTest.php
@@ -16,6 +16,9 @@ use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
class AccessDecisionManagerTest extends \PHPUnit_Framework_TestCase
{
+ /**
+ * @group legacy
+ */
public function testSupportsClass()
{
$manager = new AccessDecisionManager(array(
@@ -31,6 +34,9 @@ class AccessDecisionManagerTest extends \PHPUnit_Framework_TestCase
$this->assertFalse($manager->supportsClass('FooClass'));
}
+ /**
+ * @group legacy
+ */
public function testSupportsAttribute()
{
$manager = new AccessDecisionManager(array(
diff --git a/Core/Tests/Authorization/Voter/AbstractVoterTest.php b/Core/Tests/Authorization/Voter/AbstractVoterTest.php
index 4e38fd6..44da147 100644
--- a/Core/Tests/Authorization/Voter/AbstractVoterTest.php
+++ b/Core/Tests/Authorization/Voter/AbstractVoterTest.php
@@ -98,7 +98,7 @@ class DeprecatedVoterFixture extends AbstractVoter
protected function getSupportedClasses()
{
return array(
- 'Symfony\Component\Security\Tests\Core\Authentication\Voter\ObjectFixture',
+ 'Symfony\Component\Security\Core\Tests\Authorization\Voter\ObjectFixture',
);
}
diff --git a/Core/Tests/Authorization/Voter/LegacyAbstractVoterTest.php b/Core/Tests/Authorization/Voter/LegacyAbstractVoterTest.php
new file mode 100644
index 0000000..3a0cf1e
--- /dev/null
+++ b/Core/Tests/Authorization/Voter/LegacyAbstractVoterTest.php
@@ -0,0 +1,33 @@
+<?php
+
+namespace Symfony\Component\Security\Core\Tests\Authorization\Voter;
+
+use Symfony\Component\Security\Core\Authorization\Voter\AbstractVoter;
+
+class LegacyAbstractVoterTest_Voter extends AbstractVoter
+{
+ protected function getSupportedClasses()
+ {
+ return array('AbstractVoterTest_Object');
+ }
+
+ protected function getSupportedAttributes()
+ {
+ return array('EDIT', 'CREATE');
+ }
+
+ protected function isGranted($attribute, $object, $user = null)
+ {
+ return 'EDIT' === $attribute;
+ }
+}
+
+class LegacyAbstractVoterTest extends AbstractVoterTest
+{
+ protected function setUp()
+ {
+ parent::setUp();
+
+ $this->voter = new LegacyAbstractVoterTest_Voter();
+ }
+}