Code Duplication    Length = 33-35 lines in 2 locations

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

@@ 379-411 (lines=33) @@
376
        $this->assertSame($content, $contentService->loadContent($contentId));
377
    }
378
379
    public function testLoadContentNonPublished()
380
    {
381
        $repository = $this->getRepositoryMock();
382
        $contentService = $this->getPartlyMockedContentService(array('internalLoadContent'));
383
        $content = $this->createMock(APIContent::class);
384
        $versionInfo = $this
385
            ->getMockBuilder(APIVersionInfo::class)
386
            ->getMockForAbstractClass();
387
        $content
388
            ->expects($this->once())
389
            ->method('getVersionInfo')
390
            ->will($this->returnValue($versionInfo));
391
        $contentId = 123;
392
        $contentService
393
            ->expects($this->once())
394
            ->method('internalLoadContent')
395
            ->with($contentId)
396
            ->will($this->returnValue($content));
397
398
        $repository
399
            ->expects($this->exactly(2))
400
            ->method('canUser')
401
            ->will(
402
                $this->returnValueMap(
403
                    array(
404
                        array('content', 'read', $content, null, true),
405
                        array('content', 'versionread', $content, null, true),
406
                    )
407
                )
408
            );
409
410
        $this->assertSame($content, $contentService->loadContent($contentId));
411
    }
412
413
    public function testLoadContentUnauthorized()
414
    {
@@ 436-470 (lines=35) @@
433
        $contentService->loadContent($contentId);
434
    }
435
436
    public function testLoadContentNotPublishedStatusUnauthorized()
437
    {
438
        $this->expectException(\eZ\Publish\Core\Base\Exceptions\UnauthorizedException::class);
439
440
        $repository = $this->getRepositoryMock();
441
        $contentService = $this->getPartlyMockedContentService(array('internalLoadContent'));
442
        $content = $this->createMock(APIContent::class);
443
        $versionInfo = $this
444
            ->getMockBuilder(APIVersionInfo::class)
445
            ->getMockForAbstractClass();
446
        $content
447
            ->expects($this->once())
448
            ->method('getVersionInfo')
449
            ->will($this->returnValue($versionInfo));
450
        $contentId = 123;
451
        $contentService
452
            ->expects($this->once())
453
            ->method('internalLoadContent')
454
            ->with($contentId)
455
            ->will($this->returnValue($content));
456
457
        $repository
458
            ->expects($this->exactly(2))
459
            ->method('canUser')
460
            ->will(
461
                $this->returnValueMap(
462
                    array(
463
                        array('content', 'read', $content, null, true),
464
                        array('content', 'versionread', $content, null, false),
465
                    )
466
                )
467
            );
468
469
        $contentService->loadContent($contentId);
470
    }
471
472
    /**
473
     * @dataProvider internalLoadContentProvider