Code Duplication    Length = 31-33 lines in 2 locations

eZ/Publish/API/Repository/Tests/Values/User/Limitation/SubtreeLimitationTest.php 1 location

@@ 36-66 (lines=31) @@
33
     * @see eZ\Publish\API\Repository\Values\User\Limitation\SectionLimitation
34
     * @see eZ\Publish\API\Repository\Values\User\Limitation\SubtreeLimitation
35
     */
36
    public function testSubtreeLimitationAllow()
37
    {
38
        $repository = $this->getRepository();
39
40
        $userGroupId = $this->generateId('content', 13);
41
        /* BEGIN: Use Case */
42
        $subtree = '/1/5/';
43
44
        $this->prepareLimitation($subtree);
45
46
        $userService = $repository->getUserService();
47
        $contentService = $repository->getContentService();
48
49
        $contentUpdate = $contentService->newContentUpdateStruct();
50
        $contentUpdate->setField('name', 'eZ Editors');
51
52
        $userGroup = $userService->loadUserGroup($userGroupId);
53
54
        $groupUpdate = $userService->newUserGroupUpdateStruct();
55
        $groupUpdate->contentUpdateStruct = $contentUpdate;
56
57
        $userService->updateUserGroup($userGroup, $groupUpdate);
58
        /* END: Use Case */
59
60
        $this->assertEquals(
61
            'eZ Editors',
62
            $userService->loadUserGroup($userGroupId)
63
                ->getFieldValue('name')
64
                ->text
65
        );
66
    }
67
68
    /**
69
     * Tests a combination of SubtreeLimitation, SectionLimitation and

eZ/Publish/API/Repository/Tests/UserServiceTest.php 1 location

@@ 622-654 (lines=33) @@
619
     * @see \eZ\Publish\API\Repository\UserService::updateUserGroup()
620
     * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testUpdateUserGroup
621
     */
622
    public function testUpdateUserGroupWithSubContentUpdateStruct()
623
    {
624
        $repository = $this->getRepository();
625
        $userService = $repository->getUserService();
626
627
        /* BEGIN: Use Case */
628
        $userGroup = $this->createUserGroupVersion1();
629
630
        // Load the content service
631
        $contentService = $repository->getContentService();
632
633
        // Create a content update struct and update the group name
634
        $contentUpdate = $contentService->newContentUpdateStruct();
635
        $contentUpdate->setField('name', 'Sindelfingen', 'eng-US');
636
637
        // Create a group update struct and set content update struct
638
        $groupUpdate = $userService->newUserGroupUpdateStruct();
639
        $groupUpdate->contentUpdateStruct = $contentUpdate;
640
641
        // This will update the name and the increment the group version number
642
        $userGroup = $userService->updateUserGroup(
643
            $userGroup,
644
            $groupUpdate
645
        );
646
        /* END: Use Case */
647
648
        $this->assertEquals('Sindelfingen', $userGroup->getFieldValue('name', 'eng-US'));
649
650
        $versionInfo = $userGroup->getVersionInfo();
651
652
        $this->assertEquals(APIVersionInfo::STATUS_PUBLISHED, $versionInfo->status);
653
        $this->assertEquals(2, $versionInfo->versionNo);
654
    }
655
656
    /**
657
     * Test for the updateUserGroup() method.