Code Duplication    Length = 22-22 lines in 2 locations

eZ/Publish/API/Repository/Tests/Values/User/Limitation/RolePolicyLimitationTest.php 1 location

@@ 121-142 (lines=22) @@
118
     * @param \eZ\Publish\API\Repository\Values\User\UserGroup $group
119
     * @return \eZ\Publish\API\Repository\Values\User\User
120
     */
121
    protected function createUserInGroup(UserGroup $group)
122
    {
123
        $userService = $this->getRepository()->getUserService();
124
125
        // Instantiate a create struct with mandatory properties
126
        $userCreateStruct = $userService->newUserCreateStruct(
127
            'user',
128
            '[email protected]',
129
            'secret',
130
            'eng-US'
131
        );
132
        $userCreateStruct->enabled = true;
133
134
        // Set some fields required by the user ContentType
135
        $userCreateStruct->setField('first_name', 'Example');
136
        $userCreateStruct->setField('last_name', 'User');
137
138
        // Create a new user instance.
139
        $user = $userService->createUser($userCreateStruct, [$group]);
140
141
        return $user;
142
    }
143
144
    /**
145
     * Add policy to a new role.

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

@@ 2904-2925 (lines=22) @@
2901
     *
2902
     * @return \eZ\Publish\API\Repository\Values\User\User
2903
     */
2904
    private function createUserWithPassword(string $password, ContentType $contentType): User
2905
    {
2906
        $userService = $this->getRepository()->getUserService();
2907
        // ID of the "Editors" user group in an eZ Publish demo installation
2908
        $editorsGroupId = 13;
2909
2910
        // Instantiate a create struct with mandatory properties
2911
        $userCreate = $userService->newUserCreateStruct(
2912
            'johndoe',
2913
            '[email protected]',
2914
            $password,
2915
            'eng-US',
2916
            $contentType
2917
        );
2918
        $userCreate->enabled = true;
2919
        $userCreate->setField('first_name', 'John');
2920
        $userCreate->setField('last_name', 'Doe');
2921
2922
        return $userService->createUser($userCreate, [
2923
            $userService->loadUserGroup($editorsGroupId),
2924
        ]);
2925
    }
2926
2927
    /**
2928
     * Creates the User Content Type with password constraints.