TranslatorPassTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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\Bundle\FrameworkBundle\Tests\DependencyInjection\Compiler;
  11. use PHPUnit\Framework\TestCase;
  12. use Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\TranslatorPass;
  13. use Symfony\Component\DependencyInjection\ContainerBuilder;
  14. use Symfony\Component\DependencyInjection\Reference;
  15. class TranslatorPassTest extends TestCase
  16. {
  17. public function testValidCollector()
  18. {
  19. $container = new ContainerBuilder();
  20. $container->register('translator.default')
  21. ->setArguments(array(null, null, array()));
  22. $translationLoaderDefinition = $container->register('translation.loader');
  23. $container->register('xliff')
  24. ->addTag('translation.loader', array('alias' => 'xliff', 'legacy-alias' => 'xlf'));
  25. $pass = new TranslatorPass();
  26. $pass->process($container);
  27. $this->assertEquals(
  28. array(
  29. array('addLoader', array('xliff', new Reference('xliff'))),
  30. array('addLoader', array('xlf', new Reference('xliff'))),
  31. ),
  32. $translationLoaderDefinition->getMethodCalls()
  33. );
  34. }
  35. }