Code Duplication    Length = 22-22 lines in 2 locations

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

@@ 2821-2842 (lines=22) @@
2818
     *
2819
     * @return \eZ\Publish\API\Repository\Values\User\User
2820
     */
2821
    private function createUserWithPassword(string $password, ContentType $contentType): User
2822
    {
2823
        $userService = $this->getRepository()->getUserService();
2824
        // ID of the "Editors" user group in an eZ Publish demo installation
2825
        $editorsGroupId = 13;
2826
2827
        // Instantiate a create struct with mandatory properties
2828
        $userCreate = $userService->newUserCreateStruct(
2829
            'johndoe',
2830
            '[email protected]',
2831
            $password,
2832
            'eng-US',
2833
            $contentType
2834
        );
2835
        $userCreate->enabled = true;
2836
        $userCreate->setField('first_name', 'John');
2837
        $userCreate->setField('last_name', 'Doe');
2838
2839
        return $userService->createUser($userCreate, array(
2840
            $userService->loadUserGroup($editorsGroupId),
2841
        ));
2842
    }
2843
2844
    /**
2845
     * Creates the User Content Type with password constraints.

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.