Code Duplication    Length = 39-39 lines in 2 locations

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

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