@@ -23,17 +23,63 @@ public function testProcess()
23
23
$ container = new ContainerBuilder ();
24
24
$ def = $ container
25
25
->register ('foo ' )
26
- ->setArguments (array (new Reference ('bar ' , ContainerInterface::NULL_ON_INVALID_REFERENCE )))
26
+ ->setArguments (array (
27
+ new Reference ('bar ' , ContainerInterface::NULL_ON_INVALID_REFERENCE ),
28
+ new Reference ('baz ' , ContainerInterface::IGNORE_ON_INVALID_REFERENCE ),
29
+ ))
27
30
->addMethodCall ('foo ' , array (new Reference ('moo ' , ContainerInterface::IGNORE_ON_INVALID_REFERENCE )))
28
31
;
29
32
30
33
$ this ->process ($ container );
31
34
32
35
$ arguments = $ def ->getArguments ();
33
- $ this ->assertNull ( $ arguments[ 0 ] );
36
+ $ this ->assertSame ( array ( null , null ), $ arguments );
34
37
$ this ->assertCount (0 , $ def ->getMethodCalls ());
35
38
}
36
39
40
+ public function testProcessIgnoreInvalidArgumentInCollectionArgument ()
41
+ {
42
+ $ container = new ContainerBuilder ();
43
+ $ container ->register ('baz ' );
44
+ $ def = $ container
45
+ ->register ('foo ' )
46
+ ->setArguments (array (
47
+ array (
48
+ new Reference ('bar ' , ContainerInterface::IGNORE_ON_INVALID_REFERENCE ),
49
+ $ baz = new Reference ('baz ' , ContainerInterface::IGNORE_ON_INVALID_REFERENCE ),
50
+ new Reference ('moo ' , ContainerInterface::NULL_ON_INVALID_REFERENCE ),
51
+ ),
52
+ ))
53
+ ;
54
+
6D40
55
+ $ this ->process ($ container );
56
+
57
+ $ arguments = $ def ->getArguments ();
58
+ $ this ->assertSame (array ($ baz , null ), $ arguments [0 ]);
59
+ }
60
+
61
+ public function testProcessKeepMethodCallOnInvalidArgumentInCollectionArgument ()
62
+ {
63
+ $ container = new ContainerBuilder ();
64
+ $ container ->register ('baz ' );
65
+ $ def = $ container
66
+ ->register ('foo ' )
67
+ ->addMethodCall ('foo ' , array (
68
+ array (
69
+ new Reference ('bar ' , ContainerInterface::IGNORE_ON_INVALID_REFERENCE ),
70
+ $ baz = new Reference ('baz ' , ContainerInterface::IGNORE_ON_INVALID_REFERENCE ),
71
+ new Reference ('moo ' , ContainerInterface::NULL_ON_INVALID_REFERENCE ),
72
+ ),
73
+ ))
74
+ ;
75
+
76
+ $ this ->process ($ container );
77
+
78
+ $ calls = $ def ->getMethodCalls ();
79
+ $ this ->assertCount (1 , $ def ->getMethodCalls ());
80
+ $ this ->assertSame (array ($ baz , null ), $ calls [0 ][1 ][0 ]);
81
+ }
82
+
37
83
public function testProcessIgnoreNonExistentServices ()
38
84
{
39
85
$ container = new ContainerBuilder ();
0 commit comments