Code Duplication    Length = 20-24 lines in 3 locations

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

@@ 134-157 (lines=24) @@
131
     * @expectedException \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
132
     * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testMoveUserGroup
133
     */
134
    public function testMoveUserGroupThrowsUnauthorizedException()
135
    {
136
        $repository = $this->getRepository();
137
        $userService = $repository->getUserService();
138
139
        $memberGroupId = $this->generateId('group', 11);
140
        /* BEGIN: Use Case */
141
        // $memberGroupId is the ID of the "Members" group in an eZ Publish
142
        // demo installation
143
        //
144
        $user = $this->createUserVersion1();
145
146
        $userGroup = $this->createUserGroupVersion1();
147
148
        // Load new parent user group
149
        $newParentUserGroup = $userService->loadUserGroup($memberGroupId);
150
151
        // Now set the currently created "Editor" as current user
152
        $repository->setCurrentUser($user);
153
154
        // This call will fail with an "UnauthorizedException"
155
        $userService->moveUserGroup($userGroup, $newParentUserGroup);
156
        /* END: Use Case */
157
    }
158
159
    /**
160
     * Test for the updateUserGroup() method.

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

@@ 580-602 (lines=23) @@
577
     * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testGetRoleAssignmentsForUserGroup
578
     * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser
579
     */
580
    public function testGetRoleAssignmentsForUserGroupThrowsUnauthorizedException()
581
    {
582
        $repository = $this->getRepository();
583
        $roleService = $repository->getRoleService();
584
        $userService = $repository->getUserService();
585
586
        $editorsGroupId = $this->generateId('group', 13);
587
588
        /* BEGIN: Use Case */
589
        $user = $this->createUserVersion1();
590
591
        $this->createRole();
592
593
        // Load the "Editors" user group
594
        $userGroup = $userService->loadUserGroup($editorsGroupId);
595
596
        // Set "Editor" user as current user.
597
        $repository->setCurrentUser($user);
598
599
        // This call will fail with an "UnauthorizedException"
600
        $roleService->getRoleAssignmentsForUserGroup($userGroup);
601
        /* END: Use Case */
602
    }
603
604
    /**
605
     * Create a role fixture in a variable named <b>$role</b>,.

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

@@ 151-170 (lines=20) @@
148
     * @see \eZ\Publish\API\Repository\TrashService::trash()
149
     * @depends eZ\Publish\API\Repository\Tests\TrashServiceTest::testTrash
150
     */
151
    public function testTrashDecrementsChildCountOnParentLocation()
152
    {
153
        $repository = $this->getRepository();
154
        $locationService = $repository->getLocationService();
155
156
        $baseLocationId = $this->generateId('location', 1);
157
158
        $location = $locationService->loadLocation($baseLocationId);
159
160
        $childCount = $locationService->getLocationChildCount($location);
161
162
        $this->createTrashItem();
163
164
        $this->refreshSearch($repository);
165
166
        $this->assertEquals(
167
            $childCount - 1,
168
            $locationService->getLocationChildCount($location)
169
        );
170
    }
171
172
    /**
173
     * Test sending a location to trash updates Content mainLocation.