Code Duplication    Length = 33-36 lines in 2 locations

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

@@ 429-461 (lines=33) @@
426
        $this->assertSame($content, $contentService->loadContent($contentId));
427
    }
428
429
    public function testLoadContentNonPublished()
430
    {
431
        $repository = $this->getRepositoryMock();
432
        $contentService = $this->getPartlyMockedContentService(['internalLoadContent']);
433
        $content = $this->createMock(APIContent::class);
434
        $versionInfo = $this->createMock(APIVersionInfo::class);
435
        $permissionResolver = $this->getPermissionResolverMock();
436
437
        $content
438
            ->expects($this->once())
439
            ->method('getVersionInfo')
440
            ->will($this->returnValue($versionInfo));
441
        $contentId = 123;
442
        $contentService
443
            ->expects($this->once())
444
            ->method('internalLoadContent')
445
            ->with($contentId)
446
            ->will($this->returnValue($content));
447
448
        $permissionResolver
449
            ->expects($this->exactly(2))
450
            ->method('canUser')
451
            ->will(
452
                $this->returnValueMap(
453
                    [
454
                        ['content', 'read', $content, [], true],
455
                        ['content', 'versionread', $content, [], true],
456
                    ]
457
                )
458
            );
459
460
        $this->assertSame($content, $contentService->loadContent($contentId));
461
    }
462
463
    public function testLoadContentUnauthorized()
464
    {
@@ 488-523 (lines=36) @@
485
        $contentService->loadContent($contentId);
486
    }
487
488
    public function testLoadContentNotPublishedStatusUnauthorized()
489
    {
490
        $this->expectException(\eZ\Publish\Core\Base\Exceptions\UnauthorizedException::class);
491
492
        $repository = $this->getRepositoryMock();
493
        $permissionResolver = $this->getPermissionResolverMock();
494
        $contentService = $this->getPartlyMockedContentService(['internalLoadContent']);
495
        $content = $this->createMock(APIContent::class);
496
        $versionInfo = $this
497
            ->getMockBuilder(APIVersionInfo::class)
498
            ->getMockForAbstractClass();
499
        $content
500
            ->expects($this->once())
501
            ->method('getVersionInfo')
502
            ->will($this->returnValue($versionInfo));
503
        $contentId = 123;
504
        $contentService
505
            ->expects($this->once())
506
            ->method('internalLoadContent')
507
            ->with($contentId)
508
            ->will($this->returnValue($content));
509
510
        $permissionResolver
511
            ->expects($this->exactly(2))
512
            ->method('canUser')
513
            ->will(
514
                $this->returnValueMap(
515
                    [
516
                        ['content', 'read', $content, [], true],
517
                        ['content', 'versionread', $content, [], false],
518
                    ]
519
                )
520
            );
521
522
        $contentService->loadContent($contentId);
523
    }
524
525
    /**
526
     * @dataProvider internalLoadContentProvider