Code Duplication    Length = 39-39 lines in 2 locations

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

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