Skip to content

Commit 26aa837

Browse files
alexandre-dauboisnicolas-grekas
authored andcommitted
[Tests] Migrate data providers to static ones
1 parent 97527a3 commit 26aa837

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

Tests/DataCollector/SecurityDataCollectorTest.php

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Symfony\Component\HttpKernel\HttpKernelInterface;
2525
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
2626
use Symfony\Component\Security\Core\Authentication\Token\SwitchUserToken;
27+
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
2728
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
2829
use Symfony\Component\Security\Core\Authorization\TraceableAccessDecisionManager;
2930
use Symfony\Component\Security\Core\Authorization\Voter\TraceableVoter;
@@ -222,12 +223,17 @@ public function testGetListeners()
222223
$this->assertSame(1, $listenerCalled);
223224
}
224225

225-
public function providerCollectDecisionLog(): \Generator
226+
public static function providerCollectDecisionLog(): \Generator
226227
{
227-
$voter1 = $this->getMockBuilder(VoterInterface::class)->getMockForAbstractClass();
228-
$voter2 = $this->getMockBuilder(VoterInterface::class)->getMockForAbstractClass();
229-
230-
$eventDispatcher = $this->getMockBuilder(EventDispatcherInterface::class)->getMockForAbstractClass();
228+
$voter1 = new DummyVoter();
229+
$voter2 = new DummyVoter();
230+
231+
$eventDispatcher = new class() implements EventDispatcherInterface {
232+
public function dispatch(object $event, string $eventName = null): object
233+
{
234+
return new \stdClass();
235+
}
236+
};
231237
$decoratedVoter1 = new TraceableVoter($voter1, $eventDispatcher);
232238

233239
yield [
@@ -352,7 +358,7 @@ public function testCollectDecisionLog(string $strategy, array $decisionLog, arr
352358
$this->assertSame($dataCollector->getVoterStrategy(), $strategy, 'Wrong value returned by getVoterStrategy');
353359
}
354360

355-
public function provideRoles()
361+
public static function provideRoles()
356362
{
357363
return [
358364
// Basic roles
@@ -383,3 +389,10 @@ private function getRoleHierarchy()
383389
]);
384390
}
385391
}
392+
393+
class DummyVoter implements VoterInterface
394+
{
395+
public function vote(TokenInterface $token, $subject, array $attributes)
396+
{
397+
}
398+
}

0 commit comments

Comments
 (0)