Code Duplication    Length = 17-20 lines in 2 locations

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

@@ 30-49 (lines=20) @@
27
     * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testCreateRole
28
     * @depends eZ\Publish\API\Repository\Tests\UserServiceTest::testCreateUser
29
     */
30
    public function testCreateRoleThrowsUnauthorizedException()
31
    {
32
        $repository = $this->getRepository();
33
34
        /* BEGIN: Use Case */
35
        $user = $this->createUserVersion1();
36
37
        // Set "Editor" user as current user.
38
        $repository->setCurrentUser($user);
39
40
        // Get the role service
41
        $roleService = $repository->getRoleService();
42
43
        // Instantiate a role create struct.
44
        $roleCreate = $roleService->newRoleCreateStruct('roleName');
45
46
        // This call will fail with an "UnauthorizedException"
47
        $roleService->createRole($roleCreate);
48
        /* END: Use Case */
49
    }
50
51
    /**
52
     * Test for the loadRole() method.

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

@@ 1199-1215 (lines=17) @@
1196
     * @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException
1197
     * @depends eZ\Publish\API\Repository\Tests\RoleServiceTest::testCreateRole
1198
     */
1199
    public function testPublishEmptyRoleThrowsInvalidArgumentException()
1200
    {
1201
        $repository = $this->getRepository();
1202
1203
        /* BEGIN: Use Case */
1204
        $roleService = $repository->getRoleService();
1205
1206
        $roleCreate = $roleService->newRoleCreateStruct('Lumberjack');
1207
1208
        // @todo uncomment when support for multilingual names and descriptions is added EZP-24776
1209
        // $roleCreate->mainLanguageCode = 'eng-US';
1210
1211
        $roleDraft = $roleService->createRole($roleCreate);
1212
        // This call will fail with an InvalidArgumentException, because the role has no policies
1213
        $roleService->publishRoleDraft($roleDraft);
1214
        /* END: Use Case */
1215
    }
1216
1217
    /**
1218
     * Test for the addPolicy() method.