Code Duplication    Length = 39-39 lines in 2 locations

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

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