Code Duplication    Length = 27-27 lines in 3 locations

Tests/EventListener/EditorResponseListenerTest.php 3 locations

@@ 156-182 (lines=27) @@
153
        ];
154
    }
155
156
    public function testEditorIsNotRenderedWhenNotBehindFirewall()
157
    {
158
        $this->editor->method('renderEditor')
159
            ->willReturn('<div>editor</div>');
160
161
        $this->authorizationChecker->method('isGranted')
162
            ->with('ROLE_ADMIN')
163
            ->willThrowException(new AuthenticationCredentialsNotFoundException());
164
165
        $request = new Request();
166
        $response = new Response(
167
            '<body></body>',
168
            200,
169
            ['Content-Type' => 'text/html']
170
        );
171
172
        $this->event->method('getRequest')
173
            ->willReturn($request);
174
        $this->event->method('getResponse')
175
            ->willReturn($response);
176
        $this->event->method('isMasterRequest')
177
            ->willReturn(true);
178
179
        $this->listener->onKernelResponse($this->event);
180
181
        $this->assertSame('<body></body>', $response->getContent());
182
    }
183
184
    public function testEditorIsInjectedOnKernelResponse()
185
    {
@@ 184-210 (lines=27) @@
181
        $this->assertSame('<body></body>', $response->getContent());
182
    }
183
184
    public function testEditorIsInjectedOnKernelResponse()
185
    {
186
        $this->editor->method('renderEditor')
187
            ->willReturn('<div>editor</div>');
188
189
        $this->authorizationChecker->method('isGranted')
190
            ->with('ROLE_ADMIN')
191
            ->willReturn(true);
192
193
        $request = new Request();
194
        $response = new Response(
195
            '<body><h1>Some content</h1></body>',
196
            200,
197
            ['Content-Type' => 'text/html']
198
        );
199
200
        $this->event->method('getRequest')
201
            ->willReturn($request);
202
        $this->event->method('getResponse')
203
            ->willReturn($response);
204
        $this->event->method('isMasterRequest')
205
            ->willReturn(true);
206
207
        $this->listener->onKernelResponse($this->event);
208
209
        $this->assertSame('<body><h1>Some content</h1><div>editor</div></body>', $response->getContent());
210
    }
211
212
    public function testCustomEditorInjectionIsPossible()
213
    {
@@ 212-238 (lines=27) @@
209
        $this->assertSame('<body><h1>Some content</h1><div>editor</div></body>', $response->getContent());
210
    }
211
212
    public function testCustomEditorInjectionIsPossible()
213
    {
214
        $this->authorizationChecker->method('isGranted')
215
            ->with('ROLE_ADMIN')
216
            ->willReturn(true);
217
218
        $request = new Request();
219
        $response = new Response(
220
            '<body></body>',
221
            200,
222
            ['Content-Type' => 'text/html']
223
        );
224
225
        $this->event->method('getRequest')
226
            ->willReturn($request);
227
        $this->event->method('getResponse')
228
            ->willReturn($response);
229
        $this->event->method('isMasterRequest')
230
            ->willReturn(true);
231
232
        $this->editor->expects($this->once())
233
            ->method('renderEditor')
234
            ->with($response)
235
            ->willReturn(null);
236
237
        $this->listener->onKernelResponse($this->event);
238
    }
239
}
240