| @@ 134-144 (lines=11) @@ | ||
| 131 | * @expectedException RuntimeException |
|
| 132 | * @expectedExceptionMessage Each tag named "jms_serializer.handler" of service "my_service" must have at least two attributes: "type" and "format" |
|
| 133 | */ |
|
| 134 | public function testHandlerMustHaveTypeAndFormat() |
|
| 135 | { |
|
| 136 | $container = $this->getContainer(); |
|
| 137 | ||
| 138 | $def = new Definition('Foo'); |
|
| 139 | $def->addTag('jms_serializer.handler'); |
|
| 140 | $container->setDefinition('my_service', $def); |
|
| 141 | ||
| 142 | $pass = new CustomHandlersPass(); |
|
| 143 | $pass->process($container); |
|
| 144 | } |
|
| 145 | ||
| 146 | public function testSubscribingHandler() |
|
| 147 | { |
|
| @@ 168-178 (lines=11) @@ | ||
| 165 | * @expectedException RuntimeException |
|
| 166 | * @expectedExceptionMessage The service "my_service" must implement the SubscribingHandlerInterface |
|
| 167 | */ |
|
| 168 | public function testSubscribingHandlerInterface() |
|
| 169 | { |
|
| 170 | $container = $this->getContainer(); |
|
| 171 | ||
| 172 | $def = new Definition('JMS\SerializerBundle\Tests\DependencyInjection\Fixture\SimpleObject'); |
|
| 173 | $def->addTag('jms_serializer.subscribing_handler'); |
|
| 174 | $container->setDefinition('my_service', $def); |
|
| 175 | ||
| 176 | $pass = new CustomHandlersPass(); |
|
| 177 | $pass->process($container); |
|
| 178 | } |
|
| 179 | } |
|
| 180 | ||
| @@ 73-86 (lines=14) @@ | ||
| 70 | * @expectedException RuntimeException |
|
| 71 | * @expectedExceptionMessage The tag "jms_serializer.event_listener" of service "my_listener" requires an attribute named "event". |
|
| 72 | */ |
|
| 73 | public function testEventListenerMustHaveEventDefined() |
|
| 74 | { |
|
| 75 | $container = $this->getContainer(); |
|
| 76 | ||
| 77 | $def = new Definition('Foo'); |
|
| 78 | $def->addTag('jms_serializer.event_listener', [ |
|
| 79 | 'class' => 'Bar', |
|
| 80 | ]); |
|
| 81 | ||
| 82 | $container->setDefinition('my_listener', $def); |
|
| 83 | ||
| 84 | $pass = new RegisterEventListenersAndSubscribersPass(); |
|
| 85 | $pass->process($container); |
|
| 86 | } |
|
| 87 | ||
| 88 | public function testEventListenerCanBePrivateWithServiceClosureArgument() |
|
| 89 | { |
|
| @@ 262-273 (lines=12) @@ | ||
| 259 | * @expectedException RuntimeException |
|
| 260 | * @expectedExceptionMessage The service "my_subscriber" (class: JMS\SerializerBundle\Tests\DependencyInjection\Fixture\VersionedObject) does not implement the EventSubscriberInterface. |
|
| 261 | */ |
|
| 262 | public function testEventSubscriberInterface() |
|
| 263 | { |
|
| 264 | $container = $this->getContainer(); |
|
| 265 | ||
| 266 | $def = new Definition('JMS\SerializerBundle\Tests\DependencyInjection\Fixture\VersionedObject'); |
|
| 267 | $def->addTag('jms_serializer.event_subscriber'); |
|
| 268 | ||
| 269 | $container->setDefinition('my_subscriber', $def); |
|
| 270 | ||
| 271 | $pass = new RegisterEventListenersAndSubscribersPass(); |
|
| 272 | $pass->process($container); |
|
| 273 | } |
|
| 274 | ||
| 275 | public function testEventSubscriberCanBePrivateWithServiceClosureArgument() |
|
| 276 | { |
|