minor #15974 [Security] fix tests for the AbstractVoter
class (xabbuh)
This PR was merged into the 2.8 branch.
Discussion
----------
[Security] fix tests for the `AbstractVoter` class
| Q | A
| ------------- | ---
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #15961, #15968
| License | MIT
| Doc PR |
* The `LegacyAbstractVoterTest` class is not needed anymore, tests have
been moved to the `AbstractVoterTest` class tagging them with the
legacy group.
* Tests are applied on `stdClass` object instances. Thus, the legacy
voter fixture class must not support `AbstractVoterTest_Object`
instances, but support `stdClass` objects instead.
* Remove a test that checked for a `BadMethodCallException` being
thrown. This seems to have been added accidentally in #15961.
Commits
-------
9fe3b76
fix tests for the `AbstractVoter` class
This commit is contained in:
commit
3ebe46684a
@ -95,7 +95,7 @@ class AbstractVoterTest_LegacyVoter extends AbstractVoter
|
||||
{
|
||||
protected function getSupportedClasses()
|
||||
{
|
||||
return array('AbstractVoterTest_Object');
|
||||
return array('stdClass');
|
||||
}
|
||||
|
||||
protected function getSupportedAttributes()
|
||||
@ -113,7 +113,7 @@ class AbstractVoterTest_NothingImplementedVoter extends AbstractVoter
|
||||
{
|
||||
protected function getSupportedClasses()
|
||||
{
|
||||
return array('AbstractVoterTest_Object');
|
||||
return array('stdClass');
|
||||
}
|
||||
|
||||
protected function getSupportedAttributes()
|
||||
|
@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user