TranslationDumperPassTest.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Translation\Tests\DependencyInjection;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Component\DependencyInjection\ContainerBuilder;
  13. use Symfony\Component\DependencyInjection\Reference;
  14. use Symfony\Component\Translation\DependencyInjection\TranslationDumperPass;
  15. class TranslationDumperPassTest extends TestCase
  16. {
  17. public function testProcess()
  18. {
  19. $container = new ContainerBuilder();
  20. $writerDefinition = $container->register('translation.writer');
  21. $container->register('foo.id')
  22. ->addTag('translation.dumper', ['alias' => 'bar.alias']);
  23. $translationDumperPass = new TranslationDumperPass();
  24. $translationDumperPass->process($container);
  25. $this->assertEquals([['addDumper', ['bar.alias', new Reference('foo.id')]]], $writerDefinition->getMethodCalls());
  26. }
  27. public function testProcessNoDefinitionFound()
  28. {
  29. $container = new ContainerBuilder();
  30. $definitionsBefore = \count($container->getDefinitions());
  31. $aliasesBefore = \count($container->getAliases());
  32. $translationDumperPass = new TranslationDumperPass();
  33. $translationDumperPass->process($container);
  34. // the container is untouched (i.e. no new definitions or aliases)
  35. $this->assertCount($definitionsBefore, $container->getDefinitions());
  36. $this->assertCount($aliasesBefore, $container->getAliases());
  37. }
  38. }