1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-07 17:27:16 +02:00

[ticket/17535] Convert config files, make data providers static

PHPBB-17535
This commit is contained in:
rxu
2025-07-16 17:36:45 +07:00
parent d7db296eab
commit 8a99024087
199 changed files with 879 additions and 852 deletions

View File

@@ -15,13 +15,16 @@ class phpbb_build_url_test extends phpbb_test_case
{
protected function setUp(): void
{
global $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpbb_path_helper;
global $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpbb_path_helper, $config;
parent::setUp();
$phpbb_container = new phpbb_mock_container_builder();
$user = new phpbb_mock_user();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$config = new \phpbb\config\config([
'enable_mod_rewrite' => 0,
]);
$phpbb_path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
@@ -33,7 +36,7 @@ class phpbb_build_url_test extends phpbb_test_case
);
$phpbb_container->set('path_helper', $phpbb_path_helper);
}
public function build_url_test_data()
public static function build_url_test_data()
{
return array(
array(
@@ -79,8 +82,9 @@ class phpbb_build_url_test extends phpbb_test_case
*/
public function test_build_url($page, $strip_vars, $expected)
{
global $user;
global $config, $user, $phpbb_path_helper, $phpbb_dispatcher, $_SID;
$_SID = '';
$user->page['page'] = $page;
$output = build_url($strip_vars);

View File

@@ -13,7 +13,7 @@
class phpbb_convert_30_dbms_to_31_test extends phpbb_test_case
{
public function convert_30_dbms_to_31_data()
public static function convert_30_dbms_to_31_data()
{
return array(
array('mssql_odbc'),

View File

@@ -29,7 +29,7 @@ class phpbb_generate_string_list_test extends phpbb_test_case
$this->user->add_lang('common');
}
public function generate_string_list_data()
public static function generate_string_list_data()
{
return array(
array(

View File

@@ -13,7 +13,7 @@
class phpbb_get_formatted_filesize_test extends phpbb_test_case
{
public function get_formatted_filesize_test_data()
public static function get_formatted_filesize_test_data()
{
return array(
// exact powers of 2

View File

@@ -13,7 +13,7 @@
class phpbb_functions_get_preg_expression_test extends phpbb_test_case
{
public function data_path_remove_dot_trailing_slash()
public static function data_path_remove_dot_trailing_slash()
{
return array(
array('./../', '$2', '/..'),

View File

@@ -17,7 +17,11 @@ class phpbb_functions_make_clickable_email_test extends phpbb_test_case
{
parent::setUp();
global $user, $request, $symfony_request;
global $user, $request, $symfony_request, $config;
$config = new \phpbb\config\config([
'force_server_vars' => 0,
'server_name' => 'testhost',
]);
$user = new phpbb_mock_user();
$request = new phpbb_mock_request();
$symfony_request = new \phpbb\symfony_request($request);
@@ -26,7 +30,7 @@ class phpbb_functions_make_clickable_email_test extends phpbb_test_case
/**
* 'e' tag for email addresses html
**/
public function data_test_make_clickable_email_positive()
public static function data_test_make_clickable_email_positive()
{
return array(
array(
@@ -147,7 +151,7 @@ class phpbb_functions_make_clickable_email_test extends phpbb_test_case
);
}
public function data_test_make_clickable_email_negative()
public static function data_test_make_clickable_email_negative()
{
return array(
array('foo.example.com'), // @ is missing
@@ -206,6 +210,7 @@ class phpbb_functions_make_clickable_email_test extends phpbb_test_case
*/
public function test_email_matching_positive($email, $expected)
{
global $config, $user, $request, $symfony_request;
$this->assertSame($expected, make_clickable($email));
}
@@ -214,6 +219,7 @@ class phpbb_functions_make_clickable_email_test extends phpbb_test_case
*/
public function test_email_matching_negative($email, $expected = null)
{
global $config, $user, $request, $symfony_request;
$expected = ($expected) ?: $email;
$this->assertSame($expected, make_clickable($email));
}

View File

@@ -25,7 +25,7 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case
* "postlink" for the rest of URLs
* empty for email addresses
**/
public function data_test_make_clickable_url_positive()
public static function data_test_make_clickable_url_positive()
{
return [
[
@@ -82,7 +82,7 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case
];
}
public function data_test_make_clickable_url_idn()
public static function data_test_make_clickable_url_idn()
{
return [
[
@@ -135,7 +135,7 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case
];
}
public function data_test_make_clickable_local_url_idn()
public static function data_test_make_clickable_local_url_idn()
{
return [
[
@@ -154,7 +154,7 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case
];
}
public function data_test_make_clickable_custom_classes()
public static function data_test_make_clickable_custom_classes()
{
return [
[
@@ -200,7 +200,11 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case
{
parent::setUp();
global $user, $request, $symfony_request;
global $user, $request, $symfony_request, $config;
$config = new \phpbb\config\config([
'force_server_vars' => 0,
'server_name' => 'testhost',
]);
$user = new phpbb_mock_user();
$request = new phpbb_mock_request();
$symfony_request = new \phpbb\symfony_request($request);
@@ -212,6 +216,7 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case
*/
public function test_urls_matching_positive($url, $expected)
{
global $user, $request, $symfony_request, $config;
$this->assertSame($expected, make_clickable($url));
}
@@ -220,6 +225,7 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case
*/
public function test_local_urls_matching_idn($url, $expected)
{
global $user, $request, $symfony_request, $config;
$this->assertSame($expected, make_clickable($url, "http://www.домен.рф"));
}
@@ -228,6 +234,7 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case
*/
public function test_make_clickable_custom_classes($url, $server_url, $class, $expected)
{
global $user, $request, $symfony_request, $config;
$this->assertSame($expected, make_clickable($url, $server_url, $class));
}
}

View File

@@ -33,7 +33,7 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case
);
}
static public function obtain_guest_count_data()
public static function obtain_guest_count_data()
{
return array(
array(0, 2),
@@ -53,7 +53,7 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case
$this->assertEquals($expected, obtain_guest_count($forum_id));
}
static public function obtain_users_online_data()
public static function obtain_users_online_data()
{
return array(
array(0, false, array(
@@ -123,7 +123,7 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case
$this->assertEquals($expected, obtain_users_online($forum_id));
}
static public function obtain_users_online_string_data()
public static function obtain_users_online_string_data()
{
return array(
array(0, false, array(

View File

@@ -13,7 +13,7 @@
class phpbb_functions_parse_cfg_file_test extends phpbb_test_case
{
public function parse_cfg_file_data()
public static function parse_cfg_file_data()
{
return array(
array(

View File

@@ -61,7 +61,7 @@ class phpbb_get_banned_user_ids_test extends phpbb_database_test_case
$phpbb_container->set('ban.manager', $ban_manager);
}
public function phpbb_get_banned_user_ids_data()
public static function phpbb_get_banned_user_ids_data()
{
return array(
// Input to phpbb_get_banned_user_ids (user_id list, ban_end)

View File

@@ -13,7 +13,7 @@
class phpbb_get_install_redirect_test extends phpbb_test_case
{
public function data_redirect(): array
public static function data_redirect(): array
{
return [
[

View File

@@ -13,7 +13,7 @@
class phpbb_quoteattr_test extends phpbb_test_case
{
public function quoteattr_test_data()
public static function quoteattr_test_data()
{
return array(
array('foo', null, '"foo"'),

View File

@@ -13,7 +13,7 @@
class short_ipv6__test extends phpbb_test_case
{
public function data_short_ipv6(): array
public static function data_short_ipv6(): array
{
return [
['::1', 0, ''],

View File

@@ -18,7 +18,7 @@ class phpbb_functions_style_select_test extends phpbb_database_test_case
return $this->createXMLDataSet(__DIR__.'/fixtures/style_select.xml');
}
static public function style_select_data()
public static function style_select_data()
{
return [
[

View File

@@ -15,7 +15,7 @@ require_once __DIR__ . '/../../phpBB/includes/functions_user.php';
class phpbb_functions_validate_hex_colour_test extends phpbb_test_case
{
public function positive_match_data()
public static function positive_match_data()
{
return array(
array('a00'),
@@ -27,7 +27,7 @@ class phpbb_functions_validate_hex_colour_test extends phpbb_test_case
);
}
public function negative_match_data()
public static function negative_match_data()
{
return array(
// Invalid prefix
@@ -53,7 +53,7 @@ class phpbb_functions_validate_hex_colour_test extends phpbb_test_case
);
}
public function optional_only_data()
public static function optional_only_data()
{
return array(
// The empty colour, i.e. "no colour".
@@ -61,19 +61,19 @@ class phpbb_functions_validate_hex_colour_test extends phpbb_test_case
);
}
public function strict_negative_match_data()
public static function strict_negative_match_data()
{
return array_merge(
$this->negative_match_data(),
$this->optional_only_data()
self::negative_match_data(),
self::optional_only_data()
);
}
public function nonstrict_positive_match_data()
public static function nonstrict_positive_match_data()
{
return array_merge(
$this->positive_match_data(),
$this->optional_only_data()
self::positive_match_data(),
self::optional_only_data()
);
}

View File

@@ -25,7 +25,7 @@ class phpbb_functions_validate_password_test extends phpbb_test_case
$this->helper = new phpbb_functions_validate_data_helper($this);
}
public function validate_password_data()
public static function validate_password_data()
{
return array(
array('PASS_TYPE_ANY', array(

View File

@@ -28,12 +28,14 @@ class phpbb_functions_validate_user_email_test extends phpbb_database_test_case
protected function setUp(): void
{
global $cache, $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx;
global $cache, $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx, $config;
parent::setUp();
$phpbb_container = new phpbb_mock_container_builder();
$config = new \phpbb\config\config([]);
$config = new \phpbb\config\config([
'allow_emailreuse' => 0,
]);
$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));
@@ -99,6 +101,8 @@ class phpbb_functions_validate_user_email_test extends phpbb_database_test_case
*/
public function test_validate_user_email($case, $errors, $email)
{
global $config, $db, $user;
$this->set_validation_prerequisites(false);
$this->helper->assert_valid_data(array(
@@ -124,6 +128,8 @@ class phpbb_functions_validate_user_email_test extends phpbb_database_test_case
*/
public function test_validate_user_email_mx($case, $errors, $email)
{
global $config, $db, $user;
$this->set_validation_prerequisites(true);
$this->helper->assert_valid_data(array(

View File

@@ -35,7 +35,7 @@ class phpbb_functions_validate_username_test extends phpbb_database_test_case
$this->helper = new phpbb_functions_validate_data_helper($this);
}
public function validate_username_data()
public static function validate_username_data()
{
return array(
array('USERNAME_CHARS_ANY', array(