Skip to content

Commit d68c307

Browse files
committed
Merge branch '2.3' into 2.6
* 2.3: `ResolveParameterPlaceHoldersPass` unit tests Fixing wrong variable name from #13519
2 parents a4aa14f + 3923e16 commit d68c307

File tree

2 files changed

+92
-1
lines changed

2 files changed

+92
-1
lines changed

Dumper/PhpDumper.php

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

13371337
return sprintf("%s->%s(%s)", 0 === strpos($service, '$') ? sprintf('$this->get(%s)', $service) : $this->getServiceCall($value->getFactoryService()), $value->getFactoryMethod(), implode(', ', $arguments));
13381338
} 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+
}

0 commit comments

Comments
 (0)