|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <[email protected]> |
| 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\Bundle\SecurityBundle\Tests\DependencyInjection; |
| 13 | + |
| 14 | +use PHPUnit\Framework\TestCase; |
| 15 | +use Symfony\Bundle\SecurityBundle\DependencyInjection\SecurityExtension; |
| 16 | +use Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Fixtures\Authenticator\CustomAuthenticator; |
| 17 | +use Symfony\Bundle\SecurityBundle\Tests\DependencyInjection\Fixtures\UserProvider\CustomProvider; |
| 18 | +use Symfony\Component\Config\FileLocator; |
| 19 | +use Symfony\Component\DependencyInjection\ContainerBuilder; |
| 20 | +use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; |
| 21 | + |
| 22 | +class XmlCustomAuthenticatorTest extends TestCase |
| 23 | +{ |
| 24 | + /** |
| 25 | + * @dataProvider provideXmlConfigurationFile |
| 26 | + */ |
| 27 | + public function testCustomProviderElement(string $configurationFile) |
| 28 | + { |
| 29 | + $container = new ContainerBuilder(); |
| 30 | + $container->setParameter('kernel.debug', false); |
| 31 | + $container->register('cache.system', \stdClass::class); |
| 32 | + |
| 33 | + $security = new SecurityExtension(); |
| 34 | + $security->addAuthenticatorFactory(new CustomAuthenticator()); |
| 35 | + $container->registerExtension($security); |
| 36 | + |
| 37 | + (new XmlFileLoader($container, new FileLocator(__DIR__.'/Fixtures/xml')))->load($configurationFile); |
| 38 | + |
| 39 | + $container->getCompilerPassConfig()->setRemovingPasses([]); |
| 40 | + $container->getCompilerPassConfig()->setAfterRemovingPasses([]); |
| 41 | + $container->compile(); |
| 42 | + |
| 43 | + $this->addToAssertionCount(1); |
| 44 | + } |
| 45 | + |
| 46 | + public static function provideXmlConfigurationFile(): iterable |
| 47 | + { |
| 48 | + yield 'Custom authenticator element under SecurityBundle’s namespace' => ['custom_authenticator_under_security_namespace.xml']; |
| 49 | + yield 'Custom authenticator element under its own namespace' => ['custom_authenticator_under_own_namespace.xml']; |
| 50 | + } |
| 51 | +} |
0 commit comments