diff options
author | Marc Alexander <admin@m-a-styles.de> | 2019-12-29 15:11:29 +0100 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2019-12-29 15:11:29 +0100 |
commit | 9ea5cfd14b6e471f16745308d67b114699b9bda7 (patch) | |
tree | 925f6bd930f19b1bd8d689691000a720316c85c3 /tests | |
parent | Merge pull request #5797 from marc1706/ticket/16271 (diff) | |
parent | Merge pull request #5796 from rxu/ticket/16276 (diff) | |
download | phpbb-9ea5cfd14b6e471f16745308d67b114699b9bda7.tar.gz phpbb-9ea5cfd14b6e471f16745308d67b114699b9bda7.tar.bz2 phpbb-9ea5cfd14b6e471f16745308d67b114699b9bda7.zip |
Merge branch '3.3.x'
Diffstat (limited to 'tests')
-rw-r--r-- | tests/bbcode/parser_test.php | 1 | ||||
-rw-r--r-- | tests/console/cron/run_test.php | 4 | ||||
-rw-r--r-- | tests/console/user/base.php | 3 | ||||
-rw-r--r-- | tests/content_visibility/delete_post_test.php | 2 | ||||
-rw-r--r-- | tests/controller/common_helper_route.php | 2 | ||||
-rw-r--r-- | tests/files/types_base_test.php | 2 | ||||
-rw-r--r-- | tests/functions/obtain_online_test.php | 1 | ||||
-rw-r--r-- | tests/functions/validate_username_test.php | 4 | ||||
-rw-r--r-- | tests/functions_user/delete_user_test.php | 23 | ||||
-rw-r--r-- | tests/functions_user/group_user_attributes_test.php | 1 | ||||
-rw-r--r-- | tests/log/delete_test.php | 2 | ||||
-rw-r--r-- | tests/log/function_view_log_test.php | 2 | ||||
-rw-r--r-- | tests/migrator/get_callable_from_step_test.php | 3 | ||||
-rw-r--r-- | tests/migrator/schema_generator_test.php | 4 | ||||
-rw-r--r-- | tests/passwords/drivers_test.php | 4 |
15 files changed, 41 insertions, 17 deletions
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(); diff --git a/tests/console/cron/run_test.php b/tests/console/cron/run_test.php index fce913dde4..16b2548d09 100644 --- a/tests/console/cron/run_test.php +++ b/tests/console/cron/run_test.php @@ -121,6 +121,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( ); @@ -161,6 +163,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 2007aad194..35a8eedb80 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 84936d1401..4575adbfc3 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 6af722c69f..aee21e33bd 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', @@ -62,16 +67,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, @@ -80,8 +85,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, @@ -90,9 +95,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'), ); } |