11
11
12
12
namespace Symfony \Component \DependencyInjection \Tests \Compiler ;
13
13
14
- use Symfony \Component \DependencyInjection \Compiler \AutowiringPass ;
14
+ use Symfony \Component \DependencyInjection \Compiler \AutowirePass ;
15
15
use Symfony \Component \DependencyInjection \ContainerBuilder ;
16
16
use Symfony \Component \DependencyInjection \Reference ;
17
17
18
18
/**
19
19
* @author Kévin Dunglas <dunglas@gmail.com>
20
20
*/
21
- class AutowiringPassTest extends \PHPUnit_Framework_TestCase
21
+ class AutowirePassTest extends \PHPUnit_Framework_TestCase
22
22
{
23
23
public function testProcess ()
24
24
{
25
25
$ container = new ContainerBuilder ();
26
26
27
27
$ container ->register ('foo ' , __NAMESPACE__ .'\Foo ' );
28
28
$ barDefinition = $ container ->register ('bar ' , __NAMESPACE__ .'\Bar ' );
29
- $ barDefinition ->addTag (AutowiringPass:: AUTOWIRING );
29
+ $ barDefinition ->setAutowired ( true );
30
30
31
- $ pass = new AutowiringPass ();
31
+ $ pass = new AutowirePass ();
32
32
$ pass ->process ($ container );
33
33
34
34
$ this ->assertCount (1 , $ container ->getDefinition ('bar ' )->getArguments ());
@@ -41,9 +41,9 @@ public function testProcessAutowireParent()
41
41
42
42
$ container ->register ('b ' , __NAMESPACE__ .'\B ' );
43
43
$ cDefinition = $ container ->register ('c ' , __NAMESPACE__ .'\C ' );
44
- $ cDefinition ->addTag (AutowiringPass:: AUTOWIRING );
44
+ $ cDefinition ->setAutowired ( true );
45
45
46
- $ pass = new AutowiringPass ();
46
+ $ pass = new AutowirePass ();
47
47
$ pass ->process ($ container );
48
48
49
49
$ this ->assertCount (1 , $ container ->getDefinition ('c ' )->getArguments ());
@@ -56,9 +56,9 @@ public function testProcessAutowireInterface()
56
56
57
57
$ container ->register ('f ' , __NAMESPACE__ .'\F ' );
58
58
$ gDefinition = $ container ->register ('g ' , __NAMESPACE__ .'\G ' );
59
- $ gDefinition ->addTag (AutowiringPass:: AUTOWIRING );
59
+ $ gDefinition ->setAutowired ( true );
60
60
61
- $ pass = new AutowiringPass ();
61
+ $ pass = new AutowirePass ();
62
62
$ pass ->process ($ container );
63
63
64
64
$ this ->assertCount (2 , $ container ->getDefinition ('g ' )->getArguments ());
@@ -73,9 +73,9 @@ public function testCompleteExistingDefinition()
73
73
$ container ->register ('b ' , __NAMESPACE__ .'\B ' );
74
74
$ container ->register ('f ' , __NAMESPACE__ .'\F ' );
75
75
$ hDefinition = $ container ->register ('h ' , __NAMESPACE__ .'\H ' )->addArgument (new Reference ('b ' ));
76
- $ hDefinition ->addTag (AutowiringPass:: AUTOWIRING );
76
+ $ hDefinition ->setAutowired ( true );
77
77
78
- $ pass = new AutowiringPass ();
78
+ $ pass = new AutowirePass ();
79
79
$ pass ->process ($ container );
80
80
81
81
$ this ->assertCount (2 , $ container ->getDefinition ('h ' )->getArguments ());
@@ -90,9 +90,9 @@ public function testCompleteExistingDefinitionWithNotDefinedArguments()
90
90
$ container ->register ('b ' , __NAMESPACE__ .'\B ' );
91
91
$ container ->register ('f ' , __NAMESPACE__ .'\F ' );
92
92
$ hDefinition = $ container ->register ('h ' , __NAMESPACE__ .'\H ' )->addArgument ('' )->addArgument ('' );
93
- $ hDefinition ->addTag (AutowiringPass:: AUTOWIRING );
93
+ $ hDefinition ->setAutowired ( true );
94
94
95
- $ pass = new AutowiringPass ();
95
+ $ pass = new AutowirePass ();
96
96
$ pass ->process ($ container );
97
97
98
98
$ this ->assertCount (2 , $ container ->getDefinition ('h ' )->getArguments ());
@@ -111,9 +111,9 @@ public function testTypeCollision()
111
111
$ container ->register ('c1 ' , __NAMESPACE__ .'\CollisionA ' );
112
112
$ container ->register ('c2 ' , __NAMESPACE__ .'\CollisionB ' );
113
113
$ aDefinition = $ container ->register ('a ' , __NAMESPACE__ .'\CannotBeAutowired ' );
114
- $ aDefinition ->addTag (AutowiringPass:: AUTOWIRING );
114
+ $ aDefinition ->setAutowired ( true );
115
115
116
- $ pass = new AutowiringPass ();
116
+ $ pass = new AutowirePass ();
117
117
$ pass ->process ($ container );
118
118
}
119
119
@@ -124,9 +124,9 @@ public function testWithTypeSet()
124
124
$ container ->register ('c1 ' , __NAMESPACE__ .'\CollisionA ' );
125
125
$ container ->register ('c2 ' , __NAMESPACE__ .'\CollisionB ' )->addAutowiringType (__NAMESPACE__ .'\CollisionInterface ' );
126
126
$ aDefinition = $ container ->register ('a ' , __NAMESPACE__ .'\CannotBeAutowired ' );
127
- $ aDefinition ->addTag (AutowiringPass:: AUTOWIRING );
127
+ $ aDefinition ->setAutowired ( true );
128
128
129
- $ pass = new AutowiringPass ();
129
+ $ pass = new AutowirePass ();
130
130
$ pass ->process ($ container );
131
131
132
132
$ this ->assertCount (1 , $ container ->getDefinition ('a ' )->getArguments ());
@@ -138,9 +138,9 @@ public function testCreateDefinition()
138
138
$ container = new ContainerBuilder ();
139
139
140
140
$ coopTilleulsDefinition = $ container ->register ('coop_tilleuls ' , __NAMESPACE__ .'\LesTilleuls ' );
141
- $ coopTilleulsDefinition ->addTag (AutowiringPass:: AUTOWIRING );
141
+ $ coopTilleulsDefinition ->setAutowired ( true );
142
142
143
- $ pass = new AutowiringPass ();
143
+ $ pass = new AutowirePass ();
144
144
$ pass ->process ($ container );
145
145
146
146
$ this ->assertCount (1 , $ container ->getDefinition ('coop_tilleuls ' )->getArguments ());
@@ -163,9 +163,9 @@ public function testResolveParameter()
163
163
$ container ->setParameter ('class_name ' , __NAMESPACE__ .'\Foo ' );
164
164
$ container ->register ('foo ' , '%class_name% ' );
165
165
$ barDefinition = $ container ->register ('bar ' , __NAMESPACE__ .'\Bar ' );
166
- $ barDefinition ->addTag (AutowiringPass:: AUTOWIRING );
166
+ $ barDefinition ->setAutowired ( true );
167
167
168
- $ pass = new AutowiringPass ();
168
+ $ pass = new AutowirePass ();
169
169
$ pass ->process ($ container );
170
170
171
171
$ this ->assertEquals ('foo ' , $ container ->getDefinition ('bar ' )->getArgument (0 ));
@@ -178,9 +178,9 @@ public function testOptionalParameter()
178
178
$ container ->register ('a ' , __NAMESPACE__ .'\A ' );
179
179
$ container ->register ('foo ' , __NAMESPACE__ .'\Foo ' );
180
180
$ optDefinition = $ container ->register ('opt ' , __NAMESPACE__ .'\OptionalParameter ' );
181
- $ optDefinition ->addTag (AutowiringPass:: AUTOWIRING );
181
+ $ optDefinition ->setAutowired ( true );
182
182
183
- $ pass = new AutowiringPass ();
183
+ $ pass = new AutowirePass ();
184
184
$ pass ->process ($ container );
185
185
186
186
$ definition = $ container ->getDefinition ('opt ' );
@@ -196,7 +196,7 @@ public function testDontTriggeruAutowiring()
196
196
$ container ->register ('foo ' , __NAMESPACE__ .'\Foo ' );
197
197
$ container ->register ('bar ' , __NAMESPACE__ .'\Bar ' );
198
198
199
- $ pass = new AutowiringPass ();
199
+ $ pass = new AutowirePass ();
200
200
$ pass ->process ($ container );
201
201
202
202
$ this ->assertCount (0 , $ container ->getDefinition ('bar ' )->getArguments ());
0 commit comments