protected function getCredentialsFor( $roleIdentifier )
    {
        $roleService = $this->getRepository()->getRoleService();

        // First try to load role, throws exception if not found.
        $role = $this->getRepository()->sudo(
            function() use ( $roleService, $roleIdentifier )
            {
                // make sure role name starts with uppercase as this is what default setup provides
                if ($roleIdentifier !== ucfirst($roleIdentifier)) {
                    @trigger_error(
                        "'{$roleIdentifier}' role name should start with uppercase letter",
                        E_USER_DEPRECATED
                    );
                }

                return $roleService->loadRoleByIdentifier(ucfirst($roleIdentifier));
            }
        );

        // create a new user, uses 'User' trait
        $username = $this->findNonExistingUserName();
        $password = $this->getUserManager()->getDefaultPassword();
        $email = "${username}@ez.no";
        $user = $this->getUserManager()->ensureUserExists( $username, $email, $password );

        // Assign role to created user (without limitation)
        $this->getRepository()->sudo(
            function() use ( $roleService, $role, $user )
            {
                return $roleService->assignRoleToUser(
                    $role,
                    $user
                );
            }
        );

        return array(
            'login'     => $username,
            'password'  => $password,
        );
    }
protected function getCredentialsFor( $roleIdentifier )
    {
        $roleService = $this->getRepository()->getRoleService();

        // First try to load role, throws exception if not found.
        $role = $this->getRepository()->sudo(
            function() use ( $roleService, $roleIdentifier )
            {
                // make sure role name starts with uppercase as this is what default setup provides
                if ($roleIdentifier !== ucfirst($roleIdentifier)) {
                    @trigger_error(
                        "'{$roleIdentifier}' role name should start with uppercase letter",
                        E_USER_DEPRECATED
                    );
                }

                return $roleService->loadRoleByIdentifier(ucfirst($roleIdentifier));
            }
        );

        // create a new user, uses 'User' trait
        $username = $this->findNonExistingUserName();
        $password = $this->getUserManager()->getDefaultPassword();
        $email = "${username}@ez.no";
        $user = $this->getUserManager()->ensureUserExists( $username, $email, $password );

        // Assign role to created user (without limitation)
        $this->getRepository()->sudo(
            function() use ( $roleService, $role, $user )
            {
                return $roleService->assignRoleToUser(
                    $role,
                    $user
                );
            }
        );

        return array(
            'login'     => $username,
            'password'  => $password,
        );
    }
protected function getCredentialsFor ( $ roleIdentifier ) { $ roleService = $ this -> getRepository ( ) -> getRoleService ( ) ; // First try to load role, throws exception if not found. $ role = $ this -> getRepository ( ) -> sudo ( function ( ) use ( $ roleService , $ roleIdentifier ) { // make sure role name starts with uppercase as this is what default setup provides if ( $ roleIdentifier !== ucfirst ( $ roleIdentifier ) ) { @ trigger_error ( "'{$roleIdentifier}' role name should start with uppercase letter" , E_USER_DEPRECATED ) ; } return $ roleService -> loadRoleByIdentifier ( ucfirst ( $ roleIdentifier ) ) ; } ) ; // create a new user, uses 'User' trait $ username = $ this -> findNonExistingUserName ( ) ; $ password = $ this -> getUserManager ( ) -> getDefaultPassword ( ) ; $ email = "${username}@ez.no" ; $ user = $ this -> getUserManager ( ) -> ensureUserExists ( $ username , $ email , $ password ) ; // Assign role to created user (without limitation) $ this -> getRepository ( ) -> sudo ( function ( ) use ( $ roleService , $ role , $ user ) { return $ roleService -> assignRoleToUser ( $ role , $ user ) ; } ) ; return array ( 'login' => $ username , 'password' => $ password , ) ; }
Get credentials for a specific role

@uses \EzSystems\BehatBundle\Context\Object\User
@throws \eZ\Publish\API\Repository\Exceptions\NotFoundException

@param string $role Role intended for testing

@return array Associative with 'login' and 'password'
Get credentials for a specific role