From 82e61f501abfa2768d7faac1ccd8d688c84e5e13 Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 29 Dec 2019 01:51:15 +0700 Subject: [ticket/16276] Fix bbcode_firstpass undefined mode property PHPBB3-16276 --- phpBB/includes/message_parser.php | 3 +-- tests/bbcode/parser_test.php | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/message_parser.php b/phpBB/includes/message_parser.php index e1c28223dc..d6214c4614 100644 --- a/phpBB/includes/message_parser.php +++ b/phpBB/includes/message_parser.php @@ -46,6 +46,7 @@ class bbcode_firstpass extends bbcode var $message = ''; var $warn_msg = array(); var $parsed_items = array(); + var $mode; /** * Parse BBCode @@ -1128,8 +1129,6 @@ class parse_message extends bbcode_firstpass var $allow_quote_bbcode = true; var $allow_url_bbcode = true; - var $mode; - /** * The plupload object used for dealing with attachments * @var \phpbb\plupload\plupload diff --git a/tests/bbcode/parser_test.php b/tests/bbcode/parser_test.php index b569d371f1..6e1fad9ad1 100644 --- a/tests/bbcode/parser_test.php +++ b/tests/bbcode/parser_test.php @@ -255,6 +255,7 @@ class phpbb_bbcode_parser_test extends \phpbb_test_case $symfony_request = new \phpbb\symfony_request($request); $bbcode = new bbcode_firstpass(); + $bbcode->mode = 'post'; $bbcode->message = $message; $bbcode->bbcode_init(false); $bbcode->parse_bbcode(); -- cgit v1.2.1 From dcab0762210a4059cca7458344dcc1aeb0360c42 Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 29 Dec 2019 02:12:36 +0700 Subject: [ticket/16276] Further fix PHP nightly tests PHPBB3-16276 --- phpBB/includes/functions_module.php | 2 +- tests/console/cron/run_test.php | 4 ++++ tests/console/user/base.php | 3 ++- tests/content_visibility/delete_post_test.php | 2 +- tests/controller/common_helper_route.php | 2 +- tests/files/types_base_test.php | 2 ++ tests/functions/obtain_online_test.php | 1 + tests/functions/validate_username_test.php | 4 +++- tests/functions_user/delete_user_test.php | 23 +++++++++++++--------- .../functions_user/group_user_attributes_test.php | 1 + tests/log/delete_test.php | 2 +- tests/log/function_view_log_test.php | 2 ++ tests/migrator/get_callable_from_step_test.php | 3 ++- tests/migrator/schema_generator_test.php | 4 ++++ tests/passwords/drivers_test.php | 4 ++-- 15 files changed, 41 insertions(+), 18 deletions(-) diff --git a/phpBB/includes/functions_module.php b/phpBB/includes/functions_module.php index 510d98ec11..e90c11f884 100644 --- a/phpBB/includes/functions_module.php +++ b/phpBB/includes/functions_module.php @@ -445,7 +445,7 @@ class p_master break; default: - if (!preg_match('#(?:' . implode(array_keys($valid_tokens), ')|(?:') . ')#', $token)) + if (!preg_match('#(?:' . implode(')|(?:', array_keys($valid_tokens)) . ')#', $token)) { $token = ''; } diff --git a/tests/console/cron/run_test.php b/tests/console/cron/run_test.php index 2744bf132c..8402f9dd3e 100644 --- a/tests/console/cron/run_test.php +++ b/tests/console/cron/run_test.php @@ -122,6 +122,8 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case public function test_no_task() { + global $phpbb_root_path, $phpEx; + $tasks = array( ); @@ -163,6 +165,8 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case public function test_no_task_verbose() { + global $phpbb_root_path, $phpEx; + $tasks = array( ); diff --git a/tests/console/user/base.php b/tests/console/user/base.php index b845ab1639..74f04cf686 100644 --- a/tests/console/user/base.php +++ b/tests/console/user/base.php @@ -112,7 +112,8 @@ abstract class phpbb_console_user_base extends phpbb_database_test_case $row = $this->db->sql_fetchrow($result); $this->db->sql_freeresult($result); - return $row['user_id']; + $user_id = $row ? $row['user_id'] : null; + return $user_id; } public function getInputStream($input) diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index 4f978219c2..1c1796a1fc 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -287,7 +287,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case */ public function test_delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason, $expected_posts, $expected_topic, $expected_forum, $expected_user) { - global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx; + global $auth, $cache, $config, $db, $user, $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx; $config = new \phpbb\config\config(array( 'num_posts' => 3, diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index 447c10d10e..bdaf8ee682 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -74,7 +74,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case protected function generate_route_objects() { - global $request; + global $request, $phpbb_root_path, $phpEx; $this->request = new phpbb_mock_request(); $this->request->overwrite('SCRIPT_NAME', $this->get_uri(), \phpbb\request\request_interface::SERVER); diff --git a/tests/files/types_base_test.php b/tests/files/types_base_test.php index a5533f2bc0..28c5a12c3d 100644 --- a/tests/files/types_base_test.php +++ b/tests/files/types_base_test.php @@ -79,6 +79,7 @@ class phpbb_files_types_base_test extends phpbb_test_case $php_ini->expects($this->any()) ->method('getString') ->willReturn($max_filesize); + $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $php_ini, $this->request); $type_form = new \phpbb\files\types\local($this->factory, $this->language, $php_ini, $this->request); $file = $this->getMockBuilder('\phpbb\files\filespec') ->disableOriginalConstructor() @@ -86,6 +87,7 @@ class phpbb_files_types_base_test extends phpbb_test_case $file->expects($this->any()) ->method('get') ->willReturn($filename); + $type_form->set_upload($upload); $type_form->check_upload_size($file); $this->assertSame($expected, $file->error); diff --git a/tests/functions/obtain_online_test.php b/tests/functions/obtain_online_test.php index f740decab8..e6929b1549 100644 --- a/tests/functions/obtain_online_test.php +++ b/tests/functions/obtain_online_test.php @@ -161,6 +161,7 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case global $config, $user, $auth, $phpbb_dispatcher; $config['load_online_guests'] = $display_guests; $user = new phpbb_mock_lang(); + $user->data['user_id'] = 100; $user->lang = $this->load_language(); $auth = $this->createMock('\phpbb\auth\auth'); $acl_get_map = array( diff --git a/tests/functions/validate_username_test.php b/tests/functions/validate_username_test.php index 3a4b63b5e8..31837f015b 100644 --- a/tests/functions/validate_username_test.php +++ b/tests/functions/validate_username_test.php @@ -130,11 +130,13 @@ class phpbb_functions_validate_data_test extends phpbb_database_test_case */ public function test_validate_username($allow_name_chars, $expected) { - global $cache, $config, $db; + global $cache, $config, $db, $user; $db = $this->db; $cache = $this->cache; $cache->put('_disallowed_usernames', array('barfoo')); + $user = new phpbb_mock_user(); + $user->data['username_clean'] = 'username'; $config['allow_name_chars'] = $allow_name_chars; diff --git a/tests/functions_user/delete_user_test.php b/tests/functions_user/delete_user_test.php index c112a0c368..4a82a0eeb7 100644 --- a/tests/functions_user/delete_user_test.php +++ b/tests/functions_user/delete_user_test.php @@ -23,9 +23,14 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case { parent::setUp(); - global $cache, $config, $db, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path; + global $cache, $config, $db, $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpEx; $db = $this->db = $this->new_dbal(); + + $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); + $lang = new \phpbb\language\language($lang_loader); + $user = new \phpbb\user($lang, '\phpbb\datetime'); + $config = new \phpbb\config\config(array( 'load_online_time' => 5, 'search_type' => '\phpbb\search\fulltext_mysql', @@ -59,16 +64,16 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case array( 'retain', false, array( - array('post_id' => 1, 'poster_id' => ANONYMOUS, 'post_username' => ''), + array('post_id' => 1, 'poster_id' => ANONYMOUS, 'post_username' => 'Guest'), array('post_id' => 2, 'poster_id' => ANONYMOUS, 'post_username' => 'Other'), - array('post_id' => 3, 'poster_id' => ANONYMOUS, 'post_username' => ''), + array('post_id' => 3, 'poster_id' => ANONYMOUS, 'post_username' => 'Guest'), array('post_id' => 4, 'poster_id' => ANONYMOUS, 'post_username' => 'Other'), ), array( array( 'topic_id' => 1, - 'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => '', 'topic_first_poster_colour' => '', - 'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => '', 'topic_last_poster_colour' => '', + 'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => 'Guest', 'topic_first_poster_colour' => '', + 'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => 'Guest', 'topic_last_poster_colour' => '', ), array( 'topic_id' => 2, @@ -77,8 +82,8 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case ), array( 'topic_id' => 3, - 'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => '', 'topic_first_poster_colour' => '', - 'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => '', 'topic_last_poster_colour' => '', + 'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => 'Guest', 'topic_first_poster_colour' => '', + 'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => 'Guest', 'topic_last_poster_colour' => '', ), array( 'topic_id' => 4, @@ -87,9 +92,9 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case ), ), array( - array('forum_id' => 1, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => '', 'forum_last_poster_colour' => ''), + array('forum_id' => 1, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Guest', 'forum_last_poster_colour' => ''), array('forum_id' => 2, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Other', 'forum_last_poster_colour' => ''), - array('forum_id' => 3, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => '', 'forum_last_poster_colour' => ''), + array('forum_id' => 3, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Guest', 'forum_last_poster_colour' => ''), array('forum_id' => 4, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Other', 'forum_last_poster_colour' => ''), ), ), diff --git a/tests/functions_user/group_user_attributes_test.php b/tests/functions_user/group_user_attributes_test.php index 6968b1cd3a..dd86d23b34 100644 --- a/tests/functions_user/group_user_attributes_test.php +++ b/tests/functions_user/group_user_attributes_test.php @@ -131,6 +131,7 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes $user = new phpbb_mock_user; $user->ip = ''; + $user->data['user_id'] = $user_id; $cache = new phpbb_mock_cache; $db = $this->new_dbal(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); diff --git a/tests/log/delete_test.php b/tests/log/delete_test.php index 503e2c2fca..fd8a2cb3df 100644 --- a/tests/log/delete_test.php +++ b/tests/log/delete_test.php @@ -22,7 +22,7 @@ class phpbb_log_delete_test extends phpbb_database_test_case protected function setUp(): void { - global $phpbb_root_path, $phpEx, $db, $phpbb_dispatcher, $auth; + global $phpbb_root_path, $phpEx, $db, $phpbb_dispatcher, $auth, $user; $db = $this->new_dbal(); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php index c26644088e..edab371769 100644 --- a/tests/log/function_view_log_test.php +++ b/tests/log/function_view_log_test.php @@ -411,6 +411,8 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case 2 => 'plural (%d)', ), ); + $user->session_id = false; + $user->data['user_id'] = 10; $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); diff --git a/tests/migrator/get_callable_from_step_test.php b/tests/migrator/get_callable_from_step_test.php index f08caf3181..b0abb6199c 100644 --- a/tests/migrator/get_callable_from_step_test.php +++ b/tests/migrator/get_callable_from_step_test.php @@ -15,7 +15,7 @@ class get_callable_from_step_test extends phpbb_database_test_case { public function setUp(): void { - global $phpbb_root_path, $php_ext, $table_prefix, $phpbb_log; + global $phpbb_root_path, $php_ext, $table_prefix, $phpbb_log, $user; parent::setUp(); @@ -24,6 +24,7 @@ class get_callable_from_step_test extends phpbb_database_test_case $factory = new \phpbb\db\tools\factory(); $cache_service = $this->getMockBuilder('\phpbb\cache\service')->disableOriginalConstructor()->getMock(); $user = $this->getMockBuilder('\phpbb\user')->disableOriginalConstructor()->getMock(); + $user->ip = '127.0.0.1'; $module_manager = new \phpbb\module\module_manager( $this->getMockBuilder('\phpbb\cache\driver\dummy')->disableOriginalConstructor()->getMock(), $db, diff --git a/tests/migrator/schema_generator_test.php b/tests/migrator/schema_generator_test.php index 88257430a7..1349b98953 100644 --- a/tests/migrator/schema_generator_test.php +++ b/tests/migrator/schema_generator_test.php @@ -26,6 +26,8 @@ class schema_generator_test extends phpbb_test_case public function setUp(): void { + global $phpbb_root_path, $phpEx; + parent::setUp(); $this->config = new \phpbb\config\config(array()); @@ -33,6 +35,8 @@ class schema_generator_test extends phpbb_test_case $factory = new \phpbb\db\tools\factory(); $this->db_tools = $factory->get($this->db); $this->table_prefix = 'phpbb_'; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $phpEx; } protected function get_schema_generator(array $class_names) diff --git a/tests/passwords/drivers_test.php b/tests/passwords/drivers_test.php index 8300431dfe..8c1fdf49c2 100644 --- a/tests/passwords/drivers_test.php +++ b/tests/passwords/drivers_test.php @@ -44,8 +44,8 @@ class phpbb_passwords_helper_test extends \phpbb_test_case public function data_helper_encode64() { return array( - array('foobar', 6, 'axqPW3aQ'), - array('foobar', 7, 'axqPW3aQ..'), + array('foobars', 6, 'axqPW3aQ'), + array('foobarss', 7, 'axqPW3aQn/'), array('foobar', 5, 'axqPW34'), ); } -- cgit v1.2.1