* * 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:----RVEEPYD3xxlmhnhWj6z4KbWKMLrYPWfLVx6WQ0VWjzc9tuosAG6gImvK0Apd90IWc9z8DmXfSufKOEJuVjoZvCoFco3SWoU32AlKLiHetAKKBmPuX7OARkFBYvv9ZYNMpFDIIil0REA6jwu7Xb54r6BfC9YQP78xzz/pHjJu6Mc84u3Kb1zMB+Y9w4v6wl558YHgRPyVHozOiu40lpM5MFosxSoNfdmeqKegZp5NaQbpoJQKUY6NxirgnmyHW+WtPi8xWLKBvzKMJnW8PQlI4Djoyilxz1JtSNIhaaPcO/aMT04pWqm7tQ2rqZebMyWbWyso2q8ewexpOkT6OC3Xlfvi0TE0UozsND/5fJcS1fZ0aNVQZgfEgNVMpRoUBT6TE3mVC5qvGddet9vUtTKdq3ibc4i2gYvajMCtVSzFKRqRt2YuZC8S8KbZxTqpkIyc3kZ2fh0haT4uKB/LD3LfjNACFopZiGZoyDlFTXlwD2DPcu8Pw3q4gwRo78NmPyIuDWlp5UMn1dTaA/qq0CRaR/u04np0G28NePhJ8mf7ObeR8XNYbQKdEqq/IlMG2uSLDY+QkQQA1nvSAdJcI8eY/ExWgZFXTlY6AIwHUIn1+IHJaeCN/Y6ZzvLSyNn/k4hBqTVadL2RcFjLO2cXKVhiqTxeHtU0XnBBu7+rMIakU8w=----ATTACHMENT:----ODE2NTc5NzA1MDY2MTQ1NCA1NDQ0NDIzMjM0MjA3MDkyIDk0NDQzMTM3MTYxNDI1MDU=