Code Duplication    Length = 37-39 lines in 2 locations

Tests/DependencyInjection/EventSubscribersAndListenersPassTest.php 2 locations

@@ 114-150 (lines=37) @@
111
        }
112
    }
113
114
    public function testEventListener()
115
    {
116
        $container = $this->getContainer();
117
118
        $def = new Definition('Foo');
119
        $def->addTag('jms_serializer.event_listener', [
120
            'event' => 'serializer.pre_serialize',
121
            'class' => 'Bar',
122
        ]);
123
124
        $container->setDefinition('my_listener', $def);
125
126
        $pass = new RegisterEventListenersAndSubscribersPass();
127
        $pass->process($container);
128
129
        $dispatcher = $container->getDefinition('jms_serializer.event_dispatcher');
130
        $methodCalls = $dispatcher->getMethodCalls();
131
132
        $called = false;
133
        foreach ($methodCalls as $call) {
134
            if ($call[0] === 'setListeners') {
135
                $called = true;
136
                $this->assertEquals([
137
                    'serializer.pre_serialize' => [
138
                        [
139
                            ['my_listener', 'onserializerpreserialize'],
140
                            'bar',
141
                            null
142
                        ]
143
                    ]], $call[1][0]);
144
            }
145
        }
146
147
        if (!$called) {
148
            $this->fail("The method setListeners was not invoked on the jms_serializer.event_dispatcher");
149
        }
150
    }
151
152
    public function testEventListenerWithParams()
153
    {
@@ 152-190 (lines=39) @@
149
        }
150
    }
151
152
    public function testEventListenerWithParams()
153
    {
154
        $container = $this->getContainer();
155
156
        $container->setParameter('bar', 'Bar');
157
158
        $def = new Definition('Foo');
159
        $def->addTag('jms_serializer.event_listener', [
160
            'event' => 'serializer.pre_serialize',
161
            'class' => '%bar%',
162
        ]);
163
164
        $container->setDefinition('my_listener', $def);
165
166
        $pass = new RegisterEventListenersAndSubscribersPass();
167
        $pass->process($container);
168
169
        $dispatcher = $container->getDefinition('jms_serializer.event_dispatcher');
170
        $methodCalls = $dispatcher->getMethodCalls();
171
172
        $called = false;
173
        foreach ($methodCalls as $call) {
174
            if ($call[0] === 'setListeners') {
175
                $called = true;
176
                $this->assertEquals([
177
                    'serializer.pre_serialize' => [
178
                        [
179
                            ['my_listener', 'onserializerpreserialize'],
180
                            'bar',
181
                            null
182
                        ]
183
                    ]], $call[1][0]);
184
            }
185
        }
186
187
        if (!$called) {
188
            $this->fail("The method setListeners was not invoked on the jms_serializer.event_dispatcher");
189
        }
190
    }
191
192
    public function testEventSubscriber()
193
    {