Skip to content

Commit 5663ef0

Browse files
committed
Merge branch '5.4' into 6.2
* 5.4: Fix LICENSE CI check fixes retrieving multiple values for extra fields [String] Remove duplicates in fold maps fail with a meaningful error when a needed package is missing [DependencyInjection] Fix combinatory explosion when autowiring union and intersection types Update license years (last time) [Tests] New iteration of removing `$this` occurrences in future static data providers
2 parents 3a26dde + e709251 commit 5663ef0

File tree

6 files changed

+47
-38
lines changed

6 files changed

+47
-38
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2004-2023 Fabien Potencier
1+
Copyright (c) 2004-present Fabien Potencier
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

Test/AccessDecisionStrategyTestCase.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,27 +45,36 @@ abstract public function provideStrategyTests(): iterable;
4545
/**
4646
* @return VoterInterface[]
4747
*/
48-
final protected function getVoters(int $grants, int $denies, int $abstains): array
48+
final protected static function getVoters(int $grants, int $denies, int $abstains): array
4949
{
5050
$voters = [];
5151
for ($i = 0; $i < $grants; ++$i) {
52-
$voters[] = $this->getVoter(VoterInterface::ACCESS_GRANTED);
52+
$voters[] = static::getVoter(VoterInterface::ACCESS_GRANTED);
5353
}
5454
for ($i = 0; $i < $denies; ++$i) {
55-
$voters[] = $this->getVoter(VoterInterface::ACCESS_DENIED);
55+
$voters[] = static::getVoter(VoterInterface::ACCESS_DENIED);
5656
}
5757
for ($i = 0; $i < $abstains; ++$i) {
58-
$voters[] = $this->getVoter(VoterInterface::ACCESS_ABSTAIN);
58+
$voters[] = static::getVoter(VoterInterface::ACCESS_ABSTAIN);
5959
}
6060

6161
return $voters;
6262
}
6363

64-
final protected function getVoter(int $vote): VoterInterface
64+
final protected static function getVoter(int $vote): VoterInterface
6565
{
66-
$voter = $this->createMock(VoterInterface::class);
67-
$voter->method('vote')->willReturn($vote);
66+
return new class($vote) implements VoterInterface {
67+
private $vote;
6868

69-
return $voter;
69+
public function __construct(int $vote)
70+
{
71+
$this->vote = $vote;
72+
}
73+
74+
public function vote(TokenInterface $token, $subject, array $attributes): int
75+
{
76+
return $this->vote;
77+
}
78+
};
7079
}
7180
}

Tests/Authorization/Strategy/AffirmativeStrategyTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ public function provideStrategyTests(): iterable
2020
{
2121
$strategy = new AffirmativeStrategy();
2222

23-
yield [$strategy, $this->getVoters(1, 0, 0), true];
24-
yield [$strategy, $this->getVoters(1, 2, 0), true];
25-
yield [$strategy, $this->getVoters(0, 1, 0), false];
26-
yield [$strategy, $this->getVoters(0, 0, 1), false];
23+
yield [$strategy, static::getVoters(1, 0, 0), true];
24+
yield [$strategy, static::getVoters(1, 2, 0), true];
25+
yield [$strategy, static::getVoters(0, 1, 0), false];
26+
yield [$strategy, static::getVoters(0, 0, 1), false];
2727

2828
$strategy = new AffirmativeStrategy(true);
2929

30-
yield [$strategy, $this->getVoters(0, 0, 1), true];
30+
yield [$strategy, static::getVoters(0, 0, 1), true];
3131
}
3232
}

