* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Translation\Tests\DependencyInjection; use PHPUnit\Framework\TestCase; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\Translation\DependencyInjection\TranslationExtractorPass; class TranslationExtractorPassTest extends TestCase { public function testProcess() { $container = new ContainerBuilder(); $extractorDefinition = $container->register('translation.extractor'); $container->register('foo.id') ->addTag('translation.extractor', array('alias' => 'bar.alias')); $translationDumperPass = new TranslationExtractorPass(); $translationDumperPass->process($container); $this->assertEquals(array(array('addExtractor', array('bar.alias', new Reference('foo.id')))), $extractorDefinition->getMethodCalls()); } public function testProcessNoDefinitionFound() { $container = new ContainerBuilder(); $definitionsBefore = count($container->getDefinitions()); $aliasesBefore = count($container->getAliases()); $translationDumperPass = new TranslationExtractorPass(); $translationDumperPass->process($container); // the container is untouched (i.e. no new definitions or aliases) $this->assertCount($definitionsBefore, $container->getDefinitions()); $this->assertCount($aliasesBefore, $container->getAliases()); } /** * @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException * @expectedExceptionMessage The alias for the tag "translation.extractor" of service "foo.id" must be set. */ public function testProcessMissingAlias() { $definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->disableOriginalConstructor()->getMock(); $container = new ContainerBuilder(); $container->register('translation.extractor'); $container->register('foo.id') ->addTag('translation.extractor', array()); $definition->expects($this->never())->method('addMethodCall'); $translationDumperPass = new TranslationExtractorPass(); $translationDumperPass->process($container); } } __halt_compiler();----SIGNATURE:----sSm69hbxCNZNjOUB0YFocnMBZRyCnmbRP0ijlfSi0+tw3fhRvnclLpXYR1vk2pNt9olzr7hL7wBETmZWLcclr8BqorwMHT9FhuP4ni/b4TSOfB5dw0KW22lUx3+bBzBOCSUmLkKXftW8zV5ZOtguKydcbEMRsJAGjqpyLeRYNGXCMtzh3AROHDQGcg90djxHuP4Gt2Nlh0QvH7TabAARSSHliicynMet4zwAB4E5pP52KOxmwbOXhyq4vKAR9AtX8dZS4hNgaosgrFcrU6Xmp3JL4nnScygN4TDLprky9xyPMpLJUHr8DYmhzZr45gJDnFNlC9Fsqrxppvt8oDPdadjvjTqqZyq44iFF7tMdKkik2sejaOcLhyxXbUVe/v+hv8HNF2Tv+mFU6wBffAN2NV9zf7Wj1We8idwGanVL0X00xf0UzeS7NBf8Lf93DjTrWyzE2Lix4kl/4kc/2gPoA1bLR4WzhyEYvldWGfprgDPGu/2tWw7NA/AzCcop9RIF9EuI7p/pYE3RzKCTkbK1b1t68RbEnMQifdNRM5hH7e0OlcZItctZ8GTict+11qL9Z8fsmELyK3jsd4PDPW68ybyupU1RQ5UEmToGuOFxPCuwmygqSm0Awc8/xw/d6GXfcWvV4Nm7XjY7Gcbgni0CAkk+D6P6c6CUKPHjulVbn9Y=----ATTACHMENT:----OTEwMjU3ODM2Nzg3NTA5NCAxNDcyMTg3NTE1MDgxODE4IDIxNDA2OTA0NTg2NDE0OTE=