Code Duplication    Length = 34-34 lines in 2 locations

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

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