|
20 | 20 | use Symfony\Component\Config\Definition\Builder\NodeDefinition;
|
21 | 21 | use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
|
22 | 22 | use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
|
| 23 | +use Symfony\Component\DependencyInjection\Compiler\DecoratorServicePass; |
23 | 24 | use Symfony\Component\DependencyInjection\Compiler\ResolveChildDefinitionsPass;
|
| 25 | +use Symfony\Component\DependencyInjection\Compiler\ResolveReferencesToAliasesPass; |
24 | 26 | use Symfony\Component\DependencyInjection\ContainerBuilder;
|
25 | 27 | use Symfony\Component\DependencyInjection\Reference;
|
26 | 28 | use Symfony\Component\ExpressionLanguage\Expression;
|
@@ -900,6 +902,30 @@ public function testCustomHasherWithMigrateFrom()
|
900 | 902 | ]);
|
901 | 903 | }
|
902 | 904 |
|
| 905 | + public function testAuthenticatorsDecoration() |
| 906 | + { |
| 907 | + $container = $this->getRawContainer(); |
| 908 | + $container->setParameter('kernel.debug', true); |
| 909 | + $container->getCompilerPassConfig()->setOptimizationPasses([ |
| 910 | + new ResolveChildDefinitionsPass(), |
| 911 | + new DecoratorServicePass(), |
| 912 | + new ResolveReferencesToAliasesPass(), |
| 913 | + ]); |
| 914 | + |
| 915 | + $container->register(TestAuthenticator::class); |
| 916 | + $container->loadFromExtension('security', [ |
| 917 | + 'firewalls' => ['main' => ['custom_authenticator' => TestAuthenticator::class]], |
| 918 | + ]); |
| 919 | + $container->compile(); |
| 920 | + |
| 921 | + /** @var Reference[] $managerAuthenticators */ |
| 922 | + $managerAuthenticators = $container->getDefinition('security.authenticator.manager.main')->getArgument(0); |
| 923 | + $this->assertCount(1, $managerAuthenticators); |
| 924 | + $this->assertSame('debug.'.TestAuthenticator::class, (string) reset($managerAuthenticators), 'AuthenticatorManager must be injected traceable authenticators in debug mode.'); |
| 925 | + |
| 926 | + $this->assertTrue($container->hasDefinition(TestAuthenticator::class), 'Original authenticator must still exist in the container so it can be used outside of the AuthenticatorManager’s context.'); |
| 927 | + } |
| 928 | + |
903 | 929 | protected function getRawContainer()
|
904 | 930 | {
|
905 | 931 | $container = new ContainerBuilder();
|
|
0 commit comments