@@ -139,6 +139,91 @@ public function testAbstractEventListener()
139
139
$ registerListenersPass = new CompiledRegisterListenersPass ();
140
140
$ registerListenersPass ->process ($ container );
141
141
}
142
+
143
+ /**
144
+ * @expectedException \InvalidArgumentException
145
+ * @expectedExceptionMessage The service "foo" must not be abstract as event subscribers are lazy-loaded.
146
+ */
147
+ public function testAbstractEventSubscriber ()
148
+ {
149
+ $ container = new ContainerBuilder ();
150
+ $ container ->register ('foo ' , 'stdClass ' )->setAbstract (true )->addTag ('kernel.event_subscriber ' , array ());
151
+ $ container ->register ('event_dispatcher ' , 'stdClass ' );
152
+
153
+ $ registerListenersPass = new CompiledRegisterListenersPass ();
154
+ $ registerListenersPass ->process ($ container );
155
+ }
156
+
157
+ public function testEventSubscriberResolvableClassName ()
158
+ {
159
+ $ container = new ContainerBuilder ();
160
+
161
+ $ container ->setParameter ('subscriber.class ' , 'Symfony\Component\EventDispatcher\Tests\DependencyInjection\CompiledSubscriberService ' );
162
+ $ container ->register ('foo ' , '%subscriber.class% ' )->addTag ('kernel.event_subscriber ' , array ());
163
+ $ container ->register ('event_dispatcher ' , 'stdClass ' );
164
+
165
+ $ registerListenersPass = new CompiledRegisterListenersPass ();
166
+ $ registerListenersPass ->process ($ container );
167
+
168
+ $ definition = $ container ->getDefinition ('event_dispatcher ' );
169
+ $ expected_arguments = array (
170
+ array (
171
+ 'test_event.multiple_listeners ' => array (
172
+ 128 => array (
173
+ array (
174
+ 'service ' => array (
175
+ 'id ' => 'foo ' ,
176
+ 'method ' => 'methodWithHighestPriority ' ,
177
+ ),
178
+ ),
179
+ ),
180
+ 0 => array (
181
+ array (
182
+ 'service ' => array (
183
+ 'id ' => 'foo ' ,
184
+ 'method ' => 'methodWithoutPriority ' ,
185
+ ),
186
+ ),
187
+ ),
188
+ ),
189
+ 'test_event.single_listener_with_priority ' => array (
190
+ 64 => array (
191
+ array (
192
+ 'service ' => array (
193
+ 'id ' => 'foo ' ,
194
+ 'method ' => 'methodWithHighPriority ' ,
195
+ ),
196
+ ),
197
+ ),
198
+ ),
199
+ 'test_event.single_listener_without_priority ' => array (
200
+ 0 => array (
201
+ array (
202
+ 'service ' => array (
203
+ 'id ' => 'foo ' ,
204
+ 'method ' => 'methodWithoutPriority ' ,
205
+ ),
206
+ ),
207
+ ),
208
+ ),
209
+ ),
210
+ );
211
+ $ this ->assertSame ($ expected_arguments , $ definition ->getArguments ());
212
+ }
213
+
214
+ /**
215
+ * @expectedException \InvalidArgumentException
216
+ * @expectedExceptionMessage You have requested a non-existent parameter "subscriber.class"
217
+ */
218
+ public function testEventSubscriberUnresolvableClassName ()
219
+ {
220
+ $ container = new ContainerBuilder ();
221
+ $ container ->register ('foo ' , '%subscriber.class% ' )->addTag ('kernel.event_subscriber ' , array ());
222
+ $ container ->register ('event_dispatcher ' , 'stdClass ' );
223
+
224
+ $ registerListenersPass = new CompiledRegisterListenersPass ();
225
+ $ registerListenersPass ->process ($ container );
226
+ }
142
227
}
143
228
144
229
class CompiledSubscriberService implements EventSubscriberInterface
0 commit comments