Code Duplication    Length = 39-39 lines in 2 locations

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

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