Code Duplication    Length = 39-39 lines in 2 locations

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

@@ 298-336 (lines=39) @@
295
     *
296
     * @covers \eZ\Publish\Core\Repository\ContentService::loadVersionInfoById
297
     */
298
    public function testLoadVersionInfoByIdPublishedVersion()
299
    {
300
        $repository = $this->getRepositoryMock();
301
        $contentServiceMock = $this->getPartlyMockedContentService();
302
        /** @var \PHPUnit_Framework_MockObject_MockObject $contentHandler */
303
        $contentHandler = $this->getPersistenceMock()->contentHandler();
304
        $domainMapperMock = $this->getDomainMapperMock();
305
        $versionInfoMock = $this->createMock(APIVersionInfo::class);
306
307
        $versionInfoMock->expects($this->once())
308
            ->method('isPublished')
309
            ->willReturn(true);
310
311
        $contentHandler->expects($this->once())
312
            ->method('loadVersionInfo')
313
            ->with(
314
                $this->equalTo(42),
315
                $this->equalTo(24)
316
            )->will(
317
                $this->returnValue(new SPIVersionInfo())
318
            );
319
320
        $domainMapperMock->expects($this->once())
321
            ->method('buildVersionInfoDomainObject')
322
            ->with(new SPIVersionInfo())
323
            ->will($this->returnValue($versionInfoMock));
324
325
        $repository->expects($this->once())
326
            ->method('canUser')
327
            ->with(
328
                $this->equalTo('content'),
329
                $this->equalTo('read'),
330
                $this->equalTo($versionInfoMock)
331
            )->will($this->returnValue(true));
332
333
        $result = $contentServiceMock->loadVersionInfoById(42, 24);
334
335
        $this->assertEquals($versionInfoMock, $result);
336
    }
337
338
    /**
339
     * Test for the loadVersionInfo() method.
@@ 343-381 (lines=39) @@
340
     *
341
     * @covers \eZ\Publish\Core\Repository\ContentService::loadVersionInfoById
342
     */
343
    public function testLoadVersionInfoByIdNonPublishedVersion()
344
    {
345
        $repository = $this->getRepositoryMock();
346
        $contentServiceMock = $this->getPartlyMockedContentService();
347
        /** @var \PHPUnit_Framework_MockObject_MockObject $contentHandler */
348
        $contentHandler = $this->getPersistenceMock()->contentHandler();
349
        $domainMapperMock = $this->getDomainMapperMock();
350
        $versionInfoMock = $this->createMock(APIVersionInfo::class);
351
352
        $versionInfoMock->expects($this->once())
353
            ->method('isPublished')
354
            ->willReturn(false);
355
356
        $contentHandler->expects($this->once())
357
            ->method('loadVersionInfo')
358
            ->with(
359
                $this->equalTo(42),
360
                $this->equalTo(24)
361
            )->will(
362
                $this->returnValue(new SPIVersionInfo())
363
            );
364
365
        $domainMapperMock->expects($this->once())
366
            ->method('buildVersionInfoDomainObject')
367
            ->with(new SPIVersionInfo())
368
            ->will($this->returnValue($versionInfoMock));
369
370
        $repository->expects($this->once())
371
            ->method('canUser')
372
            ->with(
373
                $this->equalTo('content'),
374
                $this->equalTo('versionread'),
375
                $this->equalTo($versionInfoMock)
376
            )->will($this->returnValue(true));
377
378
        $result = $contentServiceMock->loadVersionInfoById(42, 24);
379
380
        $this->assertEquals($versionInfoMock, $result);
381
    }
382
383
    /**
384
     * Test for the loadVersionInfo() method.