summaryrefslogtreecommitdiff
path: root/vendor/symfony/translation/Tests/DependencyInjection
diff options
context:
space:
mode:
authorGreg Roach <fisharebest@webtrees.net>2019-06-03 14:19:10 +0100
committerGreg Roach <fisharebest@webtrees.net>2019-06-03 14:19:10 +0100
commit69c8d4f5c90cef75da102f92e4e992d03a8f1cd8 (patch)
tree4f956848961891482b64ee2cd5c8d7290936e354 /vendor/symfony/translation/Tests/DependencyInjection
parent425f99bc29ab9e477e5407b5c86da5c85ba47461 (diff)
downloadwebtrees-69c8d4f5c90cef75da102f92e4e992d03a8f1cd8.tar.gz
webtrees-69c8d4f5c90cef75da102f92e4e992d03a8f1cd8.tar.bz2
webtrees-69c8d4f5c90cef75da102f92e4e992d03a8f1cd8.zip
:Update vendor dependencies
Diffstat (limited to 'vendor/symfony/translation/Tests/DependencyInjection')
-rw-r--r--vendor/symfony/translation/Tests/DependencyInjection/TranslationPassTest.php65
-rw-r--r--vendor/symfony/translation/Tests/DependencyInjection/TranslationPathsPassTest.php89
-rw-r--r--vendor/symfony/translation/Tests/DependencyInjection/fixtures/ControllerArguments.php16
-rw-r--r--vendor/symfony/translation/Tests/DependencyInjection/fixtures/ServiceArguments.php12
-rw-r--r--vendor/symfony/translation/Tests/DependencyInjection/fixtures/ServiceMethodCalls.php12
-rw-r--r--vendor/symfony/translation/Tests/DependencyInjection/fixtures/ServiceProperties.php8
-rw-r--r--vendor/symfony/translation/Tests/DependencyInjection/fixtures/ServiceSubscriber.php19
7 files changed, 221 insertions, 0 deletions
diff --git a/vendor/symfony/translation/Tests/DependencyInjection/TranslationPassTest.php b/vendor/symfony/translation/Tests/DependencyInjection/TranslationPassTest.php
index 8b9c03d991..f62fc85ebc 100644
--- a/vendor/symfony/translation/Tests/DependencyInjection/TranslationPassTest.php
+++ b/vendor/symfony/translation/Tests/DependencyInjection/TranslationPassTest.php
@@ -54,4 +54,69 @@ class TranslationPassTest extends TestCase
$expected = ['translation.xliff_loader' => new ServiceClosureArgument(new Reference('translation.xliff_loader'))];
$this->assertEquals($expected, $container->getDefinition((string) $translator->getArgument(0))->getArgument(0));
}
+
+ public function testValidCommandsViewPathsArgument()
+ {
+ $container = new ContainerBuilder();
+ $container->register('translator.default')
+ ->setArguments([null, null, null, null])
+ ;
+ $debugCommand = $container->register('console.command.translation_debug')
+ ->setArguments([null, null, null, null, null, [], []])
+ ;
+ $updateCommand = $container->register('console.command.translation_update')
+ ->setArguments([null, null, null, null, null, null, [], []])
+ ;
+ $container->register('twig.template_iterator')
+ ->setArguments([null, null, ['other/templates' => null, 'tpl' => 'App']])
+ ;
+ $container->setParameter('twig.default_path', 'templates');
+
+ $pass = new TranslatorPass('translator.default');
+ $pass->process($container);
+
+ $expectedViewPaths = ['other/templates', 'tpl'];
+
+ $this->assertSame('templates', $debugCommand->getArgument(4));
+ $this->assertSame('templates', $updateCommand->getArgument(5));
+ $this->assertSame($expectedViewPaths, $debugCommand->getArgument(6));
+ $this->assertSame($expectedViewPaths, $updateCommand->getArgument(7));
+ }
+
+ public function testCommandsViewPathsArgumentsAreIgnoredWithOldServiceDefinitions()
+ {
+ $container = new ContainerBuilder();
+ $container->register('translator.default')
+ ->setArguments([null, null, null, null])
+ ;
+ $debugCommand = $container->register('console.command.translation_debug')
+ ->setArguments([
+ new Reference('translator'),
+ new Reference('translation.reader'),
+ new Reference('translation.extractor'),
+ '%translator.default_path%',
+ null,
+ ])
+ ;
+ $updateCommand = $container->register('console.command.translation_update')
+ ->setArguments([
+ new Reference('translation.writer'),
+ new Reference('translation.reader'),
+ new Reference('translation.extractor'),
+ '%kernel.default_locale%',
+ '%translator.default_path%',
+ null,
+ ])
+ ;
+ $container->register('twig.template_iterator')
+ ->setArguments([null, null, ['other/templates' => null, 'tpl' => 'App']])
+ ;
+ $container->setParameter('twig.default_path', 'templates');
+
+ $pass = new TranslatorPass('translator.default');
+ $pass->process($container);
+
+ $this->assertSame('templates', $debugCommand->getArgument(4));
+ $this->assertSame('templates', $updateCommand->getArgument(5));
+ }
}
diff --git a/vendor/symfony/translation/Tests/DependencyInjection/TranslationPathsPassTest.php b/vendor/symfony/translation/Tests/DependencyInjection/TranslationPathsPassTest.php
new file mode 100644
index 0000000000..42ab398dff
--- /dev/null
+++ b/vendor/symfony/translation/Tests/DependencyInjection/TranslationPathsPassTest.php
@@ -0,0 +1,89 @@
+<?php
+
+/*
+ * This file is part of the Symfony package.
+ *
+ * (c) Fabien Potencier <fabien@symfony.com>
+ *
+ * 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\Argument\ServiceClosureArgument;
+use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\Definition;
+use Symfony\Component\DependencyInjection\Reference;
+use Symfony\Component\DependencyInjection\ServiceLocator;
+use Symfony\Component\Translation\DependencyInjection\TranslatorPathsPass;
+use Symfony\Component\Translation\Tests\DependencyInjection\fixtures\ControllerArguments;
+use Symfony\Component\Translation\Tests\DependencyInjection\fixtures\ServiceArguments;
+use Symfony\Component\Translation\Tests\DependencyInjection\fixtures\ServiceMethodCalls;
+use Symfony\Component\Translation\Tests\DependencyInjection\fixtures\ServiceProperties;
+use Symfony\Component\Translation\Tests\DependencyInjection\fixtures\ServiceSubscriber;
+
+class TranslationPathsPassTest extends TestCase
+{
+ public function testProcess()
+ {
+ $container = new ContainerBuilder();
+ $container->register('translator');
+ $debugCommand = $container->register('console.command.translation_debug')
+ ->setArguments([null, null, null, null, null, [], []])
+ ;
+ $updateCommand = $container->register('console.command.translation_update')
+ ->setArguments([null, null, null, null, null, null, [], []])
+ ;
+ $container->register(ControllerArguments::class, ControllerArguments::class)
+ ->setTags(['controller.service_arguments'])
+ ;
+ $container->register(ServiceArguments::class, ServiceArguments::class)
+ ->setArguments([new Reference('translator')])
+ ;
+ $container->register(ServiceProperties::class, ServiceProperties::class)
+ ->setProperties([new Reference('translator')])
+ ;
+ $container->register(ServiceMethodCalls::class, ServiceMethodCalls::class)
+ ->setMethodCalls([['setTranslator', [new Reference('translator')]]])
+ ;
+ $container->register('service_rc')
+ ->setArguments([new Definition(), new Reference(ServiceMethodCalls::class)])
+ ;
+ $serviceLocator1 = $container->register('.service_locator.foo', ServiceLocator::class)
+ ->setArguments([new ServiceClosureArgument(new Reference('translator'))])
+ ;
+ $serviceLocator2 = (new Definition(ServiceLocator::class))
+ ->setArguments([ServiceSubscriber::class, new Reference('service_container')])
+ ->setFactory([$serviceLocator1, 'withContext'])
+ ;
+ $container->register('service_subscriber', ServiceSubscriber::class)
+ ->setArguments([$serviceLocator2])
+ ;
+ $container->register('.service_locator.bar', ServiceLocator::class)
+ ->setArguments([[
+ ControllerArguments::class.'::index' => new ServiceClosureArgument(new Reference('.service_locator.foo')),
+ ControllerArguments::class.'::__invoke' => new ServiceClosureArgument(new Reference('.service_locator.foo')),
+ ControllerArguments::class => new ServiceClosureArgument(new Reference('.service_locator.foo')),
+ ]])
+ ;
+ $container->register('argument_resolver.service')
+ ->setArguments([new Reference('.service_locator.bar')])
+ ;
+
+ $pass = new TranslatorPathsPass('translator', 'console.command.translation_debug', 'console.command.translation_update', 'argument_resolver.service');
+ $pass->process($container);
+
+ $expectedPaths = [
+ $container->getReflectionClass(ServiceArguments::class)->getFileName(),
+ $container->getReflectionClass(ServiceProperties::class)->getFileName(),
+ $container->getReflectionClass(ServiceMethodCalls::class)->getFileName(),
+ $container->getReflectionClass(ControllerArguments::class)->getFileName(),
+ $container->getReflectionClass(ServiceSubscriber::class)->getFileName(),
+ ];
+
+ $this->assertSame($expectedPaths, $debugCommand->getArgument(6));
+ $this->assertSame($expectedPaths, $updateCommand->getArgument(7));
+ }
+}
diff --git a/vendor/symfony/translation/Tests/DependencyInjection/fixtures/ControllerArguments.php b/vendor/symfony/translation/Tests/DependencyInjection/fixtures/ControllerArguments.php
new file mode 100644
index 0000000000..97a53fa76b
--- /dev/null
+++ b/vendor/symfony/translation/Tests/DependencyInjection/fixtures/ControllerArguments.php
@@ -0,0 +1,16 @@
+<?php
+
+namespace Symfony\Component\Translation\Tests\DependencyInjection\fixtures;
+
+use Symfony\Contracts\Translation\TranslatorInterface;
+
+class ControllerArguments
+{
+ public function __invoke(TranslatorInterface $translator)
+ {
+ }
+
+ public function index(TranslatorInterface $translator)
+ {
+ }
+}
diff --git a/vendor/symfony/translation/Tests/DependencyInjection/fixtures/ServiceArguments.php b/vendor/symfony/translation/Tests/DependencyInjection/fixtures/ServiceArguments.php
new file mode 100644
index 0000000000..80c629d6e7
--- /dev/null
+++ b/vendor/symfony/translation/Tests/DependencyInjection/fixtures/ServiceArguments.php
@@ -0,0 +1,12 @@
+<?php
+
+namespace Symfony\Component\Translation\Tests\DependencyInjection\fixtures;
+
+use Symfony\Contracts\Translation\TranslatorInterface;
+
+class ServiceArguments
+{
+ public function __construct(TranslatorInterface $translator)
+ {
+ }
+}
diff --git a/vendor/symfony/translation/Tests/DependencyInjection/fixtures/ServiceMethodCalls.php b/vendor/symfony/translation/Tests/DependencyInjection/fixtures/ServiceMethodCalls.php
new file mode 100644
index 0000000000..8998d8909b
--- /dev/null
+++ b/vendor/symfony/translation/Tests/DependencyInjection/fixtures/ServiceMethodCalls.php
@@ -0,0 +1,12 @@
+<?php
+
+namespace Symfony\Component\Translation\Tests\DependencyInjection\fixtures;
+
+use Symfony\Contracts\Translation\TranslatorInterface;
+
+class ServiceMethodCalls
+{
+ public function setTranslator(TranslatorInterface $translator)
+ {
+ }
+}
diff --git a/vendor/symfony/translation/Tests/DependencyInjection/fixtures/ServiceProperties.php b/vendor/symfony/translation/Tests/DependencyInjection/fixtures/ServiceProperties.php
new file mode 100644
index 0000000000..f5098e907c
--- /dev/null
+++ b/vendor/symfony/translation/Tests/DependencyInjection/fixtures/ServiceProperties.php
@@ -0,0 +1,8 @@
+<?php
+
+namespace Symfony\Component\Translation\Tests\DependencyInjection\fixtures;
+
+class ServiceProperties
+{
+ public $translator;
+}
diff --git a/vendor/symfony/translation/Tests/DependencyInjection/fixtures/ServiceSubscriber.php b/vendor/symfony/translation/Tests/DependencyInjection/fixtures/ServiceSubscriber.php
new file mode 100644
index 0000000000..65b60d6fee
--- /dev/null
+++ b/vendor/symfony/translation/Tests/DependencyInjection/fixtures/ServiceSubscriber.php
@@ -0,0 +1,19 @@
+<?php
+
+namespace Symfony\Component\Translation\Tests\DependencyInjection\fixtures;
+
+use Psr\Container\ContainerInterface;
+use Symfony\Contracts\Service\ServiceSubscriberInterface;
+use Symfony\Contracts\Translation\TranslatorInterface;
+
+class ServiceSubscriber implements ServiceSubscriberInterface
+{
+ public function __construct(ContainerInterface $container)
+ {
+ }
+
+ public static function getSubscribedServices()
+ {
+ return ['translator' => TranslatorInterface::class];
+ }
+}