Code Duplication    Length = 39-39 lines in 2 locations

eZ/Publish/Core/Repository/Tests/Service/Mock/ContentTest.php 2 locations

@@ 256-294 (lines=39) @@
253
     *
254
     * @covers \eZ\Publish\Core\Repository\ContentService::loadVersionInfoById
255
     */
256
    public function testLoadVersionInfoByIdPublishedVersion()
257
    {
258
        $repository = $this->getRepositoryMock();
259
        $contentServiceMock = $this->getPartlyMockedContentService();
260
        /** @var \PHPUnit_Framework_MockObject_MockObject $contentHandler */
261
        $contentHandler = $this->getPersistenceMock()->contentHandler();
262
        $domainMapperMock = $this->getDomainMapperMock();
263
        $versionInfoMock = $this->createMock(APIVersionInfo::class);
264
265
        $versionInfoMock->expects($this->once())
266
            ->method('isPublished')
267
            ->willReturn(true);
268
269
        $contentHandler->expects($this->once())
270
            ->method('loadVersionInfo')
271
            ->with(
272
                $this->equalTo(42),
273
                $this->equalTo(24)
274
            )->will(
275
                $this->returnValue(new SPIVersionInfo())
276
            );
277
278
        $domainMapperMock->expects($this->once())
279
            ->method('buildVersionInfoDomainObject')
280
            ->with(new SPIVersionInfo())
281
            ->will($this->returnValue($versionInfoMock));
282
283
        $repository->expects($this->once())
284
            ->method('canUser')
285
            ->with(
286
                $this->equalTo('content'),
287
                $this->equalTo('read'),
288
                $this->equalTo($versionInfoMock)
289
            )->will($this->returnValue(true));
290
291
        $result = $contentServiceMock->loadVersionInfoById(42, 24);
292
293
        $this->assertEquals($versionInfoMock, $result);
294
    }
295
296
    /**
297
     * Test for the loadVersionInfo() method.
@@ 301-339 (lines=39) @@
298
     *
299
     * @covers \eZ\Publish\Core\Repository\ContentService::loadVersionInfoById
300
     */
301
    public function testLoadVersionInfoByIdNonPublishedVersion()
302
    {
303
        $repository = $this->getRepositoryMock();
304
        $contentServiceMock = $this->getPartlyMockedContentService();
305
        /** @var \PHPUnit_Framework_MockObject_MockObject $contentHandler */
306
        $contentHandler = $this->getPersistenceMock()->contentHandler();
307
        $domainMapperMock = $this->getDomainMapperMock();
308
        $versionInfoMock = $this->createMock(APIVersionInfo::class);
309
310
        $versionInfoMock->expects($this->once())
311
            ->method('isPublished')
312
            ->willReturn(false);
313
314
        $contentHandler->expects($this->once())
315
            ->method('loadVersionInfo')
316
            ->with(
317
                $this->equalTo(42),
318
                $this->equalTo(24)
319
            )->will(
320
                $this->returnValue(new SPIVersionInfo())
321
            );
322
323
        $domainMapperMock->expects($this->once())
324
            ->method('buildVersionInfoDomainObject')
325
            ->with(new SPIVersionInfo())
326
            ->will($this->returnValue($versionInfoMock));
327
328
        $repository->expects($this->once())
329
            ->method('canUser')
330
            ->with(
331
                $this->equalTo('content'),
332
                $this->equalTo('versionread'),
333
                $this->equalTo($versionInfoMock)
334
            )->will($this->returnValue(true));
335
336
        $result = $contentServiceMock->loadVersionInfoById(42, 24);
337
338
        $this->assertEquals($versionInfoMock, $result);
339
    }
340
341
    /**
342
     * Test for the loadVersionInfo() method.