Code Duplication    Length = 20-24 lines in 4 locations

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

@@ 146-165 (lines=20) @@
143
     * @see \eZ\Publish\API\Repository\TrashService::trash()
144
     * @depends eZ\Publish\API\Repository\Tests\TrashServiceTest::testTrash
145
     */
146
    public function testTrashDecrementsChildCountOnParentLocation()
147
    {
148
        $repository = $this->getRepository();
149
        $locationService = $repository->getLocationService();
150
151
        $baseLocationId = $this->generateId('location', 1);
152
153
        $location = $locationService->loadLocation($baseLocationId);
154
155
        $childCount = $locationService->getLocationChildCount($location);
156
157
        $this->createTrashItem();
158
159
        $this->refreshSearch($repository);
160
161
        $this->assertEquals(
162
            $childCount - 1,
163
            $locationService->getLocationChildCount($location)
164
        );
165
    }
166
167
    /**
168
     * Test for the loadTrashItem() method.

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

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

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/UserServiceTest.php 1 location

@@ 238-257 (lines=20) @@
235
     * @see \eZ\Publish\API\Repository\UserService::createUserGroup()
236
     * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUserGroup
237
     */
238
    public function testCreateUserGroupIncrementsParentSubGroupCount()
239
    {
240
        $repository = $this->getRepository();
241
        $userService = $repository->getUserService();
242
        $mainGroupId = $this->generateId('group', 4);
243
244
        $parentUserGroup = $userService->loadUserGroup($mainGroupId);
245
        $parentGroupCount = $parentUserGroup->subGroupCount;
246
247
        /* BEGIN: Use Case */
248
        $this->createUserGroupVersion1();
249
250
        $this->refreshSearch($repository);
251
252
        // This should be one greater than before
253
        $subGroupCount = $userService->loadUserGroup($mainGroupId)->subGroupCount;
254
        /* END: Use Case */
255
256
        $this->assertEquals($parentGroupCount + 1, $subGroupCount);
257
    }
258
259
    /**
260
     * Test for the createUserGroup() method.