|
33 | 33 | use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport;
|
34 | 34 | use Symfony\Component\Security\Http\Event\AuthenticationTokenCreatedEvent;
|
35 | 35 | use Symfony\Component\Security\Http\Event\CheckPassportEvent;
|
| 36 | +use Symfony\Component\Security\Http\Tests\Fixtures\DummySupportsAuthenticator; |
36 | 37 |
|
37 | 38 | class AuthenticatorManagerTest extends TestCase
|
38 | 39 | {
|
@@ -64,15 +65,15 @@ public function testSupports($authenticators, $result)
|
64 | 65 | $this->assertEquals($result, $manager->supports($this->request));
|
65 | 66 | }
|
66 | 67 |
|
67 |
| - public function provideSupportsData() |
| 68 | + public static function provideSupportsData() |
68 | 69 | {
|
69 |
| - yield [[$this->createAuthenticator(null), $this->createAuthenticator(null)], null]; |
70 |
| - yield [[$this->createAuthenticator(null), $this->createAuthenticator(false)], null]; |
| 70 | + yield [[self::createDummySupportsAuthenticator(null), self::createDummySupportsAuthenticator(null)], null]; |
| 71 | + yield [[self::createDummySupportsAuthenticator(null), self::createDummySupportsAuthenticator(false)], null]; |
71 | 72 |
|
72 |
| - yield [[$this->createAuthenticator(null), $this->createAuthenticator(true)], true]; |
73 |
| - yield [[$this->createAuthenticator(true), $this->createAuthenticator(false)], true]; |
| 73 | + yield [[self::createDummySupportsAuthenticator(null), self::createDummySupportsAuthenticator(true)], true]; |
| 74 | + yield [[self::createDummySupportsAuthenticator(true), self::createDummySupportsAuthenticator(false)], true]; |
74 | 75 |
|
75 |
| - yield [[$this->createAuthenticator(false), $this->createAuthenticator(false)], false]; |
| 76 | + yield [[self::createDummySupportsAuthenticator(false), self::createDummySupportsAuthenticator(false)], false]; |
76 | 77 | yield [[], false];
|
77 | 78 | }
|
78 | 79 |
|
@@ -347,14 +348,19 @@ public function log($level, $message, array $context = []): void
|
347 | 348 | $this->assertStringContainsString('Mock_TestInteractiveAuthenticator', $logger->logContexts[0]['authenticator']);
|
348 | 349 | }
|
349 | 350 |
|
350 |
| - private function createAuthenticator($supports = true) |
| 351 | + private function createAuthenticator(?bool $supports = true) |
351 | 352 | {
|
352 | 353 | $authenticator = $this->createMock(TestInteractiveAuthenticator::class);
|
353 | 354 | $authenticator->expects($this->any())->method('supports')->willReturn($supports);
|
354 | 355 |
|
355 | 356 | return $authenticator;
|
356 | 357 | }
|
357 | 358 |
|
| 359 | + private static function createDummySupportsAuthenticator(?bool $supports = true) |
| 360 | + { |
| 361 | + return new DummySupportsAuthenticator($supports); |
| 362 | + } |
| 363 | + |
358 | 364 | private function createManager($authenticators, $firewallName = 'main', $eraseCredentials = true, array $requiredBadges = [], LoggerInterface $logger = null)
|
359 | 365 | {
|
360 | 366 | return new AuthenticatorManager($authenticators, $this->tokenStorage, $this->eventDispatcher, $firewallName, $logger, $eraseCredentials, true, $requiredBadges);
|
|
0 commit comments