Code Duplication    Length = 11-14 lines in 6 locations

Tests/DependencyInjection/CustomHandlerPassTest.php 2 locations

@@ 133-143 (lines=11) @@
130
     * @expectedException RuntimeException
131
     * @expectedExceptionMessage Each tag named "jms_serializer.handler" of service "my_service" must have at least two attributes: "type" and "format"
132
     */
133
    public function testHandlerMustHaveTypeAndFormat()
134
    {
135
        $container = $this->getContainer();
136
137
        $def = new Definition('Foo');
138
        $def->addTag('jms_serializer.handler');
139
        $container->setDefinition('my_service', $def);
140
141
        $pass = new CustomHandlersPass();
142
        $pass->process($container);
143
    }
144
145
    public function testSubscribingHandler()
146
    {
@@ 167-177 (lines=11) @@
164
     * @expectedException RuntimeException
165
     * @expectedExceptionMessage The service "my_service" must implement the SubscribingHandlerInterface
166
     */
167
    public function testSubscribingHandlerInterface()
168
    {
169
        $container = $this->getContainer();
170
171
        $def = new Definition('JMS\SerializerBundle\Tests\DependencyInjection\Fixture\SimpleObject');
172
        $def->addTag('jms_serializer.subscribing_handler');
173
        $container->setDefinition('my_service', $def);
174
175
        $pass = new CustomHandlersPass();
176
        $pass->process($container);
177
    }
178
}
179

Tests/DependencyInjection/EventSubscribersAndListenersPassTest.php 4 locations

@@ 69-82 (lines=14) @@
66
    /**
67
     * @expectedException RuntimeException
68
     */
69
    public function testEventListenerMustHaveEventDefined()
70
    {
71
        $container = $this->getContainer();
72
73
        $def = new Definition('Foo');
74
        $def->addTag('jms_serializer.event_listener', [
75
            'class' => 'Bar',
76
        ]);
77
78
        $container->setDefinition('my_listener', $def);
79
80
        $pass = new RegisterEventListenersAndSubscribersPass();
81
        $pass->process($container);
82
    }
83
84
    /**
85
     * @expectedException RuntimeException
@@ 87-99 (lines=13) @@
84
    /**
85
     * @expectedException RuntimeException
86
     */
87
    public function testEventListenerMustBePublic()
88
    {
89
        $container = $this->getContainer();
90
91
        $def = new Definition('Foo');
92
        $def->setPublic(false);
93
        $def->addTag('jms_serializer.event_listener');
94
95
        $container->setDefinition('my_listener', $def);
96
97
        $pass = new RegisterEventListenersAndSubscribersPass();
98
        $pass->process($container);
99
    }
100
101
    public function testEventListener()
102
    {
@@ 217-228 (lines=12) @@
214
    /**
215
     * @expectedException RuntimeException
216
     */
217
    public function testEventSubscriberInterface()
218
    {
219
        $container = $this->getContainer();
220
221
        $def = new Definition('JMS\SerializerBundle\Tests\DependencyInjection\Fixture\VersionedObject');
222
        $def->addTag('jms_serializer.event_subscriber');
223
224
        $container->setDefinition('my_listener', $def);
225
226
        $pass = new RegisterEventListenersAndSubscribersPass();
227
        $pass->process($container);
228
    }
229
230
    /**
231
     * @expectedException RuntimeException
@@ 233-245 (lines=13) @@
230
    /**
231
     * @expectedException RuntimeException
232
     */
233
    public function testEventSubscriberMustBePublic()
234
    {
235
        $container = $this->getContainer();
236
237
        $def = new Definition('JMS\SerializerBundle\Tests\DependencyInjection\Fixture\VersionedObject');
238
        $def->setPublic(false);
239
        $def->addTag('jms_serializer.event_subscriber');
240
241
        $container->setDefinition('my_listener', $def);
242
243
        $pass = new RegisterEventListenersAndSubscribersPass();
244
        $pass->process($container);
245
    }
246
}
247
248