protected function create_user($username)
{
// Required by unique_id
global $config;
$config = new \phpbb\config\config(array());
/*
* Add required config entries to the config array to prevent
* set_config() sending an INSERT query for already existing entries,
* resulting in a SQL error.
* This is because set_config() first sends an UPDATE query, then checks
* sql_affectedrows() which can be 0 (e.g. on MySQL) when the new
* data is already there.
*/
$config['newest_user_colour'] = '';
$config['rand_seed'] = '';
$config['rand_seed_last_update'] = time() + 600;
// Required by user_add
global $db, $cache, $phpbb_dispatcher, $phpbb_container;
$db = $this->get_db();
if (!function_exists('phpbb_mock_null_cache')) {
require_once __DIR__ . '/../mock/null_cache.php';
}
$cache = new phpbb_mock_null_cache();
$cache_driver = new \phpbb\cache\driver\dummy();
$phpbb_container = new phpbb_mock_container_builder();
$phpbb_container->set('cache.driver', $cache_driver);
$phpbb_notifications = new phpbb_mock_notification_manager();
$phpbb_container->set('notification_manager', $phpbb_notifications);
if (!function_exists('utf_clean_string')) {
require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php';
}
if (!function_exists('user_add')) {
require_once __DIR__ . '/../../phpBB/includes/functions_user.php';
}
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$passwords_manager = $this->get_passwords_manager();
$user_row = array('username' => $username, 'group_id' => 2, 'user_email' => '[email protected]', 'user_type' => 0, 'user_lang' => 'en', 'user_timezone' => 'UTC', 'user_dateformat' => 'r', 'user_password' => $passwords_manager->hash($username . $username));
return user_add($user_row);
}