Code Duplication    Length = 34-34 lines in 2 locations

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

@@ 410-443 (lines=34) @@
407
        $this->assertSame($content, $contentService->loadContent($contentId));
408
    }
409
410
    public function testLoadContentNonPublished()
411
    {
412
        $repository = $this->getRepositoryMock();
413
        $contentService = $this->getPartlyMockedContentService(array('internalLoadContent'));
414
        $content = $this->getMock('eZ\Publish\API\Repository\Values\Content\Content');
415
        $versionInfo = $this
416
            ->getMockBuilder('eZ\Publish\API\Repository\Values\Content\VersionInfo')
417
            ->setConstructorArgs(array(array('status' => APIVersionInfo::STATUS_DRAFT)))
418
            ->getMockForAbstractClass();
419
        $content
420
            ->expects($this->once())
421
            ->method('getVersionInfo')
422
            ->will($this->returnValue($versionInfo));
423
        $contentId = 123;
424
        $contentService
425
            ->expects($this->once())
426
            ->method('internalLoadContent')
427
            ->with($contentId)
428
            ->will($this->returnValue($content));
429
430
        $repository
431
            ->expects($this->exactly(2))
432
            ->method('canUser')
433
            ->will(
434
                $this->returnValueMap(
435
                    array(
436
                        array('content', 'read', $content, null, true),
437
                        array('content', 'versionread', $content, null, true),
438
                    )
439
                )
440
            );
441
442
        $this->assertSame($content, $contentService->loadContent($contentId));
443
    }
444
445
    /**
446
     * @expectedException \eZ\Publish\Core\Base\Exceptions\UnauthorizedException
@@ 472-505 (lines=34) @@
469
    /**
470
     * @expectedException \eZ\Publish\Core\Base\Exceptions\UnauthorizedException
471
     */
472
    public function testLoadContentNotPublishedStatusUnauthorized()
473
    {
474
        $repository = $this->getRepositoryMock();
475
        $contentService = $this->getPartlyMockedContentService(array('internalLoadContent'));
476
        $content = $this->getMock('eZ\Publish\API\Repository\Values\Content\Content');
477
        $versionInfo = $this
478
            ->getMockBuilder('eZ\Publish\API\Repository\Values\Content\VersionInfo')
479
            ->setConstructorArgs(array(array('status' => APIVersionInfo::STATUS_DRAFT)))
480
            ->getMockForAbstractClass();
481
        $content
482
            ->expects($this->once())
483
            ->method('getVersionInfo')
484
            ->will($this->returnValue($versionInfo));
485
        $contentId = 123;
486
        $contentService
487
            ->expects($this->once())
488
            ->method('internalLoadContent')
489
            ->with($contentId)
490
            ->will($this->returnValue($content));
491
492
        $repository
493
            ->expects($this->exactly(2))
494
            ->method('canUser')
495
            ->will(
496
                $this->returnValueMap(
497
                    array(
498
                        array('content', 'read', $content, null, true),
499
                        array('content', 'versionread', $content, null, false),
500
                    )
501
                )
502
            );
503
504
        $contentService->loadContent($contentId);
505
    }
506
507
    /**
508
     * @dataProvider internalLoadContentProvider