src/Codeception/Module/WPDb.php
public function haveUserInDatabase($user_login, $role = 'subscriber', array $overrides = [])
    {
        $hasMeta = !empty($overrides['meta']);
        $meta = [];
        if ($hasMeta) {
            $meta = $overrides['meta'];
            unset($overrides['meta']);
        }

        $userTableData = User::generateUserTableDataFrom($user_login, $overrides);
        $this->debugSection('Generated users table data', json_encode($userTableData));
        $userId = $this->haveInDatabase($this->grabUsersTableName(), $userTableData);

        $this->haveUserCapabilitiesInDatabase($userId, $role);
        $this->haveUserLevelsInDatabase($userId, $role);

        if ($hasMeta) {
            foreach ($meta as $key => $value) {
                $this->haveUserMetaInDatabase($userId, $key, $value);
            }
        }

        return $userId;
    }
public function haveUserInDatabase($user_login, $role = 'subscriber', array $overrides = [])
    {
        $hasMeta = !empty($overrides['meta']);
        $meta = [];
        if ($hasMeta) {
            $meta = $overrides['meta'];
            unset($overrides['meta']);
        }

        $userTableData = User::generateUserTableDataFrom($user_login, $overrides);
        $this->debugSection('Generated users table data', json_encode($userTableData));
        $userId = $this->haveInDatabase($this->grabUsersTableName(), $userTableData);

        $this->haveUserCapabilitiesInDatabase($userId, $role);
        $this->haveUserLevelsInDatabase($userId, $role);

        if ($hasMeta) {
            foreach ($meta as $key => $value) {
                $this->haveUserMetaInDatabase($userId, $key, $value);
            }
        }

        return $userId;
    }
public function haveUserInDatabase ( $ user_login , $ role = 'subscriber' , array $ overrides = [ ] ) { $ hasMeta = ! empty ( $ overrides [ 'meta' ] ) ; $ meta = [ ] ; if ( $ hasMeta ) { $ meta = $ overrides [ 'meta' ] ; unset ( $ overrides [ 'meta' ] ) ; } $ userTableData = User :: generateUserTableDataFrom ( $ user_login , $ overrides ) ; $ this -> debugSection ( 'Generated users table data' , json_encode ( $ userTableData ) ) ; $ userId = $ this -> haveInDatabase ( $ this -> grabUsersTableName ( ) , $ userTableData ) ; $ this -> haveUserCapabilitiesInDatabase ( $ userId , $ role ) ; $ this -> haveUserLevelsInDatabase ( $ userId , $ role ) ; if ( $ hasMeta ) { foreach ( $ meta as $ key => $ value ) { $ this -> haveUserMetaInDatabase ( $ userId , $ key , $ value ) ; } } return $ userId ; }
Inserts a user and its meta in the database.

@example
```php
$userId = $I->haveUserInDatabase('luca', 'editor', ['user_email' => 'luca@example.org']);
$subscriberId = $I->haveUserInDatabase('test');
```

@param  string $user_login The user login name.
@param  string $role       The user role slug, e.g. "administrator"; defaults to "subscriber".
@param  array  $overrides  An associative array of column names and values overridind defaults in the "users"
and "usermeta" table.

@return int The inserted user ID.
Inserts a user and its meta in the database .