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