Code Duplication    Length = 39-39 lines in 2 locations

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

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