Code Duplication    Length = 20-24 lines in 3 locations

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

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

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

@@ 629-651 (lines=23) @@
626
     * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testGetRoleAssignmentsForUserGroup
627
     * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser
628
     */
629
    public function testGetRoleAssignmentsForUserGroupThrowsUnauthorizedException()
630
    {
631
        $repository = $this->getRepository();
632
        $roleService = $repository->getRoleService();
633
        $userService = $repository->getUserService();
634
635
        $editorsGroupId = $this->generateId('group', 13);
636
637
        /* BEGIN: Use Case */
638
        $user = $this->createUserVersion1();
639
640
        $this->createRole();
641
642
        // Load the "Editors" user group
643
        $userGroup = $userService->loadUserGroup($editorsGroupId);
644
645
        // Set "Editor" user as current user.
646
        $repository->setCurrentUser($user);
647
648
        // This call will fail with an "UnauthorizedException"
649
        $roleService->getRoleAssignmentsForUserGroup($userGroup);
650
        /* END: Use Case */
651
    }
652
653
    /**
654
     * Create a role fixture in a variable named <b>$role</b>,.

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

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