Code Duplication    Length = 33-35 lines in 2 locations

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

@@ 421-453 (lines=33) @@
418
        $this->assertSame($content, $contentService->loadContent($contentId));
419
    }
420
421
    public function testLoadContentNonPublished()
422
    {
423
        $repository = $this->getRepositoryMock();
424
        $contentService = $this->getPartlyMockedContentService(array('internalLoadContent'));
425
        $content = $this->createMock(APIContent::class);
426
        $versionInfo = $this
427
            ->getMockBuilder(APIVersionInfo::class)
428
            ->getMockForAbstractClass();
429
        $content
430
            ->expects($this->once())
431
            ->method('getVersionInfo')
432
            ->will($this->returnValue($versionInfo));
433
        $contentId = 123;
434
        $contentService
435
            ->expects($this->once())
436
            ->method('internalLoadContent')
437
            ->with($contentId)
438
            ->will($this->returnValue($content));
439
440
        $repository
441
            ->expects($this->exactly(2))
442
            ->method('canUser')
443
            ->will(
444
                $this->returnValueMap(
445
                    array(
446
                        array('content', 'read', $content, null, true),
447
                        array('content', 'versionread', $content, null, true),
448
                    )
449
                )
450
            );
451
452
        $this->assertSame($content, $contentService->loadContent($contentId));
453
    }
454
455
    /**
456
     */
@@ 482-516 (lines=35) @@
479
480
    /**
481
     */
482
    public function testLoadContentNotPublishedStatusUnauthorized()
483
    {
484
        $this->expectException(\eZ\Publish\Core\Base\Exceptions\UnauthorizedException::class);
485
486
        $repository = $this->getRepositoryMock();
487
        $contentService = $this->getPartlyMockedContentService(array('internalLoadContent'));
488
        $content = $this->createMock(APIContent::class);
489
        $versionInfo = $this
490
            ->getMockBuilder(APIVersionInfo::class)
491
            ->getMockForAbstractClass();
492
        $content
493
            ->expects($this->once())
494
            ->method('getVersionInfo')
495
            ->will($this->returnValue($versionInfo));
496
        $contentId = 123;
497
        $contentService
498
            ->expects($this->once())
499
            ->method('internalLoadContent')
500
            ->with($contentId)
501
            ->will($this->returnValue($content));
502
503
        $repository
504
            ->expects($this->exactly(2))
505
            ->method('canUser')
506
            ->will(
507
                $this->returnValueMap(
508
                    array(
509
                        array('content', 'read', $content, null, true),
510
                        array('content', 'versionread', $content, null, false),
511
                    )
512
                )
513
            );
514
515
        $contentService->loadContent($contentId);
516
    }
517
518
    /**
519
     * @dataProvider internalLoadContentProvider