From bc066fb3e7e217132e2062f8336328869f386ebc Mon Sep 17 00:00:00 2001 From: Abdellatif Ait boudad Date: Sat, 14 Mar 2015 11:42:25 +0000 Subject: [PATCH 1/3] [translation][initialize cache] Remove dead code. --- src/Symfony/Component/Translation/Translator.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/Symfony/Component/Translation/Translator.php b/src/Symfony/Component/Translation/Translator.php index 356a21b5923e1..30bdc53384880 100644 --- a/src/Symfony/Component/Translation/Translator.php +++ b/src/Symfony/Component/Translation/Translator.php @@ -351,12 +351,6 @@ private function initializeCacheCatalogue($locale) return; } - if (null === $this->cacheDir) { - $this->initialize(); - - return $this->loadCatalogue($locale); - } - $this->assertValidLocale($locale); $cache = new ConfigCache($this->cacheDir.'/catalogue.'.$locale.'.php', $this->debug); if (!$cache->isFresh()) { From 3ae52ed739cce1f891d01d3223e7102f19fb5a5a Mon Sep 17 00:00:00 2001 From: Ryan Weaver Date: Sat, 14 Mar 2015 19:44:00 -0400 Subject: [PATCH 2/3] Fixing wrong variable name from #13519 --- src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index 0b0c2dc2e7e3d..009f591a87778 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -1223,7 +1223,7 @@ private function dumpValue($value, $interpolate = true) if (null !== $value->getFactoryClass()) { return sprintf("call_user_func(array(%s, '%s')%s)", $this->dumpValue($value->getFactoryClass()), $value->getFactoryMethod(), count($arguments) > 0 ? ', '.implode(', ', $arguments) : ''); } elseif (null !== $value->getFactoryService()) { - $service = $this->dumpValue($definition->getFactoryService()); + $service = $this->dumpValue($value->getFactoryService()); return sprintf("%s->%s(%s)", 0 === strpos($service, '$') ? sprintf('$this->get(%s)', $service) : $this->getServiceCall($value->getFactoryService()), $value->getFactoryMethod(), implode(', ', $arguments)); } else { From b8d42b368ba045e97ff4c48933cf83454ae3f1b0 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Sun, 15 Mar 2015 17:33:36 +0100 Subject: [PATCH 3/3] `ResolveParameterPlaceHoldersPass` unit tests --- .../ResolveParameterPlaceHoldersPassTest.php | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveParameterPlaceHoldersPassTest.php diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveParameterPlaceHoldersPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveParameterPlaceHoldersPassTest.php new file mode 100644 index 0000000000000..e08b84a73ac03 --- /dev/null +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveParameterPlaceHoldersPassTest.php @@ -0,0 +1,91 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\DependencyInjection\Tests\Compiler; + +use Symfony\Component\DependencyInjection\Compiler\ResolveParameterPlaceHoldersPass; +use Symfony\Component\DependencyInjection\ContainerBuilder; + +class ResolveParameterPlaceHoldersPassTest extends \PHPUnit_Framework_TestCase +{ + private $compilerPass; + private $container; + private $fooDefinition; + + protected function setUp() + { + $this->compilerPass = new ResolveParameterPlaceHoldersPass(); + $this->container = $this->createContainerBuilder(); + $this->compilerPass->process($this->container); + $this->fooDefinition = $this->container->getDefinition('foo'); + } + + public function testClassParametersShouldBeResolved() + { + $this->assertSame('Foo', $this->fooDefinition->getClass()); + } + + public function testFactoryClassParametersShouldBeResolved() + { + $this->assertSame('FooFactory', $this->fooDefinition->getFactoryClass()); + } + + public function testArgumentParametersShouldBeResolved() + { + $this->assertSame(array('bar', 'baz'), $this->fooDefinition->getArguments()); + } + + public function testMethodCallParametersShouldBeResolved() + { + $this->assertSame(array(array('foobar', array('bar', 'baz'))), $this->fooDefinition->getMethodCalls()); + } + + public function testPropertyParametersShouldBeResolved() + { + $this->assertSame(array('bar' => 'baz'), $this->fooDefinition->getProperties()); + } + + public function testFileParametersShouldBeResolved() + { + $this->assertSame('foo.php', $this->fooDefinition->getFile()); + } + + public function testAliasParametersShouldBeResolved() + { + $this->assertSame('foo', $this->container->getAlias('bar')->__toString()); + } + + private function createContainerBuilder() + { + $containerBuilder = new ContainerBuilder(); + + $containerBuilder->setParameter('foo.class', 'Foo'); + $containerBuilder->setParameter('foo.factory.class', 'FooFactory'); + $containerBuilder->setParameter('foo.arg1', 'bar'); + $containerBuilder->setParameter('foo.arg2', 'baz'); + $containerBuilder->setParameter('foo.method', 'foobar'); + $containerBuilder->setParameter('foo.property.name', 'bar'); + $containerBuilder->setParameter('foo.property.value', 'baz'); + $containerBuilder->setParameter('foo.file', 'foo.php'); + $containerBuilder->setParameter('alias.id', 'bar'); + + $fooDefinition = $containerBuilder->register('foo', '%foo.class%'); + $fooDefinition->setFactoryClass('%foo.factory.class%'); + $fooDefinition->setArguments(array('%foo.arg1%', '%foo.arg2%')); + $fooDefinition->addMethodCall('%foo.method%', array('%foo.arg1%', '%foo.arg2%')); + $fooDefinition->setProperty('%foo.property.name%', '%foo.property.value%'); + $fooDefinition->setFile('%foo.file%'); + + $containerBuilder->setAlias('%alias.id%', 'foo'); + + return $containerBuilder; + } +}