Code Duplication    Length = 39-39 lines in 2 locations

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

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