TranslationDumperPassTest.php 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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', array('alias' => 'bar.alias'));
  23. $translationDumperPass = new TranslationDumperPass();
  24. $translationDumperPass->process($container);
  25. $this->assertEquals(array(array('addDumper', array('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. }