diff --git a/tests/functions/validate_user_email_test.php b/tests/functions/validate_user_email_test.php index fb70c3014a..08fbe93b4b 100644 --- a/tests/functions/validate_user_email_test.php +++ b/tests/functions/validate_user_email_test.php @@ -28,18 +28,39 @@ class phpbb_functions_validate_user_email_test extends phpbb_database_test_case protected function setUp(): void { - global $cache, $phpbb_dispatcher, $phpbb_root_path, $phpEx; + global $cache, $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx; parent::setUp(); - $cache = new \phpbb\cache\driver\file(); - $cache->purge(); + $phpbb_container = new phpbb_mock_container_builder(); + $config = new \phpbb\config\config([]); $this->db = $this->new_dbal(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $language = new phpbb\language\language(new phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); $this->user = new phpbb\user($language, '\phpbb\datetime'); $this->user->data['user_email'] = ''; $this->helper = new phpbb_functions_validate_data_helper($this); + + $cache = new \phpbb\cache\service( + new \phpbb\cache\driver\dummy(), + $config, + $this->db, + $phpbb_dispatcher, + $phpbb_root_path, + $phpEx + ); + $cache->get_driver()->purge(); + + $ban_type_email = new \phpbb\ban\type\email($this->db, 'phpbb_users', 'phpbb_sessions', 'phpbb_sessions_keys'); + $ban_type_user = new \phpbb\ban\type\user($this->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, $this->db, 'phpbb_bans', 'phpbb_users'); + $phpbb_container->set('ban.manager', $ban_manager); } /** diff --git a/tests/session/testable_factory.php b/tests/session/testable_factory.php index bd25fa02f0..c85053770a 100644 --- a/tests/session/testable_factory.php +++ b/tests/session/testable_factory.php @@ -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; } diff --git a/tests/test_framework/phpbb_session_test_case.php b/tests/test_framework/phpbb_session_test_case.php index e3904f1746..79ac2d9c48 100644 --- a/tests/test_framework/phpbb_session_test_case.php +++ b/tests/test_framework/phpbb_session_test_case.php @@ -29,7 +29,7 @@ abstract class phpbb_session_test_case extends phpbb_database_test_case { parent::setUp(); - global $symfony_request, $phpbb_path_helper, $request, $phpbb_root_path, $phpEx; + global $symfony_request, $phpbb_path_helper, $phpbb_root_path, $phpEx; $symfony_request = new \phpbb\symfony_request( new phpbb_mock_request() );