@@ 72-85 (lines=14) @@ | ||
69 | * @expectedException RuntimeException |
|
70 | * @expectedExceptionMessage The tag "jms_serializer.event_listener" of service "my_listener" requires an attribute named "event". |
|
71 | */ |
|
72 | public function testEventListenerMustHaveEventDefined() |
|
73 | { |
|
74 | $container = $this->getContainer(); |
|
75 | ||
76 | $def = new Definition('Foo'); |
|
77 | $def->addTag('jms_serializer.event_listener', [ |
|
78 | 'class' => 'Bar', |
|
79 | ]); |
|
80 | ||
81 | $container->setDefinition('my_listener', $def); |
|
82 | ||
83 | $pass = new RegisterEventListenersAndSubscribersPass(); |
|
84 | $pass->process($container); |
|
85 | } |
|
86 | ||
87 | public function testEventListenerCanBePrivate() |
|
88 | { |
|
@@ 240-251 (lines=12) @@ | ||
237 | * @expectedException RuntimeException |
|
238 | * @expectedExceptionMessage The service "my_listener" (class: JMS\SerializerBundle\Tests\DependencyInjection\Fixture\VersionedObject) does not implement the EventSubscriberInterface. |
|
239 | */ |
|
240 | public function testEventSubscriberInterface() |
|
241 | { |
|
242 | $container = $this->getContainer(); |
|
243 | ||
244 | $def = new Definition('JMS\SerializerBundle\Tests\DependencyInjection\Fixture\VersionedObject'); |
|
245 | $def->addTag('jms_serializer.event_subscriber'); |
|
246 | ||
247 | $container->setDefinition('my_listener', $def); |
|
248 | ||
249 | $pass = new RegisterEventListenersAndSubscribersPass(); |
|
250 | $pass->process($container); |
|
251 | } |
|
252 | ||
253 | public function testEventSubscriberCanBePrivate() |
|
254 | { |
@@ 158-168 (lines=11) @@ | ||
155 | * @expectedException RuntimeException |
|
156 | * @expectedExceptionMessage Each tag named "jms_serializer.handler" of service "my_service" must have at least two attributes: "type" and "format" |
|
157 | */ |
|
158 | public function testHandlerMustHaveTypeAndFormat() |
|
159 | { |
|
160 | $container = $this->getContainer(); |
|
161 | ||
162 | $def = new Definition('Foo'); |
|
163 | $def->addTag('jms_serializer.handler'); |
|
164 | $container->setDefinition('my_service', $def); |
|
165 | ||
166 | $pass = new CustomHandlersPass(); |
|
167 | $pass->process($container); |
|
168 | } |
|
169 | ||
170 | public function testSubscribingHandler() |
|
171 | { |
|
@@ 211-221 (lines=11) @@ | ||
208 | * @expectedException RuntimeException |
|
209 | * @expectedExceptionMessage The service "my_service" must implement the SubscribingHandlerInterface |
|
210 | */ |
|
211 | public function testSubscribingHandlerInterface() |
|
212 | { |
|
213 | $container = $this->getContainer(); |
|
214 | ||
215 | $def = new Definition('JMS\SerializerBundle\Tests\DependencyInjection\Fixture\SimpleObject'); |
|
216 | $def->addTag('jms_serializer.subscribing_handler'); |
|
217 | $container->setDefinition('my_service', $def); |
|
218 | ||
219 | $pass = new CustomHandlersPass(); |
|
220 | $pass->process($container); |
|
221 | } |
|
222 | } |
|
223 |