Code Duplication    Length = 20-24 lines in 4 locations

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

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

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

@@ 274-293 (lines=20) @@
271
     * @see \eZ\Publish\API\Repository\UserService::createUserGroup()
272
     * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUserGroup
273
     */
274
    public function testCreateUserGroupIncrementsParentSubGroupCount()
275
    {
276
        $repository = $this->getRepository();
277
        $userService = $repository->getUserService();
278
        $mainGroupId = $this->generateId('group', 4);
279
280
        $parentUserGroup = $userService->loadUserGroup($mainGroupId);
281
        $parentGroupCount = $parentUserGroup->subGroupCount;
282
283
        /* BEGIN: Use Case */
284
        $this->createUserGroupVersion1();
285
286
        $this->refreshSearch($repository);
287
288
        // This should be one greater than before
289
        $subGroupCount = $userService->loadUserGroup($mainGroupId)->subGroupCount;
290
        /* END: Use Case */
291
292
        $this->assertEquals($parentGroupCount + 1, $subGroupCount);
293
    }
294
295
    /**
296
     * Test for the createUserGroup() method.