Skip to content

Commit bf7eeef

Browse files
committed
Prove that change is working with tests
1 parent 2176be7 commit bf7eeef

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveNamedArgumentsPassTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\DependencyInjection\Reference;
1818
use Symfony\Component\DependencyInjection\Tests\Fixtures\CaseSensitiveClass;
1919
use Symfony\Component\DependencyInjection\Tests\Fixtures\NamedArgumentsDummy;
20+
use Symfony\Component\DependencyInjection\Tests\Fixtures\SimilarArgumentsDummy;
2021

2122
/**
2223
* @author Kévin Dunglas <[email protected]>
@@ -125,6 +126,32 @@ public function testTypedArgument()
125126

126127
$this->assertEquals(array(new Reference('foo'), '123'), $definition->getArguments());
127128
}
129+
130+
public function testResolvesMultipleArgumentsOfTheSameType()
131+
{
132+
$container = new ContainerBuilder();
133+
134+
$definition = $container->register(SimilarArgumentsDummy::class, SimilarArgumentsDummy::class);
135+
$definition->setArguments(array(CaseSensitiveClass::class => new Reference('foo'), '$token' => 'qwerty'));
136+
137+
$pass = new ResolveNamedArgumentsPass();
138+
$pass->process($container);
139+
140+
$this->assertEquals(array(new Reference('foo'), 'qwerty', new Reference('foo')), $definition->getArguments());
141+
}
142+
143+
public function testResolvePrioritizeNamedOverType()
144+
{
145+
$container = new ContainerBuilder();
146+
147+
$definition = $container->register(SimilarArgumentsDummy::class, SimilarArgumentsDummy::class);
148+
$definition->setArguments(array(CaseSensitiveClass::class => new Reference('foo'), '$token' => 'qwerty', '$class1' => new Reference('bar')));
149+
150+
$pass = new ResolveNamedArgumentsPass();
151+
$pass->process($container);
152+
153+
$this->assertEquals(array(new Reference('bar'), 'qwerty', new Reference('foo')), $definition->getArguments());
154+
}
128155
}
129156

130157
class NoConstructor
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
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\Fixtures;
13+
14+
class SimilarArgumentsDummy
15+
{
16+
public function __construct(CaseSensitiveClass $class1, string $token, CaseSensitiveClass $class2)
17+
{
18+
}
19+
}

0 commit comments

Comments
 (0)