1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-07 01:06:48 +02:00

[ticket/9687] Fix tests

PHPBB3-9687
This commit is contained in:
Marc Alexander
2023-07-04 14:49:31 +02:00
parent 7739eb2cfe
commit 8bdda472bf
3 changed files with 56 additions and 11 deletions

View File

@@ -38,7 +38,7 @@ class phpbb_session_testable_factory
public function __construct()
{
// default configuration values
$this->config_data = array(
$this->config_data = [
'allow_autologin' => false,
'auth_method' => 'db',
'forwarded_for_check' => true,
@@ -53,13 +53,14 @@ class phpbb_session_testable_factory
'limit_search_load' => 0,
'ip_check' => 3,
'browser_check' => 1,
);
];
$this->cache_data = array(
'_bots' => array(),
);
$this->cache_data = [
'_bots' => [],
'_ban_info' => [],
];
$this->cookies = array();
$this->cookies = [];
$this->server_data = $_SERVER;
}
@@ -73,7 +74,8 @@ class phpbb_session_testable_factory
public function get_session(\phpbb\db\driver\driver_interface $dbal)
{
// set up all the global variables used by session
global $SID, $_SID, $db, $config, $cache, $request, $phpbb_container, $phpbb_root_path;
global $SID, $_SID, $db, $config, $cache, $request, $phpbb_container, $phpbb_dispatcher;
global $phpbb_root_path, $phpEx;
$request = $this->request = new phpbb_mock_request(
array(),
@@ -103,6 +105,28 @@ class phpbb_session_testable_factory
$provider_collection
);
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$cache_service = new \phpbb\cache\service(
$cache,
$config,
$db,
$phpbb_dispatcher,
$phpbb_root_path,
$phpEx
);
$ban_type_email = new \phpbb\ban\type\email($db, 'phpbb_users', 'phpbb_sessions', 'phpbb_sessions_keys');
$ban_type_user = new \phpbb\ban\type\user($db, 'phpbb_users', 'phpbb_sessions', 'phpbb_sessions_keys');
$phpbb_container->set('ban.type.email', $ban_type_email);
$phpbb_container->set('ban.type.user', $ban_type_user);
$collection = new \phpbb\di\service_collection($phpbb_container);
$collection->add('ban.type.email');
$collection->add('ban.type.user');
$ban_manager = new \phpbb\ban\manager($collection, $cache_service, $db, 'phpbb_bans', 'phpbb_users');
$phpbb_container->set('ban.manager', $ban_manager);
$session = new phpbb_mock_session_testable;
return $session;
}