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

@@ 2842-2863 (lines=22) @@
2839
     *
2840
     * @return \eZ\Publish\API\Repository\Values\User\User
2841
     */
2842
    private function createUserWithPassword(string $password, ContentType $contentType): User
2843
    {
2844
        $userService = $this->getRepository()->getUserService();
2845
        // ID of the "Editors" user group in an eZ Publish demo installation
2846
        $editorsGroupId = 13;
2847
2848
        // Instantiate a create struct with mandatory properties
2849
        $userCreate = $userService->newUserCreateStruct(
2850
            'johndoe',
2851
            '[email protected]',
2852
            $password,
2853
            'eng-US',
2854
            $contentType
2855
        );
2856
        $userCreate->enabled = true;
2857
        $userCreate->setField('first_name', 'John');
2858
        $userCreate->setField('last_name', 'Doe');
2859
2860
        return $userService->createUser($userCreate, array(
2861
            $userService->loadUserGroup($editorsGroupId),
2862
        ));
2863
    }
2864
2865
    /**
2866
     * Creates the User Content Type with password constraints.