4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Translation\Tests\DependencyInjection;
14 use PHPUnit\Framework\TestCase;
15 use Symfony\Component\DependencyInjection\ContainerBuilder;
16 use Symfony\Component\DependencyInjection\Reference;
17 use Symfony\Component\Translation\DependencyInjection\TranslationDumperPass;
19 class TranslationDumperPassTest extends TestCase
21 public function testProcess()
23 $container = new ContainerBuilder();
24 $writerDefinition = $container->register('translation.writer');
25 $container->register('foo.id')
26 ->addTag('translation.dumper', array('alias' => 'bar.alias'));
28 $translationDumperPass = new TranslationDumperPass();
29 $translationDumperPass->process($container);
31 $this->assertEquals(array(array('addDumper', array('bar.alias', new Reference('foo.id')))), $writerDefinition->getMethodCalls());
34 public function testProcessNoDefinitionFound()
36 $container = new ContainerBuilder();
38 $definitionsBefore = count($container->getDefinitions());
39 $aliasesBefore = count($container->getAliases());
41 $translationDumperPass = new TranslationDumperPass();
42 $translationDumperPass->process($container);
44 // the container is untouched (i.e. no new definitions or aliases)
45 $this->assertCount($definitionsBefore, $container->getDefinitions());
46 $this->assertCount($aliasesBefore, $container->getAliases());