Code Duplication    Length = 40-40 lines in 2 locations

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

@@ 260-299 (lines=40) @@
257
     *
258
     * @covers \eZ\Publish\Core\Repository\ContentService::loadVersionInfoById
259
     */
260
    public function testLoadVersionInfoByIdPublishedVersion()
261
    {
262
        $repository = $this->getRepositoryMock();
263
        $contentServiceMock = $this->getPartlyMockedContentService();
264
        /** @var \PHPUnit_Framework_MockObject_MockObject $contentHandler */
265
        $contentHandler = $this->getPersistenceMock()->contentHandler();
266
        $domainMapperMock = $this->getDomainMapperMock();
267
        $versionInfoMock = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo');
268
269
        $versionInfoMock->expects($this->any())
270
            ->method('__get')
271
            ->with('status')
272
            ->will($this->returnValue(APIVersionInfo::STATUS_PUBLISHED));
273
274
        $contentHandler->expects($this->once())
275
            ->method('loadVersionInfo')
276
            ->with(
277
                $this->equalTo(42),
278
                $this->equalTo(24)
279
            )->will(
280
                $this->returnValue(new SPIVersionInfo())
281
            );
282
283
        $domainMapperMock->expects($this->once())
284
            ->method('buildVersionInfoDomainObject')
285
            ->with(new SPIVersionInfo())
286
            ->will($this->returnValue($versionInfoMock));
287
288
        $repository->expects($this->once())
289
            ->method('canUser')
290
            ->with(
291
                $this->equalTo('content'),
292
                $this->equalTo('read'),
293
                $this->equalTo($versionInfoMock)
294
            )->will($this->returnValue(true));
295
296
        $result = $contentServiceMock->loadVersionInfoById(42, 24);
297
298
        $this->assertEquals($versionInfoMock, $result);
299
    }
300
301
    /**
302
     * Test for the loadVersionInfo() method.
@@ 306-345 (lines=40) @@
303
     *
304
     * @covers \eZ\Publish\Core\Repository\ContentService::loadVersionInfoById
305
     */
306
    public function testLoadVersionInfoByIdNonPublishedVersion()
307
    {
308
        $repository = $this->getRepositoryMock();
309
        $contentServiceMock = $this->getPartlyMockedContentService();
310
        /** @var \PHPUnit_Framework_MockObject_MockObject $contentHandler */
311
        $contentHandler = $this->getPersistenceMock()->contentHandler();
312
        $domainMapperMock = $this->getDomainMapperMock();
313
        $versionInfoMock = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\VersionInfo');
314
315
        $versionInfoMock->expects($this->any())
316
            ->method('__get')
317
            ->with('status')
318
            ->will($this->returnValue(APIVersionInfo::STATUS_DRAFT));
319
320
        $contentHandler->expects($this->once())
321
            ->method('loadVersionInfo')
322
            ->with(
323
                $this->equalTo(42),
324
                $this->equalTo(24)
325
            )->will(
326
                $this->returnValue(new SPIVersionInfo())
327
            );
328
329
        $domainMapperMock->expects($this->once())
330
            ->method('buildVersionInfoDomainObject')
331
            ->with(new SPIVersionInfo())
332
            ->will($this->returnValue($versionInfoMock));
333
334
        $repository->expects($this->once())
335
            ->method('canUser')
336
            ->with(
337
                $this->equalTo('content'),
338
                $this->equalTo('versionread'),
339
                $this->equalTo($versionInfoMock)
340
            )->will($this->returnValue(true));
341
342
        $result = $contentServiceMock->loadVersionInfoById(42, 24);
343
344
        $this->assertEquals($versionInfoMock, $result);
345
    }
346
347
    /**
348
     * Test for the loadVersionInfo() method.