diff --git a/tests/auth/provider_apache_test.php b/tests/auth/provider_apache_test.php index e135a1f002..d7509a72bf 100644 --- a/tests/auth/provider_apache_test.php +++ b/tests/auth/provider_apache_test.php @@ -7,7 +7,8 @@ * */ -require_once dirname(__FILE__).'/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; class phpbb_auth_provider_apache_test extends phpbb_database_test_case { diff --git a/tests/auth/provider_db_test.php b/tests/auth/provider_db_test.php index 140a28cd3d..45a893220b 100644 --- a/tests/auth/provider_db_test.php +++ b/tests/auth/provider_db_test.php @@ -7,7 +7,8 @@ * */ -require_once dirname(__FILE__).'/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; class phpbb_auth_provider_db_test extends phpbb_database_test_case { diff --git a/tests/functions/validate_password_test.php b/tests/functions/validate_password_test.php index 4639f6cc89..82c5fa03c1 100644 --- a/tests/functions/validate_password_test.php +++ b/tests/functions/validate_password_test.php @@ -7,6 +7,7 @@ * */ +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php'; require_once dirname(__FILE__) . '/validate_data_helper.php'; diff --git a/tests/functions_acp/build_select_test.php b/tests/functions_acp/build_select_test.php index aca49b7655..c44fd97ec3 100644 --- a/tests/functions_acp/build_select_test.php +++ b/tests/functions_acp/build_select_test.php @@ -11,6 +11,16 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php'; class phpbb_functions_acp_built_select_test extends phpbb_test_case { + protected function setUp() + { + parent::setUp(); + + global $user; + + $user = new phpbb_mock_user(); + $user->lang = new phpbb_mock_lang(); + } + public function build_select_data() { return array( @@ -46,10 +56,6 @@ class phpbb_functions_acp_built_select_test extends phpbb_test_case */ public function test_build_select($option_ary, $option_default, $expected) { - global $user; - - $user->lang = new phpbb_mock_lang(); - $this->assertEquals($expected, build_select($option_ary, $option_default)); } } diff --git a/tests/functions_acp/h_radio_test.php b/tests/functions_acp/h_radio_test.php index a61f2e8975..4c1872d341 100644 --- a/tests/functions_acp/h_radio_test.php +++ b/tests/functions_acp/h_radio_test.php @@ -11,6 +11,16 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php'; class phpbb_functions_acp_h_radio_test extends phpbb_test_case { + protected function setUp() + { + parent::setUp(); + + global $user; + + $user = new phpbb_mock_user(); + $user->lang = new phpbb_mock_lang(); + } + public function h_radio_data() { return array( @@ -111,10 +121,6 @@ class phpbb_functions_acp_h_radio_test extends phpbb_test_case */ public function test_h_radio($name, $input_ary, $input_default, $id, $key, $expected) { - global $user; - - $user->lang = new phpbb_mock_lang(); - $this->assertEquals($expected, h_radio($name, $input_ary, $input_default, $id, $key)); } } diff --git a/tests/functions_acp/validate_config_vars_test.php b/tests/functions_acp/validate_config_vars_test.php index 7cd7fa3892..acc98fbf0d 100644 --- a/tests/functions_acp/validate_config_vars_test.php +++ b/tests/functions_acp/validate_config_vars_test.php @@ -8,9 +8,20 @@ */ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php'; +require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php'; class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case { + protected function setUp() + { + parent::setUp(); + + global $user; + + $user = new phpbb_mock_user(); + $user->lang = new phpbb_mock_lang(); + } + /** * Data sets that don't throw an error. */ @@ -60,10 +71,6 @@ class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case */ public function test_validate_config_vars_fit($test_data, $cfg_array) { - global $user; - - $user->lang = new phpbb_mock_lang(); - $phpbb_error = array(); validate_config_vars($test_data, $cfg_array, $phpbb_error); @@ -146,10 +153,6 @@ class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case */ public function test_validate_config_vars_error($test_data, $cfg_array, $expected) { - global $user; - - $user->lang = new phpbb_mock_lang(); - $phpbb_error = array(); validate_config_vars($test_data, $cfg_array, $phpbb_error); diff --git a/tests/functions_acp/validate_range_test.php b/tests/functions_acp/validate_range_test.php index 8606158251..cb028d4d07 100644 --- a/tests/functions_acp/validate_range_test.php +++ b/tests/functions_acp/validate_range_test.php @@ -12,6 +12,16 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php'; class phpbb_functions_acp_validate_range_test extends phpbb_test_case { + protected function setUp() + { + parent::setUp(); + + global $user; + + $user = new phpbb_mock_user(); + $user->lang = new phpbb_mock_lang(); + } + /** * Data sets that don't throw an error. */ @@ -52,10 +62,6 @@ class phpbb_functions_acp_validate_range_test extends phpbb_test_case */ public function test_validate_range_fit($test_data) { - global $user; - - $user->lang = new phpbb_mock_lang(); - $phpbb_error = array(); validate_range($test_data, $phpbb_error); @@ -91,10 +97,6 @@ class phpbb_functions_acp_validate_range_test extends phpbb_test_case */ public function test_validate_range_too_low($test_data) { - global $user; - - $user->lang = new phpbb_mock_lang(); - $phpbb_error = array(); validate_range($test_data, $phpbb_error); @@ -130,10 +132,6 @@ class phpbb_functions_acp_validate_range_test extends phpbb_test_case */ public function test_validate_range_too_big($test_data) { - global $user; - - $user->lang = new phpbb_mock_lang(); - $phpbb_error = array(); validate_range($test_data, $phpbb_error); @@ -158,10 +156,6 @@ class phpbb_functions_acp_validate_range_test extends phpbb_test_case */ public function test_validate_range_too_long($test_data) { - global $user; - - $user->lang = new phpbb_mock_lang(); - $phpbb_error = array(); validate_range($test_data, $phpbb_error); diff --git a/tests/functions_user/group_user_attributes_test.php b/tests/functions_user/group_user_attributes_test.php index f8d52a9a6a..4317cf79da 100644 --- a/tests/functions_user/group_user_attributes_test.php +++ b/tests/functions_user/group_user_attributes_test.php @@ -127,6 +127,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes { global $auth, $cache, $db, $phpbb_dispatcher, $user, $phpbb_container, $phpbb_log, $phpbb_root_path, $phpEx; + $user = new phpbb_mock_user; $user->ip = ''; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); diff --git a/tests/regex/password_complexity_test.php b/tests/regex/password_complexity_test.php index 07453555ee..e2aefdaac8 100644 --- a/tests/regex/password_complexity_test.php +++ b/tests/regex/password_complexity_test.php @@ -7,6 +7,7 @@ * */ +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php'; class phpbb_password_complexity_test extends phpbb_test_case diff --git a/tests/text_processing/generate_text_for_display_test.php b/tests/text_processing/generate_text_for_display_test.php index a157fe7d9a..15905535ac 100644 --- a/tests/text_processing/generate_text_for_display_test.php +++ b/tests/text_processing/generate_text_for_display_test.php @@ -16,7 +16,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca { public function setUp() { - global $cache, $user; + global $cache, $user, $phpbb_dispatcher; parent::setUp(); @@ -24,6 +24,8 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca $user = new phpbb_mock_user; $user->optionset('viewcensors', false); + + $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); } public function test_empty_string() diff --git a/tests/user/lang_test.php b/tests/user/lang_test.php index c7c858c59d..9cb9e320b3 100644 --- a/tests/user/lang_test.php +++ b/tests/user/lang_test.php @@ -7,6 +7,8 @@ * */ +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; + class phpbb_user_lang_test extends phpbb_test_case { public function test_user_lang_sprintf()