File tree 2 files changed +36
-1
lines changed
src/Symfony/Component/DependencyInjection 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ public function getValues()
39
39
public function setValues (array $ values )
40
40
{
41
41
foreach ($ values as $ v ) {
42
- if (!$ v instanceof Reference) {
42
+ if (!$ v instanceof Reference && null !== $ v ) {
43
43
throw new InvalidArgumentException ('Values of a ServiceLocatorArgument must be Reference objects. ' );
44
44
}
45
45
}
Original file line number Diff line number Diff line change
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 \Argument ;
13
+
14
+ use PHPUnit \Framework \TestCase ;
15
+ use Symfony \Component \DependencyInjection \Argument \ServiceLocatorArgument ;
16
+ use Symfony \Component \DependencyInjection \Reference ;
17
+
18
+ class ServiceLocatorArgumentTest extends TestCase
19
+ {
20
+ /**
21
+ * @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
22
+ * @expectedExceptionMessage Values of a ServiceLocatorArgument must be Reference objects.
23
+ */
24
+ public function testThrowsOnNonReferenceValues ()
25
+ {
26
+ new ServiceLocatorArgument (array ('foo ' => 'bar ' ));
27
+ }
28
+
29
+ public function testAcceptsReferencesOrNulls ()
30
+ {
31
+ $ locator = new ServiceLocatorArgument ($ values = array ('foo ' => new Reference ('bar ' ), 'bar ' => null ));
32
+
33
+ $ this ->assertSame ($ values , $ locator ->getValues ());
34
+ }
35
+ }
You can’t perform that action at this time.
0 commit comments