Skip to content

Commit 08418ca

Browse files
Merge branch '6.2' into 6.3
* 6.2: [Tests] Migrate tests to static data providers [Cache] Only validate dbindex parameter when applicable
2 parents 6f8949a + e656666 commit 08418ca

File tree

2 files changed

+48
-7
lines changed

2 files changed

+48
-7
lines changed

Tests/Authentication/AuthenticatorManagerTest.php

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
use Symfony\Component\Security\Http\Authenticator\Passport\SelfValidatingPassport;
3434
use Symfony\Component\Security\Http\Event\AuthenticationTokenCreatedEvent;
3535
use Symfony\Component\Security\Http\Event\CheckPassportEvent;
36+
use Symfony\Component\Security\Http\Tests\Fixtures\DummySupportsAuthenticator;
3637

3738
class AuthenticatorManagerTest extends TestCase
3839
{
@@ -64,15 +65,15 @@ public function testSupports($authenticators, $result)
6465
$this->assertEquals($result, $manager->supports($this->request));
6566
}
6667

67-
public function provideSupportsData()
68+
public static function provideSupportsData()
6869
{
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];
7172

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];
7475

75-
yield [[$this->createAuthenticator(false), $this->createAuthenticator(false)], false];
76+
yield [[self::createDummySupportsAuthenticator(false), self::createDummySupportsAuthenticator(false)], false];
7677
yield [[], false];
7778
}
7879

@@ -347,14 +348,19 @@ public function log($level, $message, array $context = []): void
347348
$this->assertStringContainsString('Mock_TestInteractiveAuthenticator', $logger->logContexts[0]['authenticator']);
348349
}
349350

350-
private function createAuthenticator($supports = true)
351+
private function createAuthenticator(?bool $supports = true)
351352
{
352353
$authenticator = $this->createMock(TestInteractiveAuthenticator::class);
353354
$authenticator->expects($this->any())->method('supports')->willReturn($supports);
354355

355356
return $authenticator;
356357
}
357358

359+
private static function createDummySupportsAuthenticator(?bool $supports = true)
360+
{
361+
return new DummySupportsAuthenticator($supports);
362+
}
363+
358364
private function createManager($authenticators, $firewallName = 'main', $eraseCredentials = true, array $requiredBadges = [], LoggerInterface $logger = null)
359365
{
360366
return new AuthenticatorManager($authenticators, $this->tokenStorage, $this->eventDispatcher, $firewallName, $logger, $eraseCredentials, true, $requiredBadges);
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Security\Http\Tests\Fixtures;
13+
14+
use Symfony\Component\HttpFoundation\Request;
15+
use Symfony\Component\HttpFoundation\Response;
16+
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
17+
use Symfony\Component\Security\Core\Exception\AuthenticationException;
18+
use Symfony\Component\Security\Http\Authenticator\AuthenticatorInterface;
19+
use Symfony\Component\Security\Http\Authenticator\Passport\Passport;
20+
use Symfony\Component\Security\Http\Authenticator\Passport\PassportInterface;
21+
22+
class DummySupportsAuthenticator extends DummyAuthenticator
23+
{
24+
private $supports;
25+
26+
public function __construct(?bool $supports)
27+
{
28+
$this->supports = $supports;
29+
}
30+
31+
public function supports(Request $request): ?bool
32+
{
33+
return $this->supports;
34+
}
35+
}

0 commit comments

Comments
 (0)