mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Merge branch 'upgrade-sf3' of framagit.org:Chill-project/Chill-Main into upgrade-sf3
merge...
This commit is contained in:
commit
fac8506893
@ -19,7 +19,8 @@
|
||||
|
||||
namespace Chill\MainBundle\Security\Authorization;
|
||||
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\AbstractVoter;
|
||||
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
|
||||
|
||||
/**
|
||||
* Voter for Chill software.
|
||||
@ -29,8 +30,26 @@ use Symfony\Component\Security\Core\Authorization\Voter\AbstractVoter;
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
abstract class AbstractChillVoter extends AbstractVoter implements ChillVoterInterface
|
||||
abstract class AbstractChillVoter extends Voter implements ChillVoterInterface
|
||||
{
|
||||
protected function supports($attribute, $subject)
|
||||
{
|
||||
@trigger_error('This voter should implements the new `supports` '
|
||||
. 'methods introduced by Symfony 3.0, and do not rely on '
|
||||
. 'getSupportedAttributes and getSupportedClasses methods.',
|
||||
E_USER_DEPRECATED);
|
||||
|
||||
return \in_array($attribute, $this->getSupportedAttributes($attribute))
|
||||
&& \in_array(\get_class($subject), $this->getSupportedClasses());
|
||||
}
|
||||
|
||||
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
|
||||
{
|
||||
@trigger_error('This voter should implements the new `voteOnAttribute` '
|
||||
. 'methods introduced by Symfony 3.0, and do not rely on '
|
||||
. 'isGranted method', E_USER_DEPRECATED);
|
||||
|
||||
return $this->isGranted($attribute, $subject, $token->getUser());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -210,19 +210,28 @@ abstract class AbstractAggregatorTest extends KernelTestCase
|
||||
public function testAlterQuery(QueryBuilder $query, $data)
|
||||
{
|
||||
// retains informations about query
|
||||
$nbOfFrom = count($query->getDQLPart('from'));
|
||||
$nbOfWhere = count($query->getDQLPart('where'));
|
||||
$nbOfSelect = count($query->getDQLPart('select'));
|
||||
$nbOfFrom = $query->getDQLPart('from') !== null ?
|
||||
count($query->getDQLPart('from')) : 0;
|
||||
$nbOfWhere = $query->getDQLPart('where') !== null ?
|
||||
count($query->getDQLPart('where')) : 0;
|
||||
$nbOfSelect = $query->getDQLPart('select') !== null ?
|
||||
count($query->getDQLPart('select')) : 0;
|
||||
|
||||
$this->getAggregator()->alterQuery($query, $data);
|
||||
|
||||
$this->assertGreaterThanOrEqual($nbOfFrom, count($query->getDQLPart('from')),
|
||||
$this->assertGreaterThanOrEqual(
|
||||
$nbOfFrom,
|
||||
$query->getDQLPart('from') !== null ? count($query->getDQLPart('from')) : 0,
|
||||
"Test that there are equal or more 'from' clause after that the filter has
|
||||
altered the query");
|
||||
$this->assertGreaterThanOrEqual($nbOfWhere, count($query->getDQLPart('where')),
|
||||
$this->assertGreaterThanOrEqual(
|
||||
$nbOfWhere,
|
||||
$query->getDQLPart('where') !== null ? count($query->getDQLPart('where')) : 0,
|
||||
"Test that there are equal or more 'where' clause after that the filter has"
|
||||
. "altered the query");
|
||||
$this->assertGreaterThanOrEqual($nbOfSelect, count($query->getDQLPart('select')),
|
||||
$this->assertGreaterThanOrEqual(
|
||||
$nbOfSelect,
|
||||
$query->getDQLPart('select') !== null ? count($query->getDQLPart('select')) : 0,
|
||||
"Test that the filter has no altered the 'select' part of the query");
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user