Code Duplication    Length = 20-25 lines in 2 locations

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

@@ 441-460 (lines=20) @@
438
    /**
439
     * @expectedException \eZ\Publish\Core\Base\Exceptions\UnauthorizedException
440
     */
441
    public function testLoadContentUnauthorized()
442
    {
443
        $repository = $this->getRepositoryMock();
444
        $contentService = $this->getPartlyMockedContentService(array('internalLoadContent'));
445
        $content = $this->getMock('eZ\Publish\API\Repository\Values\Content\Content');
446
        $contentId = 123;
447
        $contentService
448
            ->expects($this->once())
449
            ->method('internalLoadContent')
450
            ->with($contentId)
451
            ->will($this->returnValue($content));
452
453
        $repository
454
            ->expects($this->once())
455
            ->method('canUser')
456
            ->with('content', 'read', $content)
457
            ->will($this->returnValue(false));
458
459
        $contentService->loadContent($contentId);
460
    }
461
462
    /**
463
     * @expectedException \eZ\Publish\Core\Base\Exceptions\UnauthorizedException
@@ 5240-5264 (lines=25) @@
5237
     * @covers \eZ\Publish\Core\Repository\ContentService::copyContent
5238
     * @expectedException \eZ\Publish\Core\Base\Exceptions\UnauthorizedException
5239
     */
5240
    public function testCopyContentThrowsUnauthorizedException()
5241
    {
5242
        $repository = $this->getRepositoryMock();
5243
        $contentService = $this->getPartlyMockedContentService(array('internalLoadContentInfo'));
5244
        $contentInfo = $this->getMock('eZ\\Publish\\API\\Repository\\Values\\Content\\ContentInfo');
5245
        $locationCreateStruct = new LocationCreateStruct();
5246
5247
        $contentInfo->expects($this->any())
5248
            ->method('__get')
5249
            ->with('sectionId')
5250
            ->will($this->returnValue(42));
5251
5252
        $repository->expects($this->once())
5253
            ->method('canUser')
5254
            ->with(
5255
                'content',
5256
                'create',
5257
                $contentInfo,
5258
                $locationCreateStruct
5259
            )
5260
            ->will($this->returnValue(false));
5261
5262
        /* @var \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo */
5263
        $contentService->copyContent($contentInfo, $locationCreateStruct);
5264
    }
5265
5266
    /**
5267
     * Test for the copyContent() method.