Skip to content

Commit 17ad6fd

Browse files
committed
Merge branch '2.6' into 2.7
* 2.6: `ResolveParameterPlaceHoldersPass` unit tests Fixing wrong variable name from #13519 [translation][initialize cache] Remove dead code. Conflicts: src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php
2 parents a003380 + be05344 commit 17ad6fd

File tree

3 files changed

+92
-7
lines changed

3 files changed

+92
-7
lines changed

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,7 @@ private function dumpValue($value, $interpolate = true)
13381338
if (null !== $value->getFactoryClass(false)) {
13391339
return sprintf("call_user_func(array(%s, '%s')%s)", $this->dumpValue($value->getFactoryClass(false)), $value->getFactoryMethod(false), count($arguments) > 0 ? ', '.implode(', ', $arguments) : '');
13401340
} elseif (null !== $value->getFactoryService(false)) {
1341-
$service = $this->dumpValue($definition->getFactoryService(false));
1341+
$service = $this->dumpValue($value->getFactoryService(false));
13421342

13431343
return sprintf("%s->%s(%s)", 0 === strpos($service, '$') ? sprintf('$this->get(%s)', $service) : $this->getServiceCall($value->getFactoryService(false)), $value->getFactoryMethod(false), implode(', ', $arguments));
13441344
} else {
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\DependencyInjection\Tests\Compiler;
13+
14+
use Symfony\Component\DependencyInjection\Compiler\ResolveParameterPlaceHoldersPass;
15+
use Symfony\Component\DependencyInjection\ContainerBuilder;
16+
17+
class ResolveParameterPlaceHoldersPassTest extends \PHPUnit_Framework_TestCase
18+
{
19+
private $compilerPass;
20+
private $container;
21+
private $fooDefinition;
22+
23+
protected function setUp()
24+
{
25+
$this->compilerPass = new ResolveParameterPlaceHoldersPass();
26+
$this->container = $this->createContainerBuilder();
27+
$this->compilerPass->process($this->container);
28+
$this->fooDefinition = $this->container->getDefinition('foo');
29+
}
30+
31+
public function testClassParametersShouldBeResolved()
32+
{
33+
$this->assertSame('Foo', $this->fooDefinition->getClass());
34+
}
35+
36+
public function testFactoryClassParametersShouldBeResolved()
37+
{
38+
$this->assertSame('FooFactory', $this->fooDefinition->getFactoryClass());
39+
}
40+
41+
public function testArgumentParametersShouldBeResolved()
42+
{
43+
$this->assertSame(array('bar', 'baz'), $this->fooDefinition->getArguments());
44+
}
45+
46+
public function testMethodCallParametersShouldBeResolved()
47+
{
48+
$this->assertSame(array(array('foobar', array('bar', 'baz'))), $this->fooDefinition->getMethodCalls());
49+
}
50+
51+
public function testPropertyParametersShouldBeResolved()
52+
{
53+
$this->assertSame(array('bar' => 'baz'), $this->fooDefinition->getProperties());
54+
}
55+
56+
public function testFileParametersShouldBeResolved()
57+
{
58+
$this->assertSame('foo.php', $this->fooDefinition->getFile());
59+
}
60+
61+
public function testAliasParametersShouldBeResolved()
62+
{
63+
$this->assertSame('foo', $this->container->getAlias('bar')->__toString());
64+
}
65+
66+
private function createContainerBuilder()
67+
{
68+
$containerBuilder = new ContainerBuilder();
69+
70+
$containerBuilder->setParameter('foo.class', 'Foo');
71+
$containerBuilder->setParameter('foo.factory.class', 'FooFactory');
72+
$containerBuilder->setParameter('foo.arg1', 'bar');
73+
$containerBuilder->setParameter('foo.arg2', 'baz');
74+
$containerBuilder->setParameter('foo.method', 'foobar');
75+
$containerBuilder->setParameter('foo.property.name', 'bar');
76+
$containerBuilder->setParameter('foo.property.value', 'baz');
77+
$containerBuilder->setParameter('foo.file', 'foo.php');
78+
$containerBuilder->setParameter('alias.id', 'bar');
79+
80+
$fooDefinition = $containerBuilder->register('foo', '%foo.class%');
81+
$fooDefinition->setFactoryClass('%foo.factory.class%');
82+
$fooDefinition->setArguments(array('%foo.arg1%', '%foo.arg2%'));
83+
$fooDefinition->addMethodCall('%foo.method%', array('%foo.arg1%', '%foo.arg2%'));
84+
$fooDefinition->setProperty('%foo.property.name%', '%foo.property.value%');
85+
$fooDefinition->setFile('%foo.file%');
86+
87+
$containerBuilder->setAlias('%alias.id%', 'foo');
88+
89+
return $containerBuilder;
90+
}
91+
}

src/Symfony/Component/Translation/Translator.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -354,12 +354,6 @@ private function initializeCacheCatalogue($locale, $forceRefresh = false)
354354
return;
355355
}
356356

357-
if (null === $this->cacheDir) {
358-
$this->initialize();
359-
360-
return $this->loadCatalogue($locale);
361-
}
362-
363357
$this->assertValidLocale($locale);
364358
$cache = new ConfigCache($this->cacheDir.'/catalogue.'.$locale.'.php', $this->debug);
365359
if ($forceRefresh || !$cache->isFresh()) {

0 commit comments

Comments
 (0)