3e02cb434edde6006758594a7fdc59cc8eaea037
[yaffs-website] / vendor / symfony / translation / Tests / DependencyInjection / TranslationDumperPassTest.php
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\Translation\Tests\DependencyInjection;
13
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\DependencyInjection\ContainerBuilder;
16 use Symfony\Component\DependencyInjection\Reference;
17 use Symfony\Component\Translation\DependencyInjection\TranslationDumperPass;
18
19 class TranslationDumperPassTest extends TestCase
20 {
21     public function testProcess()
22     {
23         $container = new ContainerBuilder();
24         $writerDefinition = $container->register('translation.writer');
25         $container->register('foo.id')
26             ->addTag('translation.dumper', array('alias' => 'bar.alias'));
27
28         $translationDumperPass = new TranslationDumperPass();
29         $translationDumperPass->process($container);
30
31         $this->assertEquals(array(array('addDumper', array('bar.alias', new Reference('foo.id')))), $writerDefinition->getMethodCalls());
32     }
33
34     public function testProcessNoDefinitionFound()
35     {
36         $container = new ContainerBuilder();
37
38         $definitionsBefore = count($container->getDefinitions());
39         $aliasesBefore = count($container->getAliases());
40
41         $translationDumperPass = new TranslationDumperPass();
42         $translationDumperPass->process($container);
43
44         // the container is untouched (i.e. no new definitions or aliases)
45         $this->assertCount($definitionsBefore, $container->getDefinitions());
46         $this->assertCount($aliasesBefore, $container->getAliases());
47     }
48 }