Tests/Authorization/Strategy/ConsensusStrategyTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ public function provideStrategyTests(): iterable
2020
{
2121
$strategy = new ConsensusStrategy();
2222

23-
yield [$strategy, $this->getVoters(1, 0, 0), true];
24-
yield [$strategy, $this->getVoters(1, 2, 0), false];
25-
yield [$strategy, $this->getVoters(2, 1, 0), true];
26-
yield [$strategy, $this->getVoters(0, 0, 1), false];
23+
yield [$strategy, static::getVoters(1, 0, 0), true];
24+
yield [$strategy, static::getVoters(1, 2, 0), false];
25+
yield [$strategy, static::getVoters(2, 1, 0), true];
26+
yield [$strategy, static::getVoters(0, 0, 1), false];
2727

28-
yield [$strategy, $this->getVoters(2, 2, 0), true];
29-
yield [$strategy, $this->getVoters(2, 2, 1), true];
28+
yield [$strategy, static::getVoters(2, 2, 0), true];
29+
yield [$strategy, static::getVoters(2, 2, 1), true];
3030

3131
$strategy = new ConsensusStrategy(true);
3232

33-
yield [$strategy, $this->getVoters(0, 0, 1), true];
33+
yield [$strategy, static::getVoters(0, 0, 1), true];
3434

3535
$strategy = new ConsensusStrategy(false, false);
3636

37-
yield [$strategy, $this->getVoters(2, 2, 0), false];
38-
yield [$strategy, $this->getVoters(2, 2, 1), false];
37+
yield [$strategy, static::getVoters(2, 2, 0), false];
38+
yield [$strategy, static::getVoters(2, 2, 1), false];
3939
}
4040
}

Tests/Authorization/Strategy/PriorityStrategyTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,23 +22,23 @@ public function provideStrategyTests(): iterable
2222
$strategy = new PriorityStrategy();
2323

2424
yield [$strategy, [
25-
$this->getVoter(VoterInterface::ACCESS_ABSTAIN),
26-
$this->getVoter(VoterInterface::ACCESS_GRANTED),
27-
$this->getVoter(VoterInterface::ACCESS_DENIED),
28-
$this->getVoter(VoterInterface::ACCESS_DENIED),
25+
static::getVoter(VoterInterface::ACCESS_ABSTAIN),
26+
static::getVoter(VoterInterface::ACCESS_GRANTED),
27+
static::getVoter(VoterInterface::ACCESS_DENIED),
28+
static::getVoter(VoterInterface::ACCESS_DENIED),
2929
], true];
3030

3131
yield [$strategy, [
32-
$this->getVoter(VoterInterface::ACCESS_ABSTAIN),
33-
$this->getVoter(VoterInterface::ACCESS_DENIED),
34-
$this->getVoter(VoterInterface::ACCESS_GRANTED),
35-
$this->getVoter(VoterInterface::ACCESS_GRANTED),
32+
static::getVoter(VoterInterface::ACCESS_ABSTAIN),
33+
static::getVoter(VoterInterface::ACCESS_DENIED),
34+
static::getVoter(VoterInterface::ACCESS_GRANTED),
35+
static::getVoter(VoterInterface::ACCESS_GRANTED),
3636
], false];
3737

38-
yield [$strategy, $this->getVoters(0, 0, 2), false];
38+
yield [$strategy, static::getVoters(0, 0, 2), false];
3939

4040
$strategy = new PriorityStrategy(true);
4141

42-
yield [$strategy, $this->getVoters(0, 0, 2), true];
42+
yield [$strategy, static::getVoters(0, 0, 2), true];
4343
}
4444
}

Tests/Authorization/Strategy/UnanimousStrategyTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ public function provideStrategyTests(): iterable
2020
{
2121
$strategy = new UnanimousStrategy();
2222

23-
yield [$strategy, $this->getVoters(1, 0, 0), true];
24-
yield [$strategy, $this->getVoters(1, 0, 1), true];
25-
yield [$strategy, $this->getVoters(1, 1, 0), false];
23+
yield [$strategy, static::getVoters(1, 0, 0), true];
24+
yield [$strategy, static::getVoters(1, 0, 1), true];
25+
yield [$strategy, static::getVoters(1, 1, 0), false];
2626

27-
yield [$strategy, $this->getVoters(0, 0, 2), false];
27+
yield [$strategy, static::getVoters(0, 0, 2), false];
2828

2929
$strategy = new UnanimousStrategy(true);
3030

31-
yield [$strategy, $this->getVoters(0, 0, 2), true];
31+
yield [$strategy, static::getVoters(0, 0, 2), true];
3232
}
3333
}

0 commit comments

Comments
 (0)