Code Duplication    Length = 40-40 lines in 2 locations

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

@@ 234-273 (lines=40) @@
231
     *
232
     * @covers \eZ\Publish\Core\Repository\ContentService::loadVersionInfoById
233
     */
234
    public function testLoadVersionInfoByIdPublishedVersion()
235
    {
236
        $repository = $this->getRepositoryMock();
237
        $contentServiceMock = $this->getPartlyMockedContentService();
238
        /** @var \PHPUnit\Framework\MockObject\MockObject $contentHandler */
239
        $contentHandler = $this->getPersistenceMock()->contentHandler();
240
        $domainMapperMock = $this->getDomainMapperMock();
241
        $versionInfoMock = $this->createMock(APIVersionInfo::class);
242
        $permissionResolver = $this->getPermissionResolverMock();
243
244
        $versionInfoMock->expects($this->once())
245
            ->method('isPublished')
246
            ->willReturn(true);
247
248
        $contentHandler->expects($this->once())
249
            ->method('loadVersionInfo')
250
            ->with(
251
                $this->equalTo(42),
252
                $this->equalTo(24)
253
            )->will(
254
                $this->returnValue(new SPIVersionInfo())
255
            );
256
257
        $domainMapperMock->expects($this->once())
258
            ->method('buildVersionInfoDomainObject')
259
            ->with(new SPIVersionInfo())
260
            ->will($this->returnValue($versionInfoMock));
261
262
        $permissionResolver->expects($this->once())
263
            ->method('canUser')
264
            ->with(
265
                $this->equalTo('content'),
266
                $this->equalTo('read'),
267
                $this->equalTo($versionInfoMock)
268
            )->will($this->returnValue(true));
269
270
        $result = $contentServiceMock->loadVersionInfoById(42, 24);
271
272
        $this->assertEquals($versionInfoMock, $result);
273
    }
274
275
    /**
276
     * Test for the loadVersionInfo() method.
@@ 280-319 (lines=40) @@
277
     *
278
     * @covers \eZ\Publish\Core\Repository\ContentService::loadVersionInfoById
279
     */
280
    public function testLoadVersionInfoByIdNonPublishedVersion()
281
    {
282
        $repository = $this->getRepositoryMock();
283
        $contentServiceMock = $this->getPartlyMockedContentService();
284
        /** @var \PHPUnit\Framework\MockObject\MockObject $contentHandler */
285
        $contentHandler = $this->getPersistenceMock()->contentHandler();
286
        $domainMapperMock = $this->getDomainMapperMock();
287
        $versionInfoMock = $this->createMock(APIVersionInfo::class);
288
        $permissionResolver = $this->getPermissionResolverMock();
289
290
        $versionInfoMock->expects($this->once())
291
            ->method('isPublished')
292
            ->willReturn(false);
293
294
        $contentHandler->expects($this->once())
295
            ->method('loadVersionInfo')
296
            ->with(
297
                $this->equalTo(42),
298
                $this->equalTo(24)
299
            )->will(
300
                $this->returnValue(new SPIVersionInfo())
301
            );
302
303
        $domainMapperMock->expects($this->once())
304
            ->method('buildVersionInfoDomainObject')
305
            ->with(new SPIVersionInfo())
306
            ->will($this->returnValue($versionInfoMock));
307
308
        $permissionResolver->expects($this->once())
309
            ->method('canUser')
310
            ->with(
311
                $this->equalTo('content'),
312
                $this->equalTo('versionread'),
313
                $this->equalTo($versionInfoMock)
314
            )->will($this->returnValue(true));
315
316
        $result = $contentServiceMock->loadVersionInfoById(42, 24);
317
318
        $this->assertEquals($versionInfoMock, $result);
319
    }
320
321
    /**
322
     * Test for the loadVersionInfo() method.