9fe058a7900577c829cae094a808d1180519496d
[yaffs-website] / web / core / tests / Drupal / Tests / Core / DependencyInjection / Compiler / AuthenticationProviderPassTest.php
1 <?php
2
3 namespace Drupal\Tests\Core\DependencyInjection\Compiler;
4
5 use Drupal\Core\DependencyInjection\Compiler\AuthenticationProviderPass;
6 use Drupal\Core\DependencyInjection\ContainerBuilder;
7 use Drupal\Tests\UnitTestCase;
8 use Symfony\Component\DependencyInjection\Definition;
9 use Symfony\Component\Serializer\Serializer;
10
11 /**
12  * @coversDefaultClass \Drupal\Core\DependencyInjection\Compiler\AuthenticationProviderPass
13  * @group DependencyInjection
14  */
15 class AuthenticationProviderPassTest extends UnitTestCase {
16
17   /**
18    * @covers ::process
19    */
20   public function testEncoders() {
21     $container = new ContainerBuilder();
22     $container->setDefinition('serializer', new Definition(Serializer::class, [[], []]));
23
24     $definition = new Definition('TestClass');
25     $definition->addTag('authentication_provider', ['provider_id' => 'bunny_auth']);
26     $definition->addTag('_provider', ['provider' => 'test_provider_a']);
27     $container->setDefinition('test_provider_a.authentication.bunny_auth', $definition);
28
29     $definition = new Definition('TestClass');
30     $definition->addTag('authentication_provider', ['provider_id' => 'llama_auth', 'priority' => 100]);
31     $definition->addTag('_provider', ['provider' => 'test_provider_a']);
32     $container->setDefinition('test_provider_a.authentication.llama_auth', $definition);
33
34     $definition = new Definition('TestClass');
35     $definition->addTag('authentication_provider', ['provider_id' => 'camel_auth', 'priority' => -100]);
36     $definition->addTag('_provider', ['provider' => 'test_provider_b']);
37     $container->setDefinition('test_provider_b.authentication.camel_auth', $definition);
38
39     $compiler_pass = new AuthenticationProviderPass();
40     $compiler_pass->process($container);
41
42     $this->assertEquals(['bunny_auth' => 'test_provider_a', 'llama_auth' => 'test_provider_a', 'camel_auth' => 'test_provider_b'], $container->getParameter('authentication_providers'));
43   }
44
45 }