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

@@ 2866-2887 (lines=22) @@
2863
     *
2864
     * @return \eZ\Publish\API\Repository\Values\User\User
2865
     */
2866
    private function createUserWithPassword(string $password, ContentType $contentType): User
2867
    {
2868
        $userService = $this->getRepository()->getUserService();
2869
        // ID of the "Editors" user group in an eZ Publish demo installation
2870
        $editorsGroupId = 13;
2871
2872
        // Instantiate a create struct with mandatory properties
2873
        $userCreate = $userService->newUserCreateStruct(
2874
            'johndoe',
2875
            '[email protected]',
2876
            $password,
2877
            'eng-US',
2878
            $contentType
2879
        );
2880
        $userCreate->enabled = true;
2881
        $userCreate->setField('first_name', 'John');
2882
        $userCreate->setField('last_name', 'Doe');
2883
2884
        return $userService->createUser($userCreate, array(
2885
            $userService->loadUserGroup($editorsGroupId),
2886
        ));
2887
    }
2888
2889
    /**
2890
     * Creates the User Content Type with password constraints.