From 58ea656fd8ec782ef9c765a2ddc7ed8348f9730e Mon Sep 17 00:00:00 2001 From: rxu Date: Mon, 13 Jul 2020 13:45:12 +0700 Subject: [PATCH 01/17] [ticket/16549] Move from assert[Not]Contains to assertString[Not]ContainsString PHPBB3-16549 --- tests/console/config/config_test.php | 12 +++--- tests/console/cron/cron_list_test.php | 6 +-- tests/console/cron/run_test.php | 10 ++--- tests/console/update/check_test.php | 10 ++--- tests/console/user/activate_test.php | 2 +- tests/console/user/add_test.php | 10 ++--- tests/console/user/delete_test.php | 4 +- tests/email/email_parsing_test.php | 16 +++---- tests/event/exception_listener_test.php | 2 +- tests/functional/acp_bbcodes_test.php | 8 ++-- tests/functional/acp_groups_test.php | 2 +- tests/functional/acp_permissions_test.php | 10 ++--- tests/functional/acp_users_test.php | 4 +- tests/functional/auth_test.php | 10 ++--- tests/functional/common_avatar_test_case.php | 2 +- tests/functional/common_groups_test_case.php | 12 +++--- tests/functional/download_test.php | 8 ++-- tests/functional/extension_acp_test.php | 30 ++++++------- .../functional/extension_controller_test.php | 16 +++---- .../functional/extension_global_lang_test.php | 4 +- tests/functional/extension_module_test.php | 6 +-- .../extension_permission_lang_test.php | 4 +- tests/functional/feed_test.php | 30 ++++++------- tests/functional/fileupload_form_test.php | 2 +- tests/functional/forgot_password_test.php | 2 +- tests/functional/forum_style_test.php | 23 +++++++--- tests/functional/jumpbox_test.php | 2 +- tests/functional/mcp_test.php | 6 +-- tests/functional/memberlist_test.php | 42 +++++++++---------- tests/functional/metadata_manager_test.php | 18 ++++---- tests/functional/notification_test.php | 2 +- tests/functional/paging_test.php | 12 +++--- tests/functional/plupload_test.php | 2 +- tests/functional/posting_test.php | 24 +++++------ tests/functional/private_messages_test.php | 10 ++--- tests/functional/prune_shadow_topic_test.php | 4 +- tests/functional/report_post_captcha_test.php | 8 ++-- tests/functional/subforum_test.php | 8 ++-- tests/functional/ucp_groups_test.php | 2 +- tests/functional/user_password_reset_test.php | 10 ++--- tests/functional/viewforum_paging_test.php | 8 ++-- .../functional/visibility_disapprove_test.php | 22 +++++----- .../functional/visibility_reapprove_test.php | 34 +++++++-------- .../functional/visibility_softdelete_test.php | 34 +++++++-------- .../visibility_unapproved_posts_test.php | 42 +++++++++---------- tests/functional/visit_installer_test.php | 6 +-- tests/functions/get_remote_file_test.php | 4 +- tests/network/ftp_fsock_pasv_epsv_test.php | 2 +- .../phpbb_functional_test_case.php | 24 +++++------ 49 files changed, 291 insertions(+), 280 deletions(-) diff --git a/tests/console/config/config_test.php b/tests/console/config/config_test.php index 65bfad4757..653ce89bed 100644 --- a/tests/console/config/config_test.php +++ b/tests/console/config/config_test.php @@ -162,7 +162,7 @@ class phpbb_console_command_config_test extends phpbb_test_case '--no-newline' => false, )); - $this->assertContains('CLI_CONFIG_NOT_EXISTS', $command_tester->getDisplay()); + $this->assertStringContainsString('CLI_CONFIG_NOT_EXISTS', $command_tester->getDisplay()); } public function test_increment_dynamic() @@ -178,7 +178,7 @@ class phpbb_console_command_config_test extends phpbb_test_case '--dynamic' => true, )); - $this->assertContains('CLI_CONFIG_INCREMENT_SUCCESS', $command_tester->getDisplay()); + $this->assertStringContainsString('CLI_CONFIG_INCREMENT_SUCCESS', $command_tester->getDisplay()); $this->assertSame(2, $this->config['test_key']); } @@ -195,7 +195,7 @@ class phpbb_console_command_config_test extends phpbb_test_case '--dynamic' => false, )); - $this->assertContains('CLI_CONFIG_INCREMENT_SUCCESS', $command_tester->getDisplay()); + $this->assertStringContainsString('CLI_CONFIG_INCREMENT_SUCCESS', $command_tester->getDisplay()); $this->assertSame(2, $this->config['test_key']); } @@ -211,7 +211,7 @@ class phpbb_console_command_config_test extends phpbb_test_case '--dynamic' => true, )); - $this->assertContains('CLI_CONFIG_INCREMENT_SUCCESS', $command_tester->getDisplay()); + $this->assertStringContainsString('CLI_CONFIG_INCREMENT_SUCCESS', $command_tester->getDisplay()); $this->assertSame(2, $this->config['test_key']); } @@ -226,7 +226,7 @@ class phpbb_console_command_config_test extends phpbb_test_case 'key' => 'test_key', )); - $this->assertContains('CLI_CONFIG_DELETE_SUCCESS', $command_tester->getDisplay()); + $this->assertStringContainsString('CLI_CONFIG_DELETE_SUCCESS', $command_tester->getDisplay()); $this->assertEmpty($this->config); } @@ -240,7 +240,7 @@ class phpbb_console_command_config_test extends phpbb_test_case 'key' => 'wrong_key', )); - $this->assertContains('CLI_CONFIG_NOT_EXISTS', $command_tester->getDisplay()); + $this->assertStringContainsString('CLI_CONFIG_NOT_EXISTS', $command_tester->getDisplay()); $this->assertEmpty($this->config); } diff --git a/tests/console/cron/cron_list_test.php b/tests/console/cron/cron_list_test.php index 9347f5cedd..8c84d69e25 100644 --- a/tests/console/cron/cron_list_test.php +++ b/tests/console/cron/cron_list_test.php @@ -44,19 +44,19 @@ class phpbb_console_command_cron_list_test extends phpbb_test_case public function test_no_task() { $this->initiate_test(0, 0); - $this->assertContains('CRON_NO_TASKS', $this->command_tester->getDisplay()); + $this->assertStringContainsString('CRON_NO_TASKS', $this->command_tester->getDisplay()); } public function test_only_ready() { $this->initiate_test(2, 0); - $this->assertContains('TASKS_READY command1 command2', preg_replace('/[\s*=]+/', ' ', trim($this->command_tester->getDisplay()))); + $this->assertStringContainsString('TASKS_READY command1 command2', preg_replace('/[\s*=]+/', ' ', trim($this->command_tester->getDisplay()))); } public function test_only_not_ready() { $this->initiate_test(0, 2); - $this->assertContains('TASKS_NOT_READY command1 command2', preg_replace('/[\s*=]+/', ' ', trim($this->command_tester->getDisplay()))); + $this->assertStringContainsString('TASKS_NOT_READY command1 command2', preg_replace('/[\s*=]+/', ' ', trim($this->command_tester->getDisplay()))); } public function test_both_ready() diff --git a/tests/console/cron/run_test.php b/tests/console/cron/run_test.php index af01c5242e..999e0df4be 100644 --- a/tests/console/cron/run_test.php +++ b/tests/console/cron/run_test.php @@ -103,7 +103,7 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case $command_tester = $this->get_command_tester(); $exit_status = $command_tester->execute(array('command' => $this->command_name, '--verbose' => true)); - $this->assertContains('RUNNING_TASK', $command_tester->getDisplay()); + $this->assertStringContainsString('RUNNING_TASK', $command_tester->getDisplay()); $this->assertSame(true, $this->task->executed); $this->assertSame(0, $exit_status); $this->assertSame(false, $this->lock->owns_lock()); @@ -119,7 +119,7 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case $command_tester = $this->get_command_tester(); $exit_status = $command_tester->execute(array('command' => $this->command_name)); - $this->assertContains('CRON_LOCK_ERROR', $command_tester->getDisplay()); + $this->assertStringContainsString('CRON_LOCK_ERROR', $command_tester->getDisplay()); $this->assertSame(false, $this->task->executed); $this->assertSame(1, $exit_status); } @@ -215,7 +215,7 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case $command_tester = $this->get_command_tester(); $exit_status = $command_tester->execute(array('command' => $this->command_name, '--verbose' => true)); - $this->assertContains('CRON_NO_TASK', $command_tester->getDisplay()); + $this->assertStringContainsString('CRON_NO_TASK', $command_tester->getDisplay()); $this->assertSame(0, $exit_status); $this->assertSame(false, $this->lock->owns_lock()); } @@ -240,7 +240,7 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case $command_tester = $this->get_command_tester(); $exit_status = $command_tester->execute(array('command' => $this->command_name, 'name' => 'foo')); - $this->assertContains('CRON_NO_SUCH_TASK', $command_tester->getDisplay()); + $this->assertStringContainsString('CRON_NO_SUCH_TASK', $command_tester->getDisplay()); $this->assertSame(false, $this->task->executed); $this->assertSame(2, $exit_status); $this->assertSame(false, $this->lock->owns_lock()); @@ -251,7 +251,7 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case $command_tester = $this->get_command_tester(); $exit_status = $command_tester->execute(array('command' => $this->command_name, 'name' => 'phpbb_cron_task_simple', '--verbose' => true)); - $this->assertContains('RUNNING_TASK', $command_tester->getDisplay()); + $this->assertStringContainsString('RUNNING_TASK', $command_tester->getDisplay()); $this->assertSame(true, $this->task->executed); $this->assertSame(0, $exit_status); $this->assertSame(false, $this->lock->owns_lock()); diff --git a/tests/console/update/check_test.php b/tests/console/update/check_test.php index 6812ea61b8..7a23318cf6 100644 --- a/tests/console/update/check_test.php +++ b/tests/console/update/check_test.php @@ -43,7 +43,7 @@ class phpbb_console_command_check_test extends phpbb_test_case { $command_tester = $this->get_command_tester('100000'); $status = $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true, '--verbose' => true)); - $this->assertContains($this->language->lang('UPDATE_NOT_NEEDED'), $command_tester->getDisplay()); + $this->assertStringContainsString($this->language->lang('UPDATE_NOT_NEEDED'), $command_tester->getDisplay()); $this->assertSame($status, 0); } @@ -52,7 +52,7 @@ class phpbb_console_command_check_test extends phpbb_test_case { $command_tester = $this->get_command_tester('0'); $status = $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true)); - $this->assertContains($this->language->lang('UPDATE_NEEDED'), $command_tester->getDisplay()); + $this->assertStringContainsString($this->language->lang('UPDATE_NEEDED'), $command_tester->getDisplay()); $this->assertSame($status, 1); } @@ -60,8 +60,8 @@ class phpbb_console_command_check_test extends phpbb_test_case { $command_tester = $this->get_command_tester('0'); $status = $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true, '--verbose' => true)); - $this->assertContains($this->language->lang('UPDATE_NEEDED'), $command_tester->getDisplay()); - $this->assertContains($this->language->lang('UPDATES_AVAILABLE'), $command_tester->getDisplay()); + $this->assertStringContainsString($this->language->lang('UPDATE_NEEDED'), $command_tester->getDisplay()); + $this->assertStringContainsString($this->language->lang('UPDATES_AVAILABLE'), $command_tester->getDisplay()); $this->assertSame($status, 1); } @@ -74,7 +74,7 @@ class phpbb_console_command_check_test extends phpbb_test_case $this->version_helper->set_file_location('acme.corp','foo', 'bar.json'); $status = $command_tester->execute(array('command' => $this->command_name, '--no-ansi' => true)); - $this->assertContains('VERSIONCHECK_FAIL', $command_tester->getDisplay()); + $this->assertStringContainsString('VERSIONCHECK_FAIL', $command_tester->getDisplay()); $this->assertSame($status, 2); } diff --git a/tests/console/user/activate_test.php b/tests/console/user/activate_test.php index 51e9754b59..e461879723 100644 --- a/tests/console/user/activate_test.php +++ b/tests/console/user/activate_test.php @@ -81,6 +81,6 @@ class phpbb_console_user_activate_test extends phpbb_console_user_base '--deactivate' => $deactivate, )); - $this->assertContains($expected, $command_tester->getDisplay()); + $this->assertStringContainsString($expected, $command_tester->getDisplay()); } } diff --git a/tests/console/user/add_test.php b/tests/console/user/add_test.php index cc86cb27d3..126771c7c6 100644 --- a/tests/console/user/add_test.php +++ b/tests/console/user/add_test.php @@ -93,7 +93,7 @@ class phpbb_console_user_add_test extends phpbb_console_user_base )); $this->assertNotEquals(null, $this->get_user_id('foo')); - $this->assertContains('CLI_USER_ADD_SUCCESS', $command_tester->getDisplay()); + $this->assertStringContainsString('CLI_USER_ADD_SUCCESS', $command_tester->getDisplay()); } public function test_add_dialog() @@ -113,7 +113,7 @@ class phpbb_console_user_add_test extends phpbb_console_user_base )); $this->assertNotEquals(null, $this->get_user_id('bar')); - $this->assertContains('CLI_USER_ADD_SUCCESS', $command_tester->getDisplay()); + $this->assertStringContainsString('CLI_USER_ADD_SUCCESS', $command_tester->getDisplay()); } @@ -130,8 +130,8 @@ class phpbb_console_user_add_test extends phpbb_console_user_base '--email' => 'foo' )); - $this->assertContains('USERNAME_TAKEN', $command_tester->getDisplay()); - $this->assertContains('TOO_SHORT', $command_tester->getDisplay()); - $this->assertContains('EMAIL_INVALID', $command_tester->getDisplay()); + $this->assertStringContainsString('USERNAME_TAKEN', $command_tester->getDisplay()); + $this->assertStringContainsString('TOO_SHORT', $command_tester->getDisplay()); + $this->assertStringContainsString('EMAIL_INVALID', $command_tester->getDisplay()); } } diff --git a/tests/console/user/delete_test.php b/tests/console/user/delete_test.php index 926e496e1e..999203b965 100644 --- a/tests/console/user/delete_test.php +++ b/tests/console/user/delete_test.php @@ -54,7 +54,7 @@ class phpbb_console_user_delete_test extends phpbb_console_user_base )); $this->assertNull($this->get_user_id('Test')); - $this->assertContains('USER_DELETED', $command_tester->getDisplay()); + $this->assertStringContainsString('USER_DELETED', $command_tester->getDisplay()); } public function test_delete_non_user() @@ -71,7 +71,7 @@ class phpbb_console_user_delete_test extends phpbb_console_user_base '--delete-posts' => false, )); - $this->assertContains('NO_USER', $command_tester->getDisplay()); + $this->assertStringContainsString('NO_USER', $command_tester->getDisplay()); } public function test_delete_cancel() diff --git a/tests/email/email_parsing_test.php b/tests/email/email_parsing_test.php index 629df9abb6..fdb8eaa7ff 100644 --- a/tests/email/email_parsing_test.php +++ b/tests/email/email_parsing_test.php @@ -138,13 +138,13 @@ class phpbb_email_parsing_test extends phpbb_test_case $reflection_template = $this->reflection_template_property->getValue($this->messenger); $msg = trim($reflection_template->assign_display('body')); - $this->assertContains($author_name, $msg); - $this->assertContains($forum_name, $msg); - $this->assertContains($topic_title, $msg); - $this->assertContains($username, $msg); - $this->assertContains(htmlspecialchars_decode($config['sitename']), $msg); - $this->assertContains(str_replace('
', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])), $msg); - $this->assertNotContains('EMAIL_SIG', $msg); - $this->assertNotContains('U_STOP_WATCHING_FORUM', $msg); + $this->assertStringContainsString($author_name, $msg); + $this->assertStringContainsString($forum_name, $msg); + $this->assertStringContainsString($topic_title, $msg); + $this->assertStringContainsString($username, $msg); + $this->assertStringContainsString(htmlspecialchars_decode($config['sitename']), $msg); + $this->assertStringContainsString(str_replace('
', "\n", "-- \n" . htmlspecialchars_decode($config['board_email_sig'])), $msg); + $this->assertStringNotContainsString('EMAIL_SIG', $msg); + $this->assertStringNotContainsString('U_STOP_WATCHING_FORUM', $msg); } } diff --git a/tests/event/exception_listener_test.php b/tests/event/exception_listener_test.php index fbae9e25b7..346bc5f3ec 100644 --- a/tests/event/exception_listener_test.php +++ b/tests/event/exception_listener_test.php @@ -94,7 +94,7 @@ class exception_listener extends phpbb_test_case if (isset($expected['content'])) { - $this->assertContains($expected['content'], $response->getContent()); + $this->assertStringContainsString($expected['content'], $response->getContent()); } } } diff --git a/tests/functional/acp_bbcodes_test.php b/tests/functional/acp_bbcodes_test.php index cc6397fdfd..bdf7920615 100644 --- a/tests/functional/acp_bbcodes_test.php +++ b/tests/functional/acp_bbcodes_test.php @@ -38,10 +38,10 @@ class phpbb_functional_acp_bbcodes_test extends phpbb_functional_test_case $crawler = self::submit($form); $html = $crawler->filter('#preview')->html(); - $this->assertContains('
a
', $html); - $this->assertContains('
b
', $html); - $this->assertContains('
c
', $html); - $this->assertContains('
d
', $html); + $this->assertStringContainsString('
a
', $html); + $this->assertStringContainsString('
b
', $html); + $this->assertStringContainsString('
c
', $html); + $this->assertStringContainsString('
d
', $html); } /** diff --git a/tests/functional/acp_groups_test.php b/tests/functional/acp_groups_test.php index 9dfdc93474..f574115d62 100644 --- a/tests/functional/acp_groups_test.php +++ b/tests/functional/acp_groups_test.php @@ -105,7 +105,7 @@ class phpbb_functional_acp_groups_test extends phpbb_functional_common_groups_te } } $crawler = self::submit($form); - $this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text()); + $this->assertStringContainsString($this->lang('GROUP_UPDATED'), $crawler->text()); $form = $this->get_group_manage_form($group_id); if (!isset($tick_legend) && !isset($tick_teampage)) diff --git a/tests/functional/acp_permissions_test.php b/tests/functional/acp_permissions_test.php index ccaa4aab29..19885570c3 100644 --- a/tests/functional/acp_permissions_test.php +++ b/tests/functional/acp_permissions_test.php @@ -31,21 +31,21 @@ class phpbb_functional_acp_permissions_test extends phpbb_functional_test_case // XXX hardcoded id $crawler = self::request('GET', 'adm/index.php?i=16&sid=' . $this->sid); // these language strings are html - $this->assertContains($this->lang('ACP_PERMISSIONS_EXPLAIN'), $this->get_content()); + $this->assertStringContainsString($this->lang('ACP_PERMISSIONS_EXPLAIN'), $this->get_content()); } public function test_select_user() { // User permissions $crawler = self::request('GET', 'adm/index.php?i=acp_permissions&icat=16&mode=setting_user_global&sid=' . $this->sid); - $this->assertContains($this->lang('ACP_USERS_PERMISSIONS_EXPLAIN'), $this->get_content()); + $this->assertStringContainsString($this->lang('ACP_USERS_PERMISSIONS_EXPLAIN'), $this->get_content()); // Select admin $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); $data = array('username[0]' => 'admin'); $form->setValues($data); $crawler = self::submit($form); - $this->assertContains($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text()); + $this->assertStringContainsString($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text()); } public function permissions_data() @@ -93,7 +93,7 @@ class phpbb_functional_acp_permissions_test extends phpbb_functional_test_case { // Get the form $crawler = self::request('GET', "adm/index.php?i=acp_permissions&icat=16&mode=$mode&${object_name}[0]=$object_id&type=$permission_type&sid=" . $this->sid); - $this->assertContains($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text()); + $this->assertStringContainsString($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text()); // XXX globals for \phpbb\auth\auth, refactor it later global $db, $cache; @@ -115,7 +115,7 @@ class phpbb_functional_acp_permissions_test extends phpbb_functional_test_case $data = array("setting[$object_id][0][$permission]" => '0'); $form->setValues($data); $crawler = self::submit($form); - $this->assertContains($this->lang('AUTH_UPDATED'), $crawler->text()); + $this->assertStringContainsString($this->lang('AUTH_UPDATED'), $crawler->text()); // check acl again $auth = new \phpbb\auth\auth; diff --git a/tests/functional/acp_users_test.php b/tests/functional/acp_users_test.php index c8d0072c28..b1f7e71c67 100644 --- a/tests/functional/acp_users_test.php +++ b/tests/functional/acp_users_test.php @@ -34,7 +34,7 @@ class phpbb_functional_acp_users_test extends phpbb_functional_test_case $crawler = self::request('GET', "adm/index.php?i=users&mode=overview&u=$user_id&sid={$this->sid}"); $form = $crawler->filter('#user_delete')->selectButton($this->lang('SUBMIT'))->form(); $crawler = self::submit($form); - $this->assertContains($this->lang('CANNOT_REMOVE_FOUNDER'), $this->get_content()); + $this->assertStringContainsString($this->lang('CANNOT_REMOVE_FOUNDER'), $this->get_content()); } protected function make_founder($user_id) @@ -44,6 +44,6 @@ class phpbb_functional_acp_users_test extends phpbb_functional_test_case $data = array('user_founder' => '1'); $form->setValues($data); $crawler = self::submit($form); - $this->assertContains($this->lang('USER_OVERVIEW_UPDATED'), $this->get_content()); + $this->assertStringContainsString($this->lang('USER_OVERVIEW_UPDATED'), $this->get_content()); } } diff --git a/tests/functional/auth_test.php b/tests/functional/auth_test.php index 76e1709afb..3e22a5b651 100644 --- a/tests/functional/auth_test.php +++ b/tests/functional/auth_test.php @@ -22,7 +22,7 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case // check for logout link $crawler = self::request('GET', 'index.php'); - $this->assertContains($this->lang('LOGOUT', 'admin'), $crawler->filter('.navbar')->text()); + $this->assertStringContainsString($this->lang('LOGOUT', 'admin'), $crawler->filter('.navbar')->text()); } public function test_login_other() @@ -30,7 +30,7 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case $this->create_user('anothertestuser'); $this->login('anothertestuser'); $crawler = self::request('GET', 'index.php'); - $this->assertContains('anothertestuser', $crawler->filter('#username_logged_in')->text()); + $this->assertStringContainsString('anothertestuser', $crawler->filter('#username_logged_in')->text()); } /** @@ -46,7 +46,7 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case $config['auth_method'] = 'foobar'; $this->login('anothertestuser'); $crawler = self::request('GET', 'index.php'); - $this->assertContains('anothertestuser', $crawler->filter('#username_logged_in')->text()); + $this->assertStringContainsString('anothertestuser', $crawler->filter('#username_logged_in')->text()); $sql = 'UPDATE ' . CONFIG_TABLE . " SET config_value = 'db' WHERE config_name = 'auth_method'"; $db->sql_query($sql); $config['auth_method'] = 'db'; @@ -65,7 +65,7 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case // look for a register link, which should be visible only when logged out $crawler = self::request('GET', 'index.php'); - $this->assertContains($this->lang('REGISTER'), $crawler->filter('.navbar')->text()); + $this->assertStringContainsString($this->lang('REGISTER'), $crawler->filter('.navbar')->text()); } public function test_acp_login() @@ -75,6 +75,6 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case // check that we are logged in $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid); - $this->assertContains($this->lang('ADMIN_PANEL'), $crawler->filter('h1')->text()); + $this->assertStringContainsString($this->lang('ADMIN_PANEL'), $crawler->filter('h1')->text()); } } diff --git a/tests/functional/common_avatar_test_case.php b/tests/functional/common_avatar_test_case.php index 155f6e0c09..a1ab7124c1 100644 --- a/tests/functional/common_avatar_test_case.php +++ b/tests/functional/common_avatar_test_case.php @@ -84,7 +84,7 @@ abstract class phpbb_functional_common_avatar_test_case extends phpbb_functional } catch (Exception $e) { - $this->assertContains($expected, $crawler->text()); + $this->assertStringContainsString($expected, $crawler->text()); } if ($delete) diff --git a/tests/functional/common_groups_test_case.php b/tests/functional/common_groups_test_case.php index 521b7c84d2..fdca908239 100644 --- a/tests/functional/common_groups_test_case.php +++ b/tests/functional/common_groups_test_case.php @@ -47,9 +47,9 @@ abstract class phpbb_functional_common_groups_test_case extends phpbb_functional $crawler = self::request('GET', 'adm/index.php?i=board&mode=avatar&sid=' . $this->sid); // Check the default entries we should have - $this->assertContains($this->lang('ALLOW_REMOTE_UPLOAD'), $crawler->text()); - $this->assertContains($this->lang('ALLOW_AVATARS'), $crawler->text()); - $this->assertContains($this->lang('ALLOW_LOCAL'), $crawler->text()); + $this->assertStringContainsString($this->lang('ALLOW_REMOTE_UPLOAD'), $crawler->text()); + $this->assertStringContainsString($this->lang('ALLOW_AVATARS'), $crawler->text()); + $this->assertStringContainsString($this->lang('ALLOW_LOCAL'), $crawler->text()); // Now start setting the needed settings $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); @@ -57,7 +57,7 @@ abstract class phpbb_functional_common_groups_test_case extends phpbb_functional $form['config[allow_avatar_remote]']->select(1); $form['config[allow_avatar_remote_upload]']->select(1); $crawler = self::submit($form); - $this->assertContains($this->lang('CONFIG_UPDATED'), $crawler->text()); + $this->assertStringContainsString($this->lang('CONFIG_UPDATED'), $crawler->text()); } public function groups_manage_test_data() @@ -82,7 +82,7 @@ abstract class phpbb_functional_common_groups_test_case extends phpbb_functional $form = $this->get_group_manage_form(); $form['group_colour']->setValue($input); $crawler = self::submit($form); - $this->assertContains($this->lang($expected), $crawler->text()); + $this->assertStringContainsString($this->lang($expected), $crawler->text()); } public function group_avatar_min_max_data() @@ -112,6 +112,6 @@ abstract class phpbb_functional_common_groups_test_case extends phpbb_functional $form['avatar_driver']->setValue($avatar_type); $form[$form_name]->setValue($input); $crawler = self::submit($form); - $this->assertContains($this->lang($expected), $crawler->text()); + $this->assertStringContainsString($this->lang($expected), $crawler->text()); } } diff --git a/tests/functional/download_test.php b/tests/functional/download_test.php index 3d4f316d72..6b58a9fff4 100644 --- a/tests/functional/download_test.php +++ b/tests/functional/download_test.php @@ -49,7 +49,7 @@ class phpbb_functional_download_test extends phpbb_functional_test_case $post = $this->create_topic($this->data['forums']['Download #1'], 'Download Topic #1', 'This is a test topic posted by the testing framework.', array('upload_files' => 1)); $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); - $this->assertContains('Download Topic #1', $crawler->filter('html')->text()); + $this->assertStringContainsString('Download Topic #1', $crawler->filter('html')->text()); $this->data['topics']['Download Topic #1'] = (int) $post['topic_id']; $this->data['posts']['Download Topic #1'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p'); @@ -57,7 +57,7 @@ class phpbb_functional_download_test extends phpbb_functional_test_case $post2 = $this->create_post($this->data['forums']['Download #1'], $post['topic_id'], 'Re: Download Topic #1-#2', 'This is a test post posted by the testing framework.', array('upload_files' => 1)); $crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}"); - $this->assertContains('Re: Download Topic #1-#2', $crawler->filter('html')->text()); + $this->assertStringContainsString('Re: Download Topic #1-#2', $crawler->filter('html')->text()); $this->data['posts']['Re: Download Topic #1-#2'] = (int) $post2['post_id']; } @@ -115,7 +115,7 @@ class phpbb_functional_download_test extends phpbb_functional_test_case $this->assertContainsLang('POST_DELETED', $crawler->text()); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Download Topic #1']}&sid={$this->sid}"); - $this->assertContains($this->lang('POST_DISPLAY', '', ''), $crawler->text()); + $this->assertStringContainsString($this->lang('POST_DISPLAY', '', ''), $crawler->text()); } public function test_download_softdeleted_post() @@ -182,7 +182,7 @@ class phpbb_functional_download_test extends phpbb_functional_test_case $this->assertContainsLang('TOPIC_DELETED_SUCCESS', $crawler->text()); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Download Topic #1']}&sid={$this->sid}"); - $this->assertContains('Download Topic #1', $crawler->filter('h2')->text()); + $this->assertStringContainsString('Download Topic #1', $crawler->filter('h2')->text()); } public function test_download_softdeleted_topic() diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php index 33a9b443bb..c0ae37ad9a 100644 --- a/tests/functional/extension_acp_test.php +++ b/tests/functional/extension_acp_test.php @@ -88,27 +88,27 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case $this->assertCount(1, $crawler->filter('.ext_enabled')); $this->assertCount(7, $crawler->filter('.ext_disabled')); - $this->assertContains('phpBB Foo Extension', $crawler->filter('.ext_enabled')->eq(0)->text()); + $this->assertStringContainsString('phpBB Foo Extension', $crawler->filter('.ext_enabled')->eq(0)->text()); $this->assertContainsLang('EXTENSION_DISABLE', $crawler->filter('.ext_enabled')->eq(0)->text()); - $this->assertContains('phpBB Moo Extension', $crawler->filter('.ext_disabled')->eq(2)->text()); + $this->assertStringContainsString('phpBB Moo Extension', $crawler->filter('.ext_disabled')->eq(2)->text()); $this->assertContainsLang('DETAILS', $crawler->filter('.ext_disabled')->eq(2)->text()); $this->assertContainsLang('EXTENSION_ENABLE', $crawler->filter('.ext_disabled')->eq(2)->text()); $this->assertContainsLang('EXTENSION_DELETE_DATA', $crawler->filter('.ext_disabled')->eq(2)->text()); - $this->assertContains('The “vendor/test2” extension is not valid.', $crawler->filter('.ext_disabled')->eq(0)->text()); + $this->assertStringContainsString('The “vendor/test2” extension is not valid.', $crawler->filter('.ext_disabled')->eq(0)->text()); - $this->assertContains('The “vendor/test3” extension is not valid.', $crawler->filter('.ext_disabled')->eq(1)->text()); + $this->assertStringContainsString('The “vendor/test3” extension is not valid.', $crawler->filter('.ext_disabled')->eq(1)->text()); - $this->assertContains('phpBB Bar Extension', $crawler->filter('.ext_disabled')->eq(3)->text()); + $this->assertStringContainsString('phpBB Bar Extension', $crawler->filter('.ext_disabled')->eq(3)->text()); $this->assertContainsLang('DETAILS', $crawler->filter('.ext_disabled')->eq(3)->text()); $this->assertContainsLang('EXTENSION_ENABLE', $crawler->filter('.ext_disabled')->eq(3)->text()); // Check that invalid extensions are not listed. - $this->assertNotContains('phpBB BarFoo Extension', $crawler->filter('.table1')->text()); - $this->assertNotContains('barfoo', $crawler->filter('.table1')->text()); + $this->assertStringNotContainsString('phpBB BarFoo Extension', $crawler->filter('.table1')->text()); + $this->assertStringNotContainsString('barfoo', $crawler->filter('.table1')->text()); - $this->assertNotContains('vendor3/bar', $crawler->filter('.table1')->text()); + $this->assertStringNotContainsString('vendor3/bar', $crawler->filter('.table1')->text()); } public function test_details() @@ -143,7 +143,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case { $match = true; - $this->assertContains($expected, $text); + $this->assertStringContainsString($expected, $text); } } @@ -163,7 +163,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case $this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('div.main thead')->text()); $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); - $this->assertContains($this->lang('EXTENSION_ENABLE_CONFIRM', 'phpBB Moo Extension'), $crawler->filter('#main')->text()); + $this->assertStringContainsString($this->lang('EXTENSION_ENABLE_CONFIRM', 'phpBB Moo Extension'), $crawler->filter('#main')->text()); // Correctly submit the enable form, default not enableable message $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor3%2Ffoo&sid=' . $this->sid); @@ -171,8 +171,8 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case // Custom reason messages returned by not enableable extension $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor5%2Ffoo&sid=' . $this->sid); - $this->assertContains('Reason 1', $crawler->filter('.errorbox')->text()); - $this->assertContains('Reason 2', $crawler->filter('.errorbox')->text()); + $this->assertStringContainsString('Reason 1', $crawler->filter('.errorbox')->text()); + $this->assertStringContainsString('Reason 2', $crawler->filter('.errorbox')->text()); } public function test_disable_pre() @@ -184,14 +184,14 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case $this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('div.main thead')->text()); $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=vendor2%2Ffoo&sid=' . $this->sid); - $this->assertContains($this->lang('EXTENSION_DISABLE_CONFIRM', 'phpBB Foo Extension'), $crawler->filter('#main')->text()); + $this->assertStringContainsString($this->lang('EXTENSION_DISABLE_CONFIRM', 'phpBB Foo Extension'), $crawler->filter('#main')->text()); } public function test_delete_data_pre() { // test2 is not available (error) $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=test2&sid=' . $this->sid); - $this->assertContains($this->lang('FILE_NOT_FOUND', ''), $crawler->filter('.errorbox')->text()); + $this->assertStringContainsString($this->lang('FILE_NOT_FOUND', ''), $crawler->filter('.errorbox')->text()); // foo is not disabled (redirect to list) $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=vendor2%2Ffoo&sid=' . $this->sid); @@ -200,7 +200,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case $this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('div.main thead')->text()); $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid); - $this->assertContains('Are you sure that you wish to delete the data associated with “phpBB Moo Extension”?', $crawler->filter('.errorbox')->text()); + $this->assertStringContainsString('Are you sure that you wish to delete the data associated with “phpBB Moo Extension”?', $crawler->filter('.errorbox')->text()); } public function test_actions() diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index c5ebf761c9..d77d7df4f4 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -62,7 +62,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c $this->phpbb_extension_manager->enable('foo/bar'); $crawler = self::request('GET', 'app.php/foo/bar', array(), false); self::assert_response_status_code(); - $this->assertContains("foo/bar controller handle() method", $crawler->filter('body')->text()); + $this->assertStringContainsString("foo/bar controller handle() method", $crawler->filter('body')->text()); $this->phpbb_extension_manager->purge('foo/bar'); } @@ -74,7 +74,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c $this->phpbb_extension_manager->enable('foo/foo'); $crawler = self::request('GET', 'app.php/foo/foo', array(), false); self::assert_response_status_code(); - $this->assertContains("foo/foo controller handle() method", $crawler->filter('body')->text()); + $this->assertStringContainsString("foo/foo controller handle() method", $crawler->filter('body')->text()); $this->phpbb_extension_manager->purge('foo/foo'); } @@ -85,7 +85,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c { $this->phpbb_extension_manager->enable('foo/bar'); $crawler = self::request('GET', 'app.php/foo/template'); - $this->assertContains("I am a variable", $crawler->filter('#content')->text()); + $this->assertStringContainsString("I am a variable", $crawler->filter('#content')->text()); $this->phpbb_extension_manager->purge('foo/bar'); } @@ -95,7 +95,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c public function test_controller_template_include_js_css() { $crawler = self::request('GET', 'app.php/help/faq'); - $this->assertContains("./../../assets/javascript/core.js", $crawler->filter('body')->html()); + $this->assertStringContainsString("./../../assets/javascript/core.js", $crawler->filter('body')->html()); } /** @@ -107,7 +107,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c $this->phpbb_extension_manager->enable('foo/bar'); $crawler = self::request('GET', 'app.php/foo/baz', array(), false); $this->assert_response_html(500); - $this->assertContains('Missing value for argument #1: test in class foo\bar\controller\controller:baz', $crawler->filter('body')->text()); + $this->assertStringContainsString('Missing value for argument #1: test in class foo\bar\controller\controller:baz', $crawler->filter('body')->text()); $this->phpbb_extension_manager->purge('foo/bar'); } @@ -119,7 +119,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c $this->phpbb_extension_manager->enable('foo/bar'); $crawler = self::request('GET', 'app.php/foo/exception', array(), false); $this->assert_response_html(500); - $this->assertContains('Exception thrown from foo/exception route', $crawler->filter('body')->text()); + $this->assertStringContainsString('Exception thrown from foo/exception route', $crawler->filter('body')->text()); $this->phpbb_extension_manager->purge('foo/bar'); } @@ -136,7 +136,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c { $crawler = self::request('GET', 'app.php/does/not/exist', array(), false); $this->assert_response_html(404); - $this->assertContains('No route found for "GET /does/not/exist"', $crawler->filter('body')->text()); + $this->assertStringContainsString('No route found for "GET /does/not/exist"', $crawler->filter('body')->text()); } /** @@ -157,7 +157,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c $this->assertStringStartsWith('./app.php/foo/login_redirect', $form->get('redirect')->getValue()); $crawler = self::submit($form); - $this->assertContains("I am a variable", $crawler->filter('#content')->text(), 'Unsuccessful redirect after using login_box()'); + $this->assertStringContainsString("I am a variable", $crawler->filter('#content')->text(), 'Unsuccessful redirect after using login_box()'); $this->phpbb_extension_manager->purge('foo/bar'); } diff --git a/tests/functional/extension_global_lang_test.php b/tests/functional/extension_global_lang_test.php index 94c80a6d9a..d462d6eb5d 100644 --- a/tests/functional/extension_global_lang_test.php +++ b/tests/functional/extension_global_lang_test.php @@ -67,9 +67,9 @@ class phpbb_functional_extension_global_lang_test extends phpbb_functional_test_ $crawler = self::request('GET', 'index.php'); // language from language/en/common.php - $this->assertNotContains('Skip to content', $crawler->filter('.skiplink')->text()); + $this->assertStringNotContainsString('Skip to content', $crawler->filter('.skiplink')->text()); // language from ext/foo/bar/language/en/foo_global.php - $this->assertContains('Overwritten by foo', $crawler->filter('.skiplink')->text()); + $this->assertStringContainsString('Overwritten by foo', $crawler->filter('.skiplink')->text()); } } diff --git a/tests/functional/extension_module_test.php b/tests/functional/extension_module_test.php index 09d0124990..bda18380a1 100644 --- a/tests/functional/extension_module_test.php +++ b/tests/functional/extension_module_test.php @@ -118,7 +118,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case $this->admin_login(); $crawler = self::request('GET', 'adm/index.php?i=foo%5cbar%5cacp%5cmain_module&mode=mode&sid=' . $this->sid); - $this->assertContains('Bertie rulez!', $crawler->filter('#main')->text()); + $this->assertStringContainsString('Bertie rulez!', $crawler->filter('#main')->text()); } public function test_ucp() @@ -126,11 +126,11 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case $this->login(); $crawler = self::request('GET', 'ucp.php?sid=' . $this->sid); - $this->assertContains('UCP_FOOBAR_TITLE', $crawler->filter('#tabs')->text()); + $this->assertStringContainsString('UCP_FOOBAR_TITLE', $crawler->filter('#tabs')->text()); $link = $crawler->selectLink('UCP_FOOBAR_TITLE')->link()->getUri(); $crawler = self::request('GET', substr($link, strpos($link, 'ucp.'))); - $this->assertContains('UCP Extension Template Test Passed!', $crawler->filter('#content')->text()); + $this->assertStringContainsString('UCP Extension Template Test Passed!', $crawler->filter('#content')->text()); $this->phpbb_extension_manager->purge('foo/bar'); } diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index e0721ad1ec..c9f5ff2367 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -78,9 +78,9 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t $crawler = self::submit($form); // language from language/en/acp/permissions_phpbb.php - $this->assertContains('Can attach files', $crawler->filter('body')->text()); + $this->assertStringContainsString('Can attach files', $crawler->filter('body')->text()); // language from ext/foo/bar/language/en/permissions_foo.php - $this->assertContains('Can view foobar', $crawler->filter('body')->text()); + $this->assertStringContainsString('Can view foobar', $crawler->filter('body')->text()); } } diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index b26a228523..9dde6ffcb0 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -74,7 +74,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->add_lang('acp/permissions'); $crawler = self::request('GET', "adm/index.php?i=acp_permissions&sid={$this->sid}&icat=16&mode=setting_group_global&group_id[0]=1"); - self::assertContains($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text()); + self::assertStringContainsString($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text()); $form = $crawler->selectButton($this->lang('APPLY_PERMISSIONS'))->form(); $form['setting[1][0][u_download]']->select(-1); @@ -338,7 +338,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $post = $this->create_topic($this->data['forums']['Feeds #news'], 'Feeds #news - Topic #2', 'This is a test topic posted by the testing framework.'); $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); - self::assertContains('Feeds #news - Topic #2', $crawler->filter('html')->text()); + self::assertStringContainsString('Feeds #news - Topic #2', $crawler->filter('html')->text()); $this->data['topics']['Feeds #news - Topic #2'] = (int) $post['topic_id']; $this->data['posts']['Feeds #news - Topic #2'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p'); @@ -346,7 +346,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $post2 = $this->create_post($this->data['forums']['Feeds #news'], $post['topic_id'], 'Re: Feeds #news - Topic #2', 'This is a test post posted by the testing framework.'); $crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}"); - self::assertContains('Re: Feeds #news - Topic #2', $crawler->filter('html')->text()); + self::assertStringContainsString('Re: Feeds #news - Topic #2', $crawler->filter('html')->text()); $this->data['posts']['Re: Feeds #news - Topic #2'] = (int) $post2['post_id']; } @@ -502,7 +502,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $post2 = $this->create_post($this->data['forums']['Feeds #1'], $post['topic_id'], 'Re: Feeds #1 - Topic #2', 'This is a test post posted by the testing framework.'); $crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}"); - self::assertContains('Re: Feeds #1 - Topic #2', $crawler->filter('html')->text()); + self::assertStringContainsString('Re: Feeds #1 - Topic #2', $crawler->filter('html')->text()); $this->data['posts']['Re: Feeds #1 - Topic #2'] = (int) $post2['post_id']; } @@ -530,7 +530,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case self::assertContainsLang('POST_DELETED', $crawler->text()); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Feeds #1 - Topic #2']}&sid={$this->sid}"); - self::assertContains($this->lang('POST_DISPLAY', '', ''), $crawler->text()); + self::assertStringContainsString($this->lang('POST_DISPLAY', '', ''), $crawler->text()); } public function test_feeds_softdeleted_post_admin() @@ -630,7 +630,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case self::assertContainsLang('TOPIC_DELETED_SUCCESS', $crawler->text()); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Feeds #1 - Topic #2']}&sid={$this->sid}"); - self::assertContains('Feeds #1 - Topic #2', $crawler->filter('h2')->text()); + self::assertStringContainsString('Feeds #1 - Topic #2', $crawler->filter('h2')->text()); } public function test_feeds_softdeleted_topic_admin() @@ -769,7 +769,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->create_post($this->data['forums']['Feeds #1.1'], $post['topic_id'], 'Re: Feeds #1.1 - Topic #2', 'This is a test post posted by the testing framework.', array(), 'POST_STORED_MOD'); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Feeds #1.1 - Topic #2']}&sid={$this->sid}"); - self::assertNotContains('Re: Feeds #1.1 - Topic #2', $crawler->filter('html')->text()); + self::assertStringNotContainsString('Re: Feeds #1.1 - Topic #2', $crawler->filter('html')->text()); } public function test_feeds_unapproved_post_admin() @@ -860,7 +860,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->create_topic($this->data['forums']['Feeds #1.1'], 'Feeds #1.1 - Topic #3', 'This is a test topic posted by the testing framework.', array(), 'POST_STORED_MOD'); $crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Feeds #1.1']}&sid={$this->sid}"); - self::assertNotContains('Feeds #1.1 - Topic #3', $crawler->filter('html')->text()); + self::assertStringNotContainsString('Feeds #1.1 - Topic #3', $crawler->filter('html')->text()); $this->logout(); $this->set_flood_interval(15); @@ -1012,7 +1012,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $post = $this->create_topic($this->data['forums']['Feeds #1'], 'Feeds #1 - Topic #3', 'This is a test topic posted by the testing framework. [attachment=0]Attachment #0[/attachment]', array('upload_files' => 1)); $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); - self::assertContains('Feeds #1 - Topic #3', $crawler->filter('html')->text()); + self::assertStringContainsString('Feeds #1 - Topic #3', $crawler->filter('html')->text()); $this->data['topics']['Feeds #1 - Topic #3'] = (int) $post['topic_id']; } @@ -1230,7 +1230,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $post2 = $this->create_post($this->data['forums']['Feeds #1'], $this->data['topics']['Feeds #1 - Topic #3'], 'Re: Feeds #1 - Topic #3-1', 'This is a test post posted by the testing framework. [attachment=0]Attachment #0[/attachment]'); $crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}"); - self::assertContains('Re: Feeds #1 - Topic #3-1', $crawler->filter('html')->text()); + self::assertStringContainsString('Re: Feeds #1 - Topic #3-1', $crawler->filter('html')->text()); $this->data['posts']['Re: Feeds #1 - Topic #3-1'] = (int) $post2['post_id']; } @@ -1395,7 +1395,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case foreach($data['contents'] as $entry_id => $string) { $content = $crawler->filterXPath("//entry[{$entry_id}]/content")->text(); - self::assertContains($string, $content, "Tested feed : 'app.php/feed{$params}'"); + self::assertStringContainsString($string, $content, "Tested feed : 'app.php/feed{$params}'"); } } @@ -1420,13 +1420,13 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case if ($attachment['displayed']) { - self::assertContains($url, $content, "Tested feed : 'app.php/feed{$params}'"); - self::assertNotContains($string, $content, "Tested feed : 'app.php/feed{$params}'"); + self::assertStringContainsString($url, $content, "Tested feed : 'app.php/feed{$params}'"); + self::assertStringNotContainsString($string, $content, "Tested feed : 'app.php/feed{$params}'"); } else { - self::assertContains($string, $content, "Tested feed : 'app.php/feed{$params}'"); - self::assertNotContains($url, $content, "Tested feed : 'app.php/feed{$params}'"); + self::assertStringContainsString($string, $content, "Tested feed : 'app.php/feed{$params}'"); + self::assertStringNotContainsString($url, $content, "Tested feed : 'app.php/feed{$params}'"); } } } diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php index b2f230b66f..8722a14350 100644 --- a/tests/functional/fileupload_form_test.php +++ b/tests/functional/fileupload_form_test.php @@ -143,7 +143,7 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case $crawler = $this->upload_file('valid.jpg', 'image/jpeg'); // Ensure there was no error message rendered - $this->assertNotContains('

' . $this->lang('INFORMATION') . '

', $this->get_content()); + $this->assertStringNotContainsString('

' . $this->lang('INFORMATION') . '

', $this->get_content()); // Also the file name should be in the first row of the files table $this->assertEquals('valid.jpg', $crawler->filter('span.file-name')->eq(1)->text()); diff --git a/tests/functional/forgot_password_test.php b/tests/functional/forgot_password_test.php index 10946fe5a9..490ba4cbb2 100644 --- a/tests/functional/forgot_password_test.php +++ b/tests/functional/forgot_password_test.php @@ -41,7 +41,7 @@ class phpbb_functional_forgot_password_test extends phpbb_functional_test_case $this->logout(); $crawler = self::request('GET', 'app.php/user/forgot_password'); - $this->assertContains($this->lang('UCP_PASSWORD_RESET_DISABLED', '', ''), $crawler->text()); + $this->assertStringContainsString($this->lang('UCP_PASSWORD_RESET_DISABLED', '', ''), $crawler->text()); } diff --git a/tests/functional/forum_style_test.php b/tests/functional/forum_style_test.php index b3c1115b7f..7c7df32184 100644 --- a/tests/functional/forum_style_test.php +++ b/tests/functional/forum_style_test.php @@ -19,25 +19,26 @@ class phpbb_functional_forum_style_test extends phpbb_functional_test_case public function test_font_awesome_style() { $crawler = self::request('GET', 'viewtopic.php?t=1&f=2'); - $this->assertContains('font-awesome.min', $crawler->filter('head > link[rel=stylesheet]')->eq(0)->attr('href')); + $this->assertStringContainsString('font-awesome.min', $crawler->filter('head > link[rel=stylesheet]')->eq(0)->attr('href')); $crawler = self::request('GET', 'viewtopic.php?t=1'); - $this->assertContains('font-awesome.min', $crawler->filter('head > link[rel=stylesheet]')->eq(0)->attr('href')); + $this->assertStringContainsString('font-awesome.min', $crawler->filter('head > link[rel=stylesheet]')->eq(0)->attr('href')); $crawler = self::request('GET', 'viewtopic.php?t=1&view=next'); - $this->assertContains('font-awesome.min', $crawler->filter('head > link[rel=stylesheet]')->eq(0)->attr('href')); + $this->assertStringContainsString('font-awesome.min', $crawler->filter('head > link[rel=stylesheet]')->eq(0)->attr('href')); } public function test_default_forum_style() { $crawler = self::request('GET', 'viewtopic.php?t=1&f=2'); - $this->assertContains('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href')); + + $this->assertStringContainsString('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->eq(2)->attr('href')); $crawler = self::request('GET', 'viewtopic.php?t=1'); - $this->assertContains('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href')); + $this->assertStringContainsString('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->eq(2)->attr('href')); $crawler = self::request('GET', 'viewtopic.php?t=1&view=next'); - $this->assertContains('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href')); + $this->assertStringContainsString('styles/prosilver/', $crawler->filter('head > link[rel=stylesheet]')->eq(2)->attr('href')); } public function test_custom_forum_style() @@ -47,6 +48,7 @@ class phpbb_functional_forum_style_test extends phpbb_functional_test_case $db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_style = 2 WHERE forum_id = 2'); $crawler = self::request('GET', 'viewtopic.php?t=1&f=2'); +<<<<<<< HEAD $this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href')); $crawler = self::request('GET', 'viewtopic.php?t=1'); @@ -54,6 +56,15 @@ class phpbb_functional_forum_style_test extends phpbb_functional_test_case $crawler = self::request('GET', 'viewtopic.php?t=1&view=next'); $this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href')); +======= + $this->assertStringContainsString('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->eq(2)->attr('href')); + + $crawler = self::request('GET', 'viewtopic.php?t=1'); + $this->assertStringContainsString('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->eq(2)->attr('href')); + + $crawler = self::request('GET', 'viewtopic.php?t=1&view=next'); + $this->assertStringContainsString('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->eq(2)->attr('href')); +>>>>>>> 33be5dc489... [ticket/16549] Move from assert[Not]Contains to assertString[Not]ContainsString $db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_style = 0 WHERE forum_id = 2'); $this->delete_style(2, 'test_style'); diff --git a/tests/functional/jumpbox_test.php b/tests/functional/jumpbox_test.php index f5a671b1b9..9e2938f9e2 100644 --- a/tests/functional/jumpbox_test.php +++ b/tests/functional/jumpbox_test.php @@ -30,6 +30,6 @@ class phpbb_functional_jumpbox_test extends phpbb_functional_test_case protected function check_valid_jump($forum) { - $this->assertContains($this->lang('FORUM') . ": $forum", $this->crawler->filter('#cp-main h2')->text(), $this->crawler->text()); + $this->assertStringContainsString($this->lang('FORUM') . ": $forum", $this->crawler->filter('#cp-main h2')->text(), $this->crawler->text()); } } diff --git a/tests/functional/mcp_test.php b/tests/functional/mcp_test.php index 40615d66a5..87a98dae74 100644 --- a/tests/functional/mcp_test.php +++ b/tests/functional/mcp_test.php @@ -24,7 +24,7 @@ class phpbb_functional_mcp_test extends phpbb_functional_test_case $post = $this->create_topic(2, 'Test Topic 2', 'Testing move post with "Move posts" option from Quick-Moderator Tools.'); $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); - $this->assertContains('Testing move post with "Move posts" option from Quick-Moderator Tools.', $crawler->filter('html')->text()); + $this->assertStringContainsString('Testing move post with "Move posts" option from Quick-Moderator Tools.', $crawler->filter('html')->text()); return $crawler; } @@ -49,7 +49,7 @@ class phpbb_functional_mcp_test extends phpbb_functional_test_case )); $form['post_id_list'][0]->tick(); $crawler = self::submit($form); - $this->assertContains($this->lang('MERGE_POSTS'), $crawler->filter('html')->text()); + $this->assertStringContainsString($this->lang('MERGE_POSTS'), $crawler->filter('html')->text()); return $crawler; } @@ -62,7 +62,7 @@ class phpbb_functional_mcp_test extends phpbb_functional_test_case $this->add_lang('mcp'); $form = $crawler->selectButton('Yes')->form(); $crawler = self::submit($form); - $this->assertContains($this->lang('POSTS_MERGED_SUCCESS'), $crawler->text()); + $this->assertStringContainsString($this->lang('POSTS_MERGED_SUCCESS'), $crawler->text()); } public function test_delete_logs() diff --git a/tests/functional/memberlist_test.php b/tests/functional/memberlist_test.php index 1da5c39401..3e40ddc528 100644 --- a/tests/functional/memberlist_test.php +++ b/tests/functional/memberlist_test.php @@ -22,15 +22,15 @@ class phpbb_functional_memberlist_test extends phpbb_functional_test_case // logs in as admin $this->login(); $crawler = self::request('GET', 'memberlist.php?sid=' . $this->sid); - $this->assertContains('memberlist-test-user', $crawler->text()); + $this->assertStringContainsString('memberlist-test-user', $crawler->text()); // restrict by first character $crawler = self::request('GET', 'memberlist.php?first_char=m&sid=' . $this->sid); - $this->assertContains('memberlist-test-user', $crawler->text()); + $this->assertStringContainsString('memberlist-test-user', $crawler->text()); // make sure results for wrong character are not returned $crawler = self::request('GET', 'memberlist.php?first_char=a&sid=' . $this->sid); - $this->assertNotContains('memberlist-test-user', $crawler->text()); + $this->assertStringNotContainsString('memberlist-test-user', $crawler->text()); } public function test_viewprofile() @@ -38,7 +38,7 @@ class phpbb_functional_memberlist_test extends phpbb_functional_test_case $this->login(); // XXX hardcoded user id $crawler = self::request('GET', 'memberlist.php?mode=viewprofile&u=2&sid=' . $this->sid); - $this->assertContains('admin', $crawler->filter('h2')->text()); + $this->assertStringContainsString('admin', $crawler->filter('h2')->text()); } protected function get_memberlist_leaders_table_crawler() @@ -55,16 +55,16 @@ class phpbb_functional_memberlist_test extends phpbb_functional_test_case $crawler = $this->get_memberlist_leaders_table_crawler(); // Admin in admin group, but not in moderators - $this->assertContains('admin', $crawler->eq(0)->text()); - $this->assertNotContains('admin', $crawler->eq(1)->text()); + $this->assertStringContainsString('admin', $crawler->eq(0)->text()); + $this->assertStringNotContainsString('admin', $crawler->eq(1)->text()); // memberlist-test-user in neither group - $this->assertNotContains('memberlist-test-user', $crawler->eq(0)->text()); - $this->assertNotContains('memberlist-test-user', $crawler->eq(1)->text()); + $this->assertStringNotContainsString('memberlist-test-user', $crawler->eq(0)->text()); + $this->assertStringNotContainsString('memberlist-test-user', $crawler->eq(1)->text()); // memberlist-test-moderator in neither group - $this->assertNotContains('memberlist-test-moderator', $crawler->eq(0)->text()); - $this->assertNotContains('memberlist-test-moderator', $crawler->eq(1)->text()); + $this->assertStringNotContainsString('memberlist-test-moderator', $crawler->eq(0)->text()); + $this->assertStringNotContainsString('memberlist-test-moderator', $crawler->eq(1)->text()); } public function test_leaders_remove_users() @@ -74,14 +74,14 @@ class phpbb_functional_memberlist_test extends phpbb_functional_test_case // Remove admin from admins, but is now in moderators $this->remove_user_group('ADMINISTRATORS', array('admin')); $crawler = $this->get_memberlist_leaders_table_crawler(); - $this->assertNotContains('admin', $crawler->eq(0)->text()); - $this->assertContains('admin', $crawler->eq(1)->text()); + $this->assertStringNotContainsString('admin', $crawler->eq(0)->text()); + $this->assertStringContainsString('admin', $crawler->eq(1)->text()); // Remove admin from moderators, should not be visible anymore $this->remove_user_group('GLOBAL_MODERATORS', array('admin')); $crawler = $this->get_memberlist_leaders_table_crawler(); - $this->assertNotContains('admin', $crawler->eq(0)->text()); - $this->assertNotContains('admin', $crawler->eq(1)->text()); + $this->assertStringNotContainsString('admin', $crawler->eq(0)->text()); + $this->assertStringNotContainsString('admin', $crawler->eq(1)->text()); } public function test_leaders_add_users() @@ -91,20 +91,20 @@ class phpbb_functional_memberlist_test extends phpbb_functional_test_case // Add memberlist-test-moderator to moderators $this->add_user_group('GLOBAL_MODERATORS', array('memberlist-test-moderator')); $crawler = $this->get_memberlist_leaders_table_crawler(); - $this->assertNotContains('memberlist-test-moderator', $crawler->eq(0)->text()); - $this->assertContains('memberlist-test-moderator', $crawler->eq(1)->text()); + $this->assertStringNotContainsString('memberlist-test-moderator', $crawler->eq(0)->text()); + $this->assertStringContainsString('memberlist-test-moderator', $crawler->eq(1)->text()); // Add admin to moderators, should be visible as moderator $this->add_user_group('GLOBAL_MODERATORS', array('admin'), true); $crawler = $this->get_memberlist_leaders_table_crawler(); - $this->assertNotContains('admin', $crawler->eq(0)->text()); - $this->assertContains('admin', $crawler->eq(1)->text()); + $this->assertStringNotContainsString('admin', $crawler->eq(0)->text()); + $this->assertStringContainsString('admin', $crawler->eq(1)->text()); // Add admin to admins as leader, should be visible as admin, not moderator $this->add_user_group('ADMINISTRATORS', array('admin'), true, true); $crawler = $this->get_memberlist_leaders_table_crawler(); - $this->assertContains('admin', $crawler->eq(0)->text()); - $this->assertNotContains('admin', $crawler->eq(1)->text()); + $this->assertStringContainsString('admin', $crawler->eq(0)->text()); + $this->assertStringNotContainsString('admin', $crawler->eq(1)->text()); } public function test_group_rank() @@ -130,7 +130,7 @@ class phpbb_functional_memberlist_test extends phpbb_functional_test_case $this->assertContainsLang('RANK_UPDATED', $crawler->filter('.successbox')->text()); $crawler = self::request('GET', 'memberlist.php?mode=group&g=2'); - $this->assertContains('memberlist-test-user', $crawler->text()); + $this->assertStringContainsString('memberlist-test-user', $crawler->text()); unlink(__DIR__ . '/../../phpBB/images/ranks/valid.jpg'); } diff --git a/tests/functional/metadata_manager_test.php b/tests/functional/metadata_manager_test.php index 4f4fad4434..ca52e73ed0 100644 --- a/tests/functional/metadata_manager_test.php +++ b/tests/functional/metadata_manager_test.php @@ -63,9 +63,9 @@ class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case public function test_extensions_list() { $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid); - $this->assertContains($this->lang('EXTENSIONS_EXPLAIN'), $crawler->filter('#main')->text()); - $this->assertContains('phpBB 3.1 Extension Testing', $crawler->filter('#main')->text()); - $this->assertContains('Details', $crawler->filter('#main')->text()); + $this->assertStringContainsString($this->lang('EXTENSIONS_EXPLAIN'), $crawler->filter('#main')->text()); + $this->assertStringContainsString('phpBB 3.1 Extension Testing', $crawler->filter('#main')->text()); + $this->assertStringContainsString('Details', $crawler->filter('#main')->text()); } public function test_extensions_details() @@ -73,15 +73,15 @@ class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=foo%2Fbar&sid=' . $this->sid); // Test whether the details are displayed - $this->assertContains($this->lang('CLEAN_NAME'), $crawler->filter('#main')->text()); - $this->assertContains('foo/bar', $crawler->filter('#meta_name')->text()); + $this->assertStringContainsString($this->lang('CLEAN_NAME'), $crawler->filter('#main')->text()); + $this->assertStringContainsString('foo/bar', $crawler->filter('#meta_name')->text()); - $this->assertContains($this->lang('PHP_VERSION'), $crawler->filter('#main')->text()); - $this->assertContains('>=5.3', $crawler->filter('#require_php')->text()); + $this->assertStringContainsString($this->lang('PHP_VERSION'), $crawler->filter('#main')->text()); + $this->assertStringContainsString('>=5.3', $crawler->filter('#require_php')->text()); // Details should be html escaped // However, text() only returns the displayed text, so HTML Special Chars are decoded. // So we test this directly on the content of the response. - $this->assertContains('>=5.3', $this->get_content()); + $this->assertStringContainsString('>=5.3', $this->get_content()); } public function test_extensions_details_notexists() @@ -89,6 +89,6 @@ class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=not%2Fexists&sid=' . $this->sid); // Error message because the files do not exist - $this->assertContains($this->lang('FILE_NOT_FOUND', ''), $crawler->filter('#main')->text()); + $this->assertStringContainsString($this->lang('FILE_NOT_FOUND', ''), $crawler->filter('#main')->text()); } } diff --git a/tests/functional/notification_test.php b/tests/functional/notification_test.php index 91fc962846..759fbcf98a 100644 --- a/tests/functional/notification_test.php +++ b/tests/functional/notification_test.php @@ -67,7 +67,7 @@ class phpbb_functional_notification_test extends phpbb_functional_test_case // Post a new post that needs approval $this->create_post(2, 1, 'Re: Welcome to phpBB3', 'This is a test [b]post[/b] posted by notificationtestuser.', array(), 'POST_STORED_MOD'); $crawler = self::request('GET', "viewtopic.php?t=1&sid={$this->sid}"); - $this->assertNotContains('This is a test post posted by notificationtestuser.', $crawler->filter('html')->text()); + $this->assertStringNotContainsString('This is a test post posted by notificationtestuser.', $crawler->filter('html')->text()); // Login as admin $this->logout(); diff --git a/tests/functional/paging_test.php b/tests/functional/paging_test.php index cfaf9104a8..f6d6960919 100644 --- a/tests/functional/paging_test.php +++ b/tests/functional/paging_test.php @@ -27,17 +27,17 @@ class phpbb_functional_paging_test extends phpbb_functional_test_case $this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', 'This is a test post no' . $post_id . ' posted by the testing framework.'); } $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); - $this->assertContains('post no4', $crawler->text()); - $this->assertNotContains('post no16', $crawler->text()); + $this->assertStringContainsString('post no4', $crawler->text()); + $this->assertStringNotContainsString('post no16', $crawler->text()); $next_link = $crawler->filter('.pagination > ul > li.next > a')->attr('href'); $crawler = self::request('GET', $next_link); - $this->assertNotContains('post no4', $crawler->text()); - $this->assertContains('post no16', $crawler->text()); + $this->assertStringNotContainsString('post no4', $crawler->text()); + $this->assertStringContainsString('post no16', $crawler->text()); $prev_link = $crawler->filter('.pagination > ul > li.previous > a')->attr('href'); $crawler = self::request('GET', $prev_link); - $this->assertContains('post no4', $crawler->text()); - $this->assertNotContains('post no16', $crawler->text()); + $this->assertStringContainsString('post no4', $crawler->text()); + $this->assertStringNotContainsString('post no16', $crawler->text()); } } diff --git a/tests/functional/plupload_test.php b/tests/functional/plupload_test.php index b7b5b08360..19c09bafb6 100644 --- a/tests/functional/plupload_test.php +++ b/tests/functional/plupload_test.php @@ -111,7 +111,7 @@ class phpbb_functional_plupload_test extends phpbb_functional_test_case if ($i < self::CHUNKS - 1) { - $this->assertContains('{"jsonrpc":"2.0","id":"id","result":null}', self::get_content()); + $this->assertStringContainsString('{"jsonrpc":"2.0","id":"id","result":null}', self::get_content()); } else { diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 49447e1133..38edcf6767 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -24,17 +24,17 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case $post = $this->create_topic(2, 'Test Topic 1', 'This is a test topic posted by the testing framework.'); $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); - $this->assertContains('This is a test topic posted by the testing framework.', $crawler->filter('html')->text()); + $this->assertStringContainsString('This is a test topic posted by the testing framework.', $crawler->filter('html')->text()); // Test creating a reply with bbcode $post2 = $this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', 'This is a test [b]post[/b] posted by the testing framework.'); $crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}"); - $this->assertContains('This is a test post posted by the testing framework.', $crawler->filter('html')->text()); + $this->assertStringContainsString('This is a test post posted by the testing framework.', $crawler->filter('html')->text()); // Test quoting a message $crawler = self::request('GET', "posting.php?mode=quote&f=2&t={$post2['topic_id']}&p={$post2['post_id']}&sid={$this->sid}"); - $this->assertContains('This is a test post posted by the testing framework.', $crawler->filter('html')->text()); + $this->assertStringContainsString('This is a test post posted by the testing framework.', $crawler->filter('html')->text()); } public function test_unsupported_characters() @@ -44,7 +44,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case $post = $this->create_topic(2, "Test Topic \xF0\x9F\xA4\x94 3\xF0\x9D\x94\xBB\xF0\x9D\x95\x9A", 'This is a test with emoji character in the topic title.'); $this->create_post(2, $post['topic_id'], "Re: Test Topic 1 \xF0\x9F\xA4\x94 3\xF0\x9D\x94\xBB\xF0\x9D\x95\x9A", 'This is a test with emoji characters in the topic title.'); $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); - $this->assertContains("\xF0\x9F\xA4\x94 3\xF0\x9D\x94\xBB\xF0\x9D\x95\x9A", $crawler->text()); + $this->assertStringContainsString("\xF0\x9F\xA4\x94 3\xF0\x9D\x94\xBB\xF0\x9D\x95\x9A", $crawler->text()); } public function test_supported_unicode_characters() @@ -54,7 +54,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case $post = $this->create_topic(2, 'Test Topic 1', 'This is a test topic posted by the testing framework.'); $this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', "This is a test with these weird characters: \xF0\x9F\x84\x90 \xF0\x9F\x84\x91"); $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); - $this->assertContains("\xF0\x9F\x84\x90 \xF0\x9F\x84\x91", $crawler->text()); + $this->assertStringContainsString("\xF0\x9F\x84\x90 \xF0\x9F\x84\x91", $crawler->text()); } public function test_html_entities() @@ -64,7 +64,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case $post = $this->create_topic(2, 'Test Topic 1', 'This is a test topic posted by the testing framework.'); $this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', '😀'); $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); - $this->assertContains('😀', $crawler->text()); + $this->assertStringContainsString('😀', $crawler->text()); } public function test_quote() @@ -96,7 +96,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case $form->setValues(array('message' => 'Edited post')); $crawler = self::submit($form); - $this->assertContains('Edited post', $crawler->filter("#post_content{$post_id} .content")->text()); + $this->assertStringContainsString('Edited post', $crawler->filter("#post_content{$post_id} .content")->text()); } /** @@ -163,11 +163,11 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case $text_content = $crawler->filter('#p' . $post['post_id'])->text(); foreach ($contains[$quote_depth] as $contains_text) { - $this->assertContains($contains_text, $text_content); + $this->assertStringContainsString($contains_text, $text_content); } foreach ($not_contains[$quote_depth] as $not_contains_text) { - $this->assertNotContains($not_contains_text, $text_content); + $this->assertStringNotContainsString($not_contains_text, $text_content); } } } @@ -229,7 +229,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case 'message' => 'My post', )); $crawler = self::submit($form); - $this->assertContains( + $this->assertStringContainsString( 'My signature', $crawler->filter('#preview .signature')->html() ); @@ -274,7 +274,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case 'message' => $text, )); $crawler = self::submit($form); - $this->assertContains( + $this->assertStringContainsString( 'http://example.org/ tcp://localhost:22/ServiceName', $crawler->filter('#preview .content')->html() ); @@ -295,7 +295,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case 'message' => $text, )); $crawler = self::submit($form); - $this->assertContains( + $this->assertStringContainsString( 'http://example.org/ tcp://localhost:22/ServiceName', $crawler->filter('#preview .content')->html() ); diff --git a/tests/functional/private_messages_test.php b/tests/functional/private_messages_test.php index ce709524a9..6f94eac35c 100644 --- a/tests/functional/private_messages_test.php +++ b/tests/functional/private_messages_test.php @@ -32,7 +32,7 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case $form->setValues($values); $crawler = self::submit($form); - $this->assertContains($this->lang('CONFIG_UPDATED'), $crawler->filter('.successbox')->text()); + $this->assertStringContainsString($this->lang('CONFIG_UPDATED'), $crawler->filter('.successbox')->text()); } public function test_inbox_full() @@ -41,12 +41,12 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case $message_id = $this->create_private_message('Test private message #1', 'This is a test private message sent by the testing framework.', array(2)); $crawler = self::request('GET', "ucp.php?i=pm&mode=view&sid{$this->sid}&p={$message_id}"); - $this->assertContains($this->lang('UCP_PM_VIEW'), $crawler->filter('html')->text()); + $this->assertStringContainsString($this->lang('UCP_PM_VIEW'), $crawler->filter('html')->text()); $message_id = $this->create_private_message('Test private message #2', 'This is a test private message sent by the testing framework.', array(2)); $crawler = self::request('GET', "ucp.php?i=pm&mode=view&sid{$this->sid}&p={$message_id}"); - $this->assertContains($this->lang('NO_AUTH_READ_HOLD_MESSAGE'), $crawler->filter('html')->text()); + $this->assertStringContainsString($this->lang('NO_AUTH_READ_HOLD_MESSAGE'), $crawler->filter('html')->text()); } public function test_restore_config() @@ -64,7 +64,7 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case $form->setValues($values); $crawler = self::submit($form); - $this->assertContains($this->lang('CONFIG_UPDATED'), $crawler->filter('.successbox')->text()); + $this->assertStringContainsString($this->lang('CONFIG_UPDATED'), $crawler->filter('.successbox')->text()); } public function test_quote_post() @@ -105,6 +105,6 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case $crawler = self::request('GET', 'ucp.php?i=pm&mode=compose&action=forward&f=0&p=' . $message_id . '&sid=' . $this->sid); - $this->assertContains($expected, $crawler->filter('textarea#message')->text()); + $this->assertStringContainsString($expected, $crawler->filter('textarea#message')->text()); } } diff --git a/tests/functional/prune_shadow_topic_test.php b/tests/functional/prune_shadow_topic_test.php index 1d4bb02a95..8099d230d5 100644 --- a/tests/functional/prune_shadow_topic_test.php +++ b/tests/functional/prune_shadow_topic_test.php @@ -61,7 +61,7 @@ class phpbb_functional_prune_shadow_topic_test extends phpbb_functional_test_cas $this->post = $this->create_topic($this->data['forums']['Prune Shadow'], 'Prune Shadow #1', 'This is a test topic posted by the testing framework.'); $crawler = self::request('GET', "viewtopic.php?t={$this->post['topic_id']}&sid={$this->sid}"); - $this->assertContains('Prune Shadow #1', $crawler->filter('html')->text()); + $this->assertStringContainsString('Prune Shadow #1', $crawler->filter('html')->text()); $this->data['topics']['Prune Shadow #1'] = (int) $this->post['topic_id']; $this->data['posts']['Prune Shadow #1'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p'); @@ -79,7 +79,7 @@ class phpbb_functional_prune_shadow_topic_test extends phpbb_functional_test_cas $post2 = $this->create_post($this->data['forums']['Prune Shadow'], $this->post['topic_id'], 'Re: Prune Shadow #1-#2', 'This is a test post posted by the testing framework.'); $crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}"); - $this->assertContains('Re: Prune Shadow #1-#2', $crawler->filter('html')->text()); + $this->assertStringContainsString('Re: Prune Shadow #1-#2', $crawler->filter('html')->text()); $this->data['posts']['Re: Prune Shadow #1-#2'] = (int) $post2['post_id']; $this->assert_forum_details($this->data['forums']['Prune Shadow'], array( diff --git a/tests/functional/report_post_captcha_test.php b/tests/functional/report_post_captcha_test.php index 36a1a9ee4d..e4c2ff6ab7 100644 --- a/tests/functional/report_post_captcha_test.php +++ b/tests/functional/report_post_captcha_test.php @@ -21,11 +21,11 @@ class phpbb_functional_report_post_captcha_test extends phpbb_functional_test_ca $crawler = self::request('GET', 'app.php/post/1/report', array(), false); $this->assert_response_html(403); $this->add_lang('mcp'); - $this->assertContains($this->lang('USER_CANNOT_REPORT'), $crawler->filter('html')->text()); + $this->assertStringContainsString($this->lang('USER_CANNOT_REPORT'), $crawler->filter('html')->text()); $this->set_reporting_guest(1); $crawler = self::request('GET', 'app.php/post/1/report'); - $this->assertContains($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text()); + $this->assertStringContainsString($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text()); $this->set_reporting_guest(-1); } @@ -33,12 +33,12 @@ class phpbb_functional_report_post_captcha_test extends phpbb_functional_test_ca { $this->login(); $crawler = self::request('GET', 'app.php/post/1/report'); - $this->assertNotContains($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text()); + $this->assertStringNotContainsString($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text()); $this->add_lang('mcp'); $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); $crawler = self::submit($form); - $this->assertContains($this->lang('POST_REPORTED_SUCCESS'), $crawler->text()); + $this->assertStringContainsString($this->lang('POST_REPORTED_SUCCESS'), $crawler->text()); } protected function set_reporting_guest($report_post_allowed) diff --git a/tests/functional/subforum_test.php b/tests/functional/subforum_test.php index 6ce4f53c20..493c2053da 100644 --- a/tests/functional/subforum_test.php +++ b/tests/functional/subforum_test.php @@ -64,8 +64,8 @@ class phpbb_functional_subforum_test extends phpbb_functional_test_case public function test_display_subforums() { $crawler = self::request('GET', "index.php?sid={$this->sid}"); - $this->assertContains('Subforum Test #1.1', $crawler->html()); - $this->assertContains('Subforum Test #1.1.1', $crawler->html()); + $this->assertStringContainsString('Subforum Test #1.1', $crawler->html()); + $this->assertStringContainsString('Subforum Test #1.1.1', $crawler->html()); } /** @@ -85,8 +85,8 @@ class phpbb_functional_subforum_test extends phpbb_functional_test_case self::submit($form); $crawler = self::request('GET', "index.php?sid={$this->sid}"); - $this->assertContains('Subforum Test #1.1', $crawler->html()); - $this->assertNotContains('Subforum Test #1.1.1', $crawler->html()); + $this->assertStringContainsString('Subforum Test #1.1', $crawler->html()); + $this->assertStringNotContainsString('Subforum Test #1.1.1', $crawler->html()); } protected function get_forum_id($forum_name) diff --git a/tests/functional/ucp_groups_test.php b/tests/functional/ucp_groups_test.php index 445c124158..f8e801dcf7 100644 --- a/tests/functional/ucp_groups_test.php +++ b/tests/functional/ucp_groups_test.php @@ -51,7 +51,7 @@ class phpbb_functional_ucp_groups_test extends phpbb_functional_common_groups_te $form = $this->get_group_manage_form(); $teampage_settings = $this->get_teampage_settings(); $crawler = self::submit($form); - $this->assertContains($this->lang('GROUP_UPDATED'), $crawler->text()); + $this->assertStringContainsString($this->lang('GROUP_UPDATED'), $crawler->text()); $this->assertEquals($teampage_settings, $this->get_teampage_settings()); } diff --git a/tests/functional/user_password_reset_test.php b/tests/functional/user_password_reset_test.php index a97300b9ee..e912b8ce08 100644 --- a/tests/functional/user_password_reset_test.php +++ b/tests/functional/user_password_reset_test.php @@ -25,7 +25,7 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca // test without email $crawler = self::request('GET', "ucp.php?mode=sendpassword&sid={$this->sid}"); - $this->assertContains('app.php/user/forgot_password', $crawler->getUri()); + $this->assertStringContainsString('app.php/user/forgot_password', $crawler->getUri()); $form = $crawler->selectButton('submit')->form(); $crawler = self::submit($form); $this->assertContainsLang('NO_EMAIL_USER', $crawler->text()); @@ -143,11 +143,11 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca { $this->add_lang('ucp'); $crawler = self::request('GET', 'ucp.php'); - $this->assertContains($this->lang('LOGIN_EXPLAIN_UCP'), $crawler->filter('html')->text()); + $this->assertStringContainsString($this->lang('LOGIN_EXPLAIN_UCP'), $crawler->filter('html')->text()); $form = $crawler->selectButton($this->lang('LOGIN'))->form(); $crawler = self::submit($form, array('username' => 'reset-password-test-user', 'password' => 'reset-password-test-user')); - $this->assertNotContains($this->lang('LOGIN'), $crawler->filter('.navbar')->text()); + $this->assertStringNotContainsString($this->lang('LOGIN'), $crawler->filter('.navbar')->text()); $cookies = self::$cookieJar->all(); @@ -163,12 +163,12 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca $this->logout(); $crawler = self::request('GET', 'ucp.php'); - $this->assertContains($this->lang('LOGIN_EXPLAIN_UCP'), $crawler->filter('html')->text()); + $this->assertStringContainsString($this->lang('LOGIN_EXPLAIN_UCP'), $crawler->filter('html')->text()); $form = $crawler->selectButton($this->lang('LOGIN'))->form(); // Try logging in with the old password $crawler = self::submit($form, array('username' => 'reset-password-test-user', 'password' => 'reset-password-test-userreset-password-test-user')); - $this->assertContains($this->lang('LOGIN_ERROR_PASSWORD', '', ''), $crawler->filter('html')->text()); + $this->assertStringContainsString($this->lang('LOGIN_ERROR_PASSWORD', '', ''), $crawler->filter('html')->text()); } /** diff --git a/tests/functional/viewforum_paging_test.php b/tests/functional/viewforum_paging_test.php index 4a574bebbb..2ba29cecc6 100644 --- a/tests/functional/viewforum_paging_test.php +++ b/tests/functional/viewforum_paging_test.php @@ -127,8 +127,8 @@ class viewforum_paging_test extends phpbb_functional_test_case $this->assertEquals(2, $crawler->filter('div.pagination')->count()); $top_pagination = $crawler->filter('div.pagination')->eq(0); $this->assertEquals(3, $top_pagination->filter('li')->count(), 'Number of pagination items on page 1 does not match'); - $this->assertContains('1', $top_pagination->filter('li')->eq(0)->text()); - $this->assertContains('2', $top_pagination->filter('li')->eq(1)->text()); + $this->assertStringContainsString('1', $top_pagination->filter('li')->eq(0)->text()); + $this->assertStringContainsString('2', $top_pagination->filter('li')->eq(1)->text()); $this->assertContainsLang('NEXT', $top_pagination->filter('li')->eq(2)->text()); } @@ -157,8 +157,8 @@ class viewforum_paging_test extends phpbb_functional_test_case $top_pagination = $crawler->filter('div.pagination')->eq(0); $this->assertEquals(3, $top_pagination->filter('li')->count(), 'Number of pagination items on page 2 does not match'); $this->assertContainsLang('PREVIOUS', $top_pagination->filter('li')->eq(0)->text()); - $this->assertContains('1', $top_pagination->filter('li')->eq(1)->text()); - $this->assertContains('2', $top_pagination->filter('li')->eq(2)->text()); + $this->assertStringContainsString('1', $top_pagination->filter('li')->eq(1)->text()); + $this->assertStringContainsString('2', $top_pagination->filter('li')->eq(2)->text()); } protected function assert_forum_details($forum_id, $details, $additional_error_message = '') diff --git a/tests/functional/visibility_disapprove_test.php b/tests/functional/visibility_disapprove_test.php index 6f6edba422..cb38f64aed 100644 --- a/tests/functional/visibility_disapprove_test.php +++ b/tests/functional/visibility_disapprove_test.php @@ -60,7 +60,7 @@ class phpbb_functional_visibility_disapprove_test extends phpbb_functional_test_ $post = $this->create_topic($this->data['forums']['Disapprove Test #1'], 'Disapprove Test Topic #1', 'This is a test topic posted by the testing framework.'); $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); - $this->assertContains('Disapprove Test Topic #1', $crawler->filter('html')->text()); + $this->assertStringContainsString('Disapprove Test Topic #1', $crawler->filter('html')->text()); $this->data['topics']['Disapprove Test Topic #1'] = (int) $post['topic_id']; $this->data['posts']['Disapprove Test Topic #1'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p'); @@ -83,7 +83,7 @@ class phpbb_functional_visibility_disapprove_test extends phpbb_functional_test_ $post2 = $this->create_post($this->data['forums']['Disapprove Test #1'], $post['topic_id'], 'Re: Disapprove Test Topic #1-#2', 'This is a test post posted by the testing framework.', array(), 'POST_STORED_MOD'); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Disapprove Test Topic #1']}&sid={$this->sid}"); - $this->assertNotContains('Re: Disapprove Test Topic #1-#2', $crawler->filter('html')->text()); + $this->assertStringNotContainsString('Re: Disapprove Test Topic #1-#2', $crawler->filter('html')->text()); $this->assert_forum_details($this->data['forums']['Disapprove Test #1'], array( 'forum_posts_approved' => 1, @@ -99,7 +99,7 @@ class phpbb_functional_visibility_disapprove_test extends phpbb_functional_test_ $post = $this->create_topic($this->data['forums']['Disapprove Test #1'], 'Disapprove Test Topic #2', 'This is a test topic posted by the testing framework.', array(), 'POST_STORED_MOD'); $crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Disapprove Test #1']}&sid={$this->sid}"); - $this->assertNotContains('Disapprove Test Topic #2', $crawler->filter('html')->text()); + $this->assertStringNotContainsString('Disapprove Test Topic #2', $crawler->filter('html')->text()); $this->assert_forum_details($this->data['forums']['Disapprove Test #1'], array( 'forum_posts_approved' => 1, @@ -155,8 +155,8 @@ class phpbb_functional_visibility_disapprove_test extends phpbb_functional_test_ $this->add_lang('viewtopic'); $this->add_lang('mcp'); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Disapprove Test Topic #1']}&sid={$this->sid}"); - $this->assertContains('Disapprove Test Topic #1', $crawler->filter('html')->text()); - $this->assertContains('Re: Disapprove Test Topic #1-#2', $crawler->filter('html')->text()); + $this->assertStringContainsString('Disapprove Test Topic #1', $crawler->filter('html')->text()); + $this->assertStringContainsString('Re: Disapprove Test Topic #1-#2', $crawler->filter('html')->text()); $form = $crawler->selectButton($this->lang('DISAPPROVE'))->form(); $crawler = self::submit($form); @@ -176,11 +176,11 @@ class phpbb_functional_visibility_disapprove_test extends phpbb_functional_test_ $link = $crawler->selectLink($this->lang('RETURN_PAGE', '', ''))->link(); $link_url = $link->getUri(); - $this->assertContains('viewtopic.php?f=' . $this->data['forums']['Disapprove Test #1'] . '&t=' . $this->data['topics']['Disapprove Test Topic #1'], $link_url); + $this->assertStringContainsString('viewtopic.php?f=' . $this->data['forums']['Disapprove Test #1'] . '&t=' . $this->data['topics']['Disapprove Test Topic #1'], $link_url); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Disapprove Test Topic #1']}&sid={$this->sid}"); - $this->assertContains('Disapprove Test Topic #1', $crawler->filter('html')->text()); - $this->assertNotContains('Re: Disapprove Test Topic #1-#2', $crawler->filter('html')->text()); + $this->assertStringContainsString('Disapprove Test Topic #1', $crawler->filter('html')->text()); + $this->assertStringNotContainsString('Re: Disapprove Test Topic #1-#2', $crawler->filter('html')->text()); } public function test_disapprove_topic() @@ -214,7 +214,7 @@ class phpbb_functional_visibility_disapprove_test extends phpbb_functional_test_ $this->add_lang('viewtopic'); $this->add_lang('mcp'); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Disapprove Test Topic #2']}&sid={$this->sid}"); - $this->assertContains('Disapprove Test Topic #2', $crawler->filter('html')->text()); + $this->assertStringContainsString('Disapprove Test Topic #2', $crawler->filter('html')->text()); $form = $crawler->selectButton($this->lang('DISAPPROVE'))->form(); $crawler = self::submit($form); @@ -234,11 +234,11 @@ class phpbb_functional_visibility_disapprove_test extends phpbb_functional_test_ $link = $crawler->selectLink($this->lang('RETURN_PAGE', '', ''))->link(); $link_url = $link->getUri(); - $this->assertContains('viewforum.php?f=' . $this->data['forums']['Disapprove Test #1'], $link_url); + $this->assertStringContainsString('viewforum.php?f=' . $this->data['forums']['Disapprove Test #1'], $link_url); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Disapprove Test Topic #2']}&sid={$this->sid}", array(), false); self::assert_response_html(404); - $this->assertNotContains('Disapprove Test Topic #2', $crawler->filter('html')->text()); + $this->assertStringNotContainsString('Disapprove Test Topic #2', $crawler->filter('html')->text()); } protected function assert_forum_details($forum_id, $details, $additional_error_message = '') diff --git a/tests/functional/visibility_reapprove_test.php b/tests/functional/visibility_reapprove_test.php index 6a6e2edf18..555e6d7f9d 100644 --- a/tests/functional/visibility_reapprove_test.php +++ b/tests/functional/visibility_reapprove_test.php @@ -60,7 +60,7 @@ class phpbb_functional_visibility_reapprove_test extends phpbb_functional_test_c $post = $this->create_topic($this->data['forums']['Reapprove Test #1'], 'Reapprove Test Topic #1', 'This is a test topic posted by the testing framework.'); $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); - $this->assertContains('Reapprove Test Topic #1', $crawler->filter('h2')->text()); + $this->assertStringContainsString('Reapprove Test Topic #1', $crawler->filter('h2')->text()); $this->data['topics']['Reapprove Test Topic #1'] = (int) $post['topic_id']; $this->data['posts']['Reapprove Test Topic #1'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p'); @@ -83,7 +83,7 @@ class phpbb_functional_visibility_reapprove_test extends phpbb_functional_test_c $post2 = $this->create_post($this->data['forums']['Reapprove Test #1'], $post['topic_id'], 'Re: Reapprove Test Topic #1-#2', 'This is a test post posted by the testing framework.', array(), 'POST_STORED_MOD'); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #1']}&sid={$this->sid}"); - $this->assertNotContains('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text()); + $this->assertStringNotContainsString('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text()); $this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array( 'forum_posts_approved' => 1, @@ -99,7 +99,7 @@ class phpbb_functional_visibility_reapprove_test extends phpbb_functional_test_c $post = $this->create_topic($this->data['forums']['Reapprove Test #1'], 'Reapprove Test Topic #2', 'This is a test topic posted by the testing framework.', array(), 'POST_STORED_MOD'); $crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Reapprove Test #1']}&sid={$this->sid}"); - $this->assertNotContains('Reapprove Test Topic #2', $crawler->filter('html')->text()); + $this->assertStringNotContainsString('Reapprove Test Topic #2', $crawler->filter('html')->text()); $this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array( 'forum_posts_approved' => 1, @@ -146,8 +146,8 @@ class phpbb_functional_visibility_reapprove_test extends phpbb_functional_test_c $this->add_lang('viewtopic'); $this->add_lang('mcp'); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #1']}&sid={$this->sid}"); - $this->assertContains('Reapprove Test Topic #1', $crawler->filter('h2')->text()); - $this->assertContains('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text()); + $this->assertStringContainsString('Reapprove Test Topic #1', $crawler->filter('h2')->text()); + $this->assertStringContainsString('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text()); $form = $crawler->selectButton($this->lang('APPROVE'))->form(); $crawler = self::submit($form); @@ -167,11 +167,11 @@ class phpbb_functional_visibility_reapprove_test extends phpbb_functional_test_c $link = $crawler->selectLink($this->lang('RETURN_PAGE', '', ''))->link(); $link_url = $link->getUri(); - $this->assertContains('viewtopic.php?f=' . $this->data['forums']['Reapprove Test #1'] . '&t=' . $this->data['topics']['Reapprove Test Topic #1'], $link_url); + $this->assertStringContainsString('viewtopic.php?f=' . $this->data['forums']['Reapprove Test #1'] . '&t=' . $this->data['topics']['Reapprove Test Topic #1'], $link_url); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #1']}&sid={$this->sid}"); - $this->assertContains('Reapprove Test Topic #1', $crawler->filter('h2')->text()); - $this->assertContains('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text()); + $this->assertStringContainsString('Reapprove Test Topic #1', $crawler->filter('h2')->text()); + $this->assertStringContainsString('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text()); } public function test_approve_topic() @@ -206,7 +206,7 @@ class phpbb_functional_visibility_reapprove_test extends phpbb_functional_test_c $this->add_lang('viewtopic'); $this->add_lang('mcp'); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #2']}&sid={$this->sid}"); - $this->assertContains('Reapprove Test Topic #2', $crawler->filter('h2')->text()); + $this->assertStringContainsString('Reapprove Test Topic #2', $crawler->filter('h2')->text()); $form = $crawler->selectButton($this->lang('APPROVE'))->form(); $crawler = self::submit($form); @@ -226,10 +226,10 @@ class phpbb_functional_visibility_reapprove_test extends phpbb_functional_test_c $link = $crawler->selectLink($this->lang('RETURN_PAGE', '', ''))->link(); $link_url = $link->getUri(); - $this->assertContains('viewtopic.php?f=' . $this->data['forums']['Reapprove Test #1'], $link_url); + $this->assertStringContainsString('viewtopic.php?f=' . $this->data['forums']['Reapprove Test #1'], $link_url); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #2']}&sid={$this->sid}"); - $this->assertContains('Reapprove Test Topic #2', $crawler->filter('h2')->text()); + $this->assertStringContainsString('Reapprove Test Topic #2', $crawler->filter('h2')->text()); } public function test_edit_posts() @@ -273,8 +273,8 @@ class phpbb_functional_visibility_reapprove_test extends phpbb_functional_test_c $this->submit_post($posting_url, 'EDIT_POST', $form_data, 'POST_EDITED_MOD'); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #1']}&sid={$this->sid}"); - $this->assertNotContains('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text()); - $this->assertNotContains('Post edited by testing framework', $crawler->filter('#page-body')->text()); + $this->assertStringNotContainsString('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text()); + $this->assertStringNotContainsString('Post edited by testing framework', $crawler->filter('#page-body')->text()); $this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array( 'forum_posts_approved' => 2, @@ -297,8 +297,8 @@ class phpbb_functional_visibility_reapprove_test extends phpbb_functional_test_c $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #2']}&sid={$this->sid}", array(), false); self::assert_response_html(404); - $this->assertNotContains('Reapprove Test Topic #2', $crawler->filter('#page-body')->text()); - $this->assertNotContains('Post edited by testing framework', $crawler->filter('#page-body')->text()); + $this->assertStringNotContainsString('Reapprove Test Topic #2', $crawler->filter('#page-body')->text()); + $this->assertStringNotContainsString('Post edited by testing framework', $crawler->filter('#page-body')->text()); $this->assert_forum_details($this->data['forums']['Reapprove Test #1'], array( 'forum_posts_approved' => 1, @@ -314,8 +314,8 @@ class phpbb_functional_visibility_reapprove_test extends phpbb_functional_test_c $this->login(); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Reapprove Test Topic #1']}&sid={$this->sid}"); - $this->assertContains('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text()); - $this->assertContains('Post edited by testing framework', $crawler->filter('#page-body')->text()); + $this->assertStringContainsString('Re: Reapprove Test Topic #1-#2', $crawler->filter('#page-body')->text()); + $this->assertStringContainsString('Post edited by testing framework', $crawler->filter('#page-body')->text()); } public function test_approve_post_again() diff --git a/tests/functional/visibility_softdelete_test.php b/tests/functional/visibility_softdelete_test.php index fd994361a5..4eba77ba1b 100644 --- a/tests/functional/visibility_softdelete_test.php +++ b/tests/functional/visibility_softdelete_test.php @@ -81,7 +81,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_ $post = $this->create_topic($this->data['forums']['Soft Delete #1'], 'Soft Delete Topic #1', 'This is a test topic posted by the testing framework.'); $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); - $this->assertContains('Soft Delete Topic #1', $crawler->filter('html')->text()); + $this->assertStringContainsString('Soft Delete Topic #1', $crawler->filter('html')->text()); $this->data['topics']['Soft Delete Topic #1'] = (int) $post['topic_id']; $this->data['posts']['Soft Delete Topic #1'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p'); @@ -99,7 +99,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_ $post2 = $this->create_post($this->data['forums']['Soft Delete #1'], $post['topic_id'], 'Re: Soft Delete Topic #1-#2', 'This is a test post posted by the testing framework.'); $crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}"); - $this->assertContains('Re: Soft Delete Topic #1-#2', $crawler->filter('html')->text()); + $this->assertStringContainsString('Re: Soft Delete Topic #1-#2', $crawler->filter('html')->text()); $this->data['posts']['Re: Soft Delete Topic #1-#2'] = (int) $post2['post_id']; $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( @@ -116,7 +116,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_ $post3 = $this->create_post($this->data['forums']['Soft Delete #1'], $post['topic_id'], 'Re: Soft Delete Topic #1-#3', 'This is another test post posted by the testing framework.'); $crawler = self::request('GET', "viewtopic.php?p={$post3['post_id']}&sid={$this->sid}"); - $this->assertContains('Re: Soft Delete Topic #1-#3', $crawler->filter('html')->text()); + $this->assertStringContainsString('Re: Soft Delete Topic #1-#3', $crawler->filter('html')->text()); $this->data['posts']['Re: Soft Delete Topic #1-#3'] = (int) $post3['post_id']; $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( @@ -177,7 +177,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_ ), 'after softdelete'); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); - $this->assertContains($this->lang('POST_DISPLAY', '', ''), $crawler->text()); + $this->assertStringContainsString($this->lang('POST_DISPLAY', '', ''), $crawler->text()); } public function test_softdelete_post_no_m_delete() @@ -227,7 +227,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_ ), 'after softdelete without m_delete'); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); - $this->assertContains($this->lang('POST_DISPLAY', '', ''), $crawler->text()); + $this->assertStringContainsString($this->lang('POST_DISPLAY', '', ''), $crawler->text()); } public function test_move_softdeleted_post() @@ -278,8 +278,8 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_ $this->assertContainsLang('TOPIC_MOVED_SUCCESS', $crawler->text()); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); - $this->assertContains('Soft Delete #2', $crawler->filter('.navlinks')->text()); - $this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text()); + $this->assertStringContainsString('Soft Delete #2', $crawler->filter('.navlinks')->text()); + $this->assertStringContainsString('Soft Delete Topic #1', $crawler->filter('h2')->text()); $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( 'forum_posts_approved' => 0, @@ -350,8 +350,8 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_ $this->assertContainsLang('TOPIC_DELETED_SUCCESS', $crawler->text()); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); - $this->assertContains('Soft Delete #2', $crawler->filter('.navlinks')->text()); - $this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text()); + $this->assertStringContainsString('Soft Delete #2', $crawler->filter('.navlinks')->text()); + $this->assertStringContainsString('Soft Delete Topic #1', $crawler->filter('h2')->text()); $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( 'forum_posts_approved' => 0, @@ -422,8 +422,8 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_ $this->assertContainsLang('TOPIC_MOVED_SUCCESS', $crawler->text()); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); - $this->assertContains('Soft Delete #1', $crawler->filter('.navlinks')->text()); - $this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text()); + $this->assertStringContainsString('Soft Delete #1', $crawler->filter('.navlinks')->text()); + $this->assertStringContainsString('Soft Delete Topic #1', $crawler->filter('h2')->text()); $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( 'forum_posts_approved' => 0, @@ -496,8 +496,8 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_ $this->assertContainsLang('POST_RESTORED_SUCCESS', $crawler->text()); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); - $this->assertContains('Soft Delete #1', $crawler->filter('.navlinks')->text()); - $this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text()); + $this->assertStringContainsString('Soft Delete #1', $crawler->filter('.navlinks')->text()); + $this->assertStringContainsString('Soft Delete Topic #1', $crawler->filter('h2')->text()); $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( 'forum_posts_approved' => 1, @@ -575,8 +575,8 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_ $this->assertContainsLang('TOPIC_SPLIT_SUCCESS', $crawler->text()); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); - $this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text()); - $this->assertNotContains('Re: Soft Delete Topic #1-#2', $crawler->text()); + $this->assertStringContainsString('Soft Delete Topic #1', $crawler->filter('h2')->text()); + $this->assertStringNotContainsString('Re: Soft Delete Topic #1-#2', $crawler->text()); $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( 'forum_posts_approved' => 1, @@ -601,7 +601,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_ // Assert new topic title is indexed as well $this->add_lang('search'); self::request('GET', "search.php?keywords=bang&sid={$this->sid}"); - $this->assertContains(sprintf($this->lang['FOUND_SEARCH_MATCHES'][1], 1), self::get_content()); + $this->assertStringContainsString(sprintf($this->lang['FOUND_SEARCH_MATCHES'][1], 1), self::get_content()); } public function test_move_topic_back() @@ -689,7 +689,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_ $this->assertContainsLang('POSTS_MERGED_SUCCESS', $crawler->text()); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); - $this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text()); + $this->assertStringContainsString('Soft Delete Topic #1', $crawler->filter('h2')->text()); $this->assertContainsLang('POST_DELETED_ACTION', $crawler->filter('body')->text()); $this->assertContainsLang('BOOKMARK_TOPIC_REMOVE', $crawler->filter('body')->text()); diff --git a/tests/functional/visibility_unapproved_posts_test.php b/tests/functional/visibility_unapproved_posts_test.php index 9f6491d1d8..f44d5186c4 100644 --- a/tests/functional/visibility_unapproved_posts_test.php +++ b/tests/functional/visibility_unapproved_posts_test.php @@ -60,7 +60,7 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_ $post = $this->create_topic($this->data['forums']['Unapproved Posts Test #1'], 'Unapproved Posts Test Topic #1', 'This is a test topic posted by the testing framework.'); $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); - $this->assertContains('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text()); + $this->assertStringContainsString('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text()); $this->data['topics']['Unapproved Posts Test Topic #1'] = (int) $post['topic_id']; $this->data['posts']['Unapproved Posts Test Topic #1'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p'); @@ -83,7 +83,7 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_ $post2 = $this->create_post($this->data['forums']['Unapproved Posts Test #1'], $post['topic_id'], 'Re: Unapproved Posts Test Topic #1-#2', 'This is a test post posted by the testing framework.', [], 'POST_STORED_MOD'); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #1']}&sid={$this->sid}"); - $this->assertNotContains('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text()); + $this->assertStringNotContainsString('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text()); $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], [ 'forum_posts_approved' => 1, @@ -99,7 +99,7 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_ $post = $this->create_topic($this->data['forums']['Unapproved Posts Test #1'], 'Unapproved Posts Test Topic #2', 'This is a test topic posted by the testing framework.', [], 'POST_STORED_MOD'); $crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Unapproved Posts Test #1']}&sid={$this->sid}"); - $this->assertNotContains('Unapproved Posts Test Topic #2', $crawler->filter('html')->text()); + $this->assertStringNotContainsString('Unapproved Posts Test Topic #2', $crawler->filter('html')->text()); $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], [ 'forum_posts_approved' => 1, @@ -149,13 +149,13 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_ // should be able to see topic 1 but not unapproved post $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #1']}&sid={$this->sid}"); - $this->assertContains('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text()); - $this->assertNotContains('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text()); - $this->assertNotContains('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text()); + $this->assertStringContainsString('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text()); + $this->assertStringNotContainsString('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text()); + $this->assertStringNotContainsString('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text()); // should not be able to see topic 2 $crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Unapproved Posts Test #1']}&sid={$this->sid}"); - $this->assertNotContains('Unapproved Posts Test Topic #2', $crawler->filter('html')->text()); + $this->assertStringNotContainsString('Unapproved Posts Test Topic #2', $crawler->filter('html')->text()); $this->logout(); // another user @@ -166,13 +166,13 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_ // should be able to see topic 1 but not unapproved post $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #1']}&sid={$this->sid}"); - $this->assertContains('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text()); - $this->assertNotContains('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text()); - $this->assertNotContains('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text()); + $this->assertStringContainsString('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text()); + $this->assertStringNotContainsString('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text()); + $this->assertStringNotContainsString('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text()); // should not be able to see topic 2 $crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Unapproved Posts Test #1']}&sid={$this->sid}"); - $this->assertNotContains('Unapproved Posts Test Topic #2', $crawler->filter('html')->text()); + $this->assertStringNotContainsString('Unapproved Posts Test Topic #2', $crawler->filter('html')->text()); } public function test_view_unapproved_post_enabled() @@ -212,18 +212,18 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_ // should be able to see topic 1 and unapproved post $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #1']}&sid={$this->sid}"); - $this->assertContains('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text()); - $this->assertContains('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text()); - $this->assertContains('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text()); + $this->assertStringContainsString('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text()); + $this->assertStringContainsString('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text()); + $this->assertStringContainsString('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text()); // should be able to see topic 2 $crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Unapproved Posts Test #1']}&sid={$this->sid}"); - $this->assertContains('Unapproved Posts Test Topic #2', $crawler->filter('html')->text()); + $this->assertStringContainsString('Unapproved Posts Test Topic #2', $crawler->filter('html')->text()); // should be able to see post in topic 2 $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #2']}&sid={$this->sid}"); - $this->assertContains('Unapproved Posts Test Topic #2', $crawler->filter('#page-body')->text()); - $this->assertContains('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text()); + $this->assertStringContainsString('Unapproved Posts Test Topic #2', $crawler->filter('#page-body')->text()); + $this->assertStringContainsString('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text()); $this->logout(); // another user @@ -235,13 +235,13 @@ class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_ // should be able to see topic 1 but not unapproved post $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Unapproved Posts Test Topic #1']}&sid={$this->sid}"); - $this->assertContains('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text()); - $this->assertNotContains('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text()); - $this->assertNotContains('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text()); + $this->assertStringContainsString('Unapproved Posts Test Topic #1', $crawler->filter('h2')->text()); + $this->assertStringNotContainsString('Re: Unapproved Posts Test Topic #1-#2', $crawler->filter('#page-body')->text()); + $this->assertStringNotContainsString('This post is not visible to other users until it has been approved', $crawler->filter('#page-body')->text()); // should not be able to see topic 2 $crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Unapproved Posts Test #1']}&sid={$this->sid}"); - $this->assertNotContains('Unapproved Posts Test Topic #2', $crawler->filter('html')->text()); + $this->assertStringNotContainsString('Unapproved Posts Test Topic #2', $crawler->filter('html')->text()); $this->logout(); } diff --git a/tests/functional/visit_installer_test.php b/tests/functional/visit_installer_test.php index b4a75c0b51..742007fa5f 100644 --- a/tests/functional/visit_installer_test.php +++ b/tests/functional/visit_installer_test.php @@ -19,12 +19,12 @@ class phpbb_functional_visit_installer_test extends phpbb_functional_test_case public function test_visit_installer() { self::request('GET', 'install/', [], false); - $this->assertContains('', $this->get_content()); + $this->assertStringContainsString('', $this->get_content()); self::request('GET', 'install/index.html', [], false); - $this->assertContains('', $this->get_content()); + $this->assertStringContainsString('', $this->get_content()); self::request('GET', 'install/app.php'); - $this->assertContains('installation system', $this->get_content()); + $this->assertStringContainsString('installation system', $this->get_content()); } } diff --git a/tests/functions/get_remote_file_test.php b/tests/functions/get_remote_file_test.php index b783e3c297..c0330d01f8 100644 --- a/tests/functions/get_remote_file_test.php +++ b/tests/functions/get_remote_file_test.php @@ -74,7 +74,7 @@ class phpbb_functions_get_remote_file extends phpbb_test_case 'Failed asserting that the second line of the version file is a valid URL.' ); - $this->assertContains('http', $lines[1]); - $this->assertContains('phpbb.com', $lines[1], '', true); + $this->assertStringContainsString('http', $lines[1]); + $this->assertStringContainsString('phpbb.com', $lines[1], '', true); } } diff --git a/tests/network/ftp_fsock_pasv_epsv_test.php b/tests/network/ftp_fsock_pasv_epsv_test.php index 4ec21b6f75..876df09d1b 100644 --- a/tests/network/ftp_fsock_pasv_epsv_test.php +++ b/tests/network/ftp_fsock_pasv_epsv_test.php @@ -55,7 +55,7 @@ class phpbb_network_ftp_fsock_pasv_epsv_test extends phpbb_test_case { $this->markTestSkipped("Failed to connect to $hostname: $result"); } - $this->assertContains('debian', $o->_ls()); + $this->assertStringContainsString('debian', $o->_ls()); $o->_close(); } diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index b55f4c8b05..4aabebebd2 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -793,7 +793,7 @@ class phpbb_functional_test_case extends phpbb_test_case $this->add_lang('ucp'); $crawler = self::request('GET', 'ucp.php'); - $this->assertContains($this->lang('LOGIN_EXPLAIN_UCP'), $crawler->filter('html')->text()); + $this->assertStringContainsString($this->lang('LOGIN_EXPLAIN_UCP'), $crawler->filter('html')->text()); $form = $crawler->selectButton($this->lang('LOGIN'))->form(); if ($autologin) @@ -801,7 +801,7 @@ class phpbb_functional_test_case extends phpbb_test_case $form['autologin']->tick(); } $crawler = self::submit($form, array('username' => $username, 'password' => $username . $username)); - $this->assertNotContains($this->lang('LOGIN'), $crawler->filter('.navbar')->text()); + $this->assertStringNotContainsString($this->lang('LOGIN'), $crawler->filter('.navbar')->text()); $cookies = self::$cookieJar->all(); @@ -820,7 +820,7 @@ class phpbb_functional_test_case extends phpbb_test_case $this->add_lang('ucp'); $crawler = self::request('GET', 'ucp.php?sid=' . $this->sid . '&mode=logout'); - $this->assertContains($this->lang('REGISTER'), $crawler->filter('.navbar')->text()); + $this->assertStringContainsString($this->lang('REGISTER'), $crawler->filter('.navbar')->text()); unset($this->sid); } @@ -841,7 +841,7 @@ class phpbb_functional_test_case extends phpbb_test_case } $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid); - $this->assertContains($this->lang('LOGIN_ADMIN_CONFIRM'), $crawler->filter('html')->text()); + $this->assertStringContainsString($this->lang('LOGIN_ADMIN_CONFIRM'), $crawler->filter('html')->text()); $form = $crawler->selectButton($this->lang('LOGIN'))->form(); @@ -850,7 +850,7 @@ class phpbb_functional_test_case extends phpbb_test_case if (strpos($field, 'password_') === 0) { $crawler = self::submit($form, array('username' => $username, $field => $username . $username)); - $this->assertContains($this->lang('ADMIN_PANEL'), $crawler->filter('h1')->text()); + $this->assertStringContainsString($this->lang('ADMIN_PANEL'), $crawler->filter('h1')->text()); $cookies = self::$cookieJar->all(); @@ -940,7 +940,7 @@ class phpbb_functional_test_case extends phpbb_test_case */ public function assertContainsLang($needle, $haystack, $message = '') { - $this->assertContains(html_entity_decode($this->lang($needle), ENT_QUOTES), $haystack, $message); + $this->assertStringContainsString(html_entity_decode($this->lang($needle), ENT_QUOTES), $haystack, $message); } /** @@ -952,7 +952,7 @@ class phpbb_functional_test_case extends phpbb_test_case */ public function assertNotContainsLang($needle, $haystack, $message = '') { - $this->assertNotContains(html_entity_decode($this->lang($needle), ENT_QUOTES), $haystack, $message); + $this->assertStringNotContainsString(html_entity_decode($this->lang($needle), ENT_QUOTES), $haystack, $message); } /* @@ -967,7 +967,7 @@ class phpbb_functional_test_case extends phpbb_test_case { // Any output before the doc type means there was an error $content = self::get_content(); - self::assertNotContains('[phpBB Debug]', $content); + self::assertStringNotContainsString('[phpBB Debug]', $content); self::assertStringStartsWith('assertContains($expected, $crawler->filter('html')->text()); + $this->assertStringContainsString($expected, $crawler->filter('html')->text()); } return null; } @@ -1212,7 +1212,7 @@ class phpbb_functional_test_case extends phpbb_test_case $crawler = self::submit_message($posting_url, 'POST_NEW_PM', $form_data); - $this->assertContains($this->lang('MESSAGE_STORED'), $crawler->filter('html')->text()); + $this->assertStringContainsString($this->lang('MESSAGE_STORED'), $crawler->filter('html')->text()); $url = $crawler->selectLink($this->lang('VIEW_PRIVATE_MESSAGE', '', ''))->link()->getUri(); return $this->get_parameter_from_link($url, 'p'); @@ -1236,7 +1236,7 @@ class phpbb_functional_test_case extends phpbb_test_case self::$last_post_timestamp = time(); $crawler = self::request('GET', $posting_url); - $this->assertContains($this->lang($posting_contains), $crawler->filter('html')->text()); + $this->assertStringContainsString($this->lang($posting_contains), $crawler->filter('html')->text()); if (!empty($form_data['upload_files'])) { From fb62d220139c38b424f5b269ffc536268302cb79 Mon Sep 17 00:00:00 2001 From: rxu Date: Mon, 13 Jul 2020 14:06:04 +0700 Subject: [PATCH 02/17] [ticket/16549] Add void return type of template methods PHPBB3-16549 --- tests/cache/apcu_driver_test.php | 2 +- tests/cache/memcached_test.php | 2 +- tests/cache/redis_driver_test.php | 2 +- tests/extension/extension_base_test.php | 2 +- tests/filesystem/realpath_test.php | 2 +- tests/functional/extension_acp_test.php | 4 ++-- tests/functional/extension_controller_test.php | 4 ++-- tests/functional/extension_global_lang_test.php | 4 ++-- tests/functional/extension_module_test.php | 4 ++-- tests/functional/extension_permission_lang_test.php | 4 ++-- tests/functional/metadata_manager_test.php | 4 ++-- tests/functions_content/get_username_string_test.php | 2 +- tests/group/helper_test_case.php | 2 +- tests/lint_test.php | 2 +- tests/network/ftp_fsock_pasv_epsv_test.php | 2 +- tests/template/template_test_case.php | 2 +- tests/test_framework/phpbb_database_test_case.php | 4 ++-- tests/test_framework/phpbb_functional_test_case.php | 2 +- tests/text_processing/message_parser_test.php | 4 ++-- 19 files changed, 27 insertions(+), 27 deletions(-) diff --git a/tests/cache/apcu_driver_test.php b/tests/cache/apcu_driver_test.php index 34bcf8f844..86ae880dab 100644 --- a/tests/cache/apcu_driver_test.php +++ b/tests/cache/apcu_driver_test.php @@ -26,7 +26,7 @@ class phpbb_cache_apcu_driver_test extends phpbb_cache_common_test_case return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); } - static public function setUpBeforeClass() + static public function setUpBeforeClass(): void { if (!extension_loaded('apcu')) { diff --git a/tests/cache/memcached_test.php b/tests/cache/memcached_test.php index 650b72ea18..14499e7423 100644 --- a/tests/cache/memcached_test.php +++ b/tests/cache/memcached_test.php @@ -22,7 +22,7 @@ class phpbb_cache_memcached_driver_test extends \phpbb_cache_common_test_case return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); } - static public function setUpBeforeClass() + static public function setUpBeforeClass(): void { if (!extension_loaded('memcached')) { diff --git a/tests/cache/redis_driver_test.php b/tests/cache/redis_driver_test.php index a2288cf9a8..c5ec7880fd 100644 --- a/tests/cache/redis_driver_test.php +++ b/tests/cache/redis_driver_test.php @@ -22,7 +22,7 @@ class phpbb_cache_redis_driver_test extends \phpbb_cache_common_test_case return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); } - static public function setUpBeforeClass() + static public function setUpBeforeClass(): void { if (!extension_loaded('redis')) { diff --git a/tests/extension/extension_base_test.php b/tests/extension/extension_base_test.php index 1f44fdb234..1181498004 100644 --- a/tests/extension/extension_base_test.php +++ b/tests/extension/extension_base_test.php @@ -21,7 +21,7 @@ class phpbb_extension_extension_base_test extends phpbb_test_case /** @var phpbb_mock_extension_manager */ protected $extension_manager; - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); diff --git a/tests/filesystem/realpath_test.php b/tests/filesystem/realpath_test.php index 3d05cd7ff2..c4d1ac9472 100644 --- a/tests/filesystem/realpath_test.php +++ b/tests/filesystem/realpath_test.php @@ -18,7 +18,7 @@ class phpbb_filesystem_realpath_test extends phpbb_test_case /** @var \phpbb\filesystem\filesystem_interface */ protected $filesystem; - static public function setUpBeforeClass() + static public function setUpBeforeClass(): void { parent::setUpBeforeClass(); diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php index c0ae37ad9a..af06168466 100644 --- a/tests/functional/extension_acp_test.php +++ b/tests/functional/extension_acp_test.php @@ -22,7 +22,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case './', ); - static public function setUpBeforeClass() + static public function setUpBeforeClass(): void { parent::setUpBeforeClass(); @@ -30,7 +30,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/../extension/ext/', self::$fixtures); } - static public function tearDownAfterClass() + static public function tearDownAfterClass(): void { parent::tearDownAfterClass(); diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index d77d7df4f4..575af62c29 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -30,7 +30,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c 'foo/foo/controller/', ); - static public function setUpBeforeClass() + static public function setUpBeforeClass(): void { parent::setUpBeforeClass(); @@ -38,7 +38,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures); } - static public function tearDownAfterClass() + static public function tearDownAfterClass(): void { parent::tearDownAfterClass(); diff --git a/tests/functional/extension_global_lang_test.php b/tests/functional/extension_global_lang_test.php index d462d6eb5d..7c30a5fc22 100644 --- a/tests/functional/extension_global_lang_test.php +++ b/tests/functional/extension_global_lang_test.php @@ -26,7 +26,7 @@ class phpbb_functional_extension_global_lang_test extends phpbb_functional_test_ 'foo/bar/language/en/', ); - static public function setUpBeforeClass() + static public function setUpBeforeClass(): void { parent::setUpBeforeClass(); @@ -34,7 +34,7 @@ class phpbb_functional_extension_global_lang_test extends phpbb_functional_test_ self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures); } - static public function tearDownAfterClass() + static public function tearDownAfterClass(): void { parent::tearDownAfterClass(); diff --git a/tests/functional/extension_module_test.php b/tests/functional/extension_module_test.php index bda18380a1..d94f9e0173 100644 --- a/tests/functional/extension_module_test.php +++ b/tests/functional/extension_module_test.php @@ -25,7 +25,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case './', ); - static public function setUpBeforeClass() + static public function setUpBeforeClass(): void { parent::setUpBeforeClass(); @@ -33,7 +33,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures); } - static public function tearDownAfterClass() + static public function tearDownAfterClass(): void { parent::tearDownAfterClass(); diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index c9f5ff2367..a8caee0eeb 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -26,7 +26,7 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t 'foo/bar/language/en/', ); - static public function setUpBeforeClass() + static public function setUpBeforeClass(): void { parent::setUpBeforeClass(); @@ -34,7 +34,7 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures); } - static public function tearDownAfterClass() + static public function tearDownAfterClass(): void { parent::tearDownAfterClass(); diff --git a/tests/functional/metadata_manager_test.php b/tests/functional/metadata_manager_test.php index ca52e73ed0..3072351c25 100644 --- a/tests/functional/metadata_manager_test.php +++ b/tests/functional/metadata_manager_test.php @@ -31,7 +31,7 @@ class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case parent::tearDown(); } - static public function setUpBeforeClass() + static public function setUpBeforeClass(): void { parent::setUpBeforeClass(); @@ -39,7 +39,7 @@ class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case self::$helper->copy_ext_fixtures(dirname(__FILE__) . '/fixtures/ext/', self::$fixtures); } - static public function tearDownAfterClass() + static public function tearDownAfterClass(): void { parent::tearDownAfterClass(); diff --git a/tests/functions_content/get_username_string_test.php b/tests/functions_content/get_username_string_test.php index ac36e37e93..17c8a2f2e1 100644 --- a/tests/functions_content/get_username_string_test.php +++ b/tests/functions_content/get_username_string_test.php @@ -13,7 +13,7 @@ class phpbb_functions_content_get_username_string_test extends phpbb_test_case { - public function setUp() + public function setUp(): void { parent::setUp(); diff --git a/tests/group/helper_test_case.php b/tests/group/helper_test_case.php index 099887bcb0..5a5956e0f1 100644 --- a/tests/group/helper_test_case.php +++ b/tests/group/helper_test_case.php @@ -116,7 +116,7 @@ class phpbb_group_helper_test_case extends phpbb_test_case $this->group_helper = new \phpbb\group\helper($auth, $cache_service, $config, $lang, $phpbb_dispatcher, $path_helper, $user); } - public function setUp() + public function setUp(): void { $this->setup_engine(); } diff --git a/tests/lint_test.php b/tests/lint_test.php index 8356389acf..172a399c7e 100644 --- a/tests/lint_test.php +++ b/tests/lint_test.php @@ -16,7 +16,7 @@ class phpbb_lint_test extends phpbb_test_case static protected $php_binary; static protected $exclude; - static public function setUpBeforeClass() + static public function setUpBeforeClass(): void { // Try to use PHP_BINARY constant if available so lint tests are run // using the same php binary as phpunit. If not available (pre PHP diff --git a/tests/network/ftp_fsock_pasv_epsv_test.php b/tests/network/ftp_fsock_pasv_epsv_test.php index 876df09d1b..f615888efe 100644 --- a/tests/network/ftp_fsock_pasv_epsv_test.php +++ b/tests/network/ftp_fsock_pasv_epsv_test.php @@ -20,7 +20,7 @@ class phpbb_network_ftp_fsock_pasv_epsv_test extends phpbb_test_case { static protected $ipv4; - static public function setUpBeforeClass() + static public function setUpBeforeClass(): void { $hostname = 'ftp.debian.org.'; self::$ipv4 = gethostbyname($hostname); diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php index 0389088ec8..1cb6cbe799 100644 --- a/tests/template/template_test_case.php +++ b/tests/template/template_test_case.php @@ -25,7 +25,7 @@ class phpbb_template_template_test_case extends phpbb_test_case static protected $language_reflection_lang; - static public function setUpBeforeClass() + static public function setUpBeforeClass(): void { parent::setUpBeforeClass(); diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index 9b873fbf68..04324e0df1 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -54,7 +54,7 @@ abstract class phpbb_database_test_case extends TestCase return array(); } - static public function setUpBeforeClass() + static public function setUpBeforeClass(): void { global $phpbb_root_path, $phpEx; @@ -91,7 +91,7 @@ abstract class phpbb_database_test_case extends TestCase parent::setUpBeforeClass(); } - static public function tearDownAfterClass() + static public function tearDownAfterClass(): void { if (file_exists(self::$install_schema_file)) { diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 4aabebebd2..10e444dee5 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -42,7 +42,7 @@ class phpbb_functional_test_case extends phpbb_test_case static protected $already_installed = false; static protected $last_post_timestamp = 0; - static public function setUpBeforeClass() + static public function setUpBeforeClass(): void { parent::setUpBeforeClass(); diff --git a/tests/text_processing/message_parser_test.php b/tests/text_processing/message_parser_test.php index d302ee9504..0090a6c41c 100644 --- a/tests/text_processing/message_parser_test.php +++ b/tests/text_processing/message_parser_test.php @@ -16,7 +16,7 @@ require_once __DIR__ . '/../../phpBB/includes/message_parser.php'; class phpbb_text_processing_message_parser_test extends phpbb_test_case { - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { parent::setUpBeforeClass(); @@ -25,7 +25,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case stream_wrapper_register('http', __CLASS__ . '_proxy'); } - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { parent::tearDownAfterClass(); stream_wrapper_restore('http'); From 632bcdd2dac5c3b2eb7c091c7751e84bd93c01ba Mon Sep 17 00:00:00 2001 From: rxu Date: Mon, 13 Jul 2020 14:20:55 +0700 Subject: [PATCH 03/17] [ticket/16549] Remove exception expectation annotations PHPBB3-16549 --- tests/console/cron/run_test.php | 14 ++++++------- tests/console/update/check_test.php | 5 ++--- tests/event/php_exporter_test.php | 13 ++++-------- tests/functional/lang_test.php | 4 +--- .../get_max_setting_from_group_test.php | 4 +--- tests/migrator/schema_generator_test.php | 4 +--- tests/mimetype/guesser_test.php | 3 +-- tests/template/template_test.php | 4 +--- .../nestedset_forum_insert_delete_test.php | 5 ++--- tests/tree/nestedset_forum_move_test.php | 20 ++++++++----------- 10 files changed, 27 insertions(+), 49 deletions(-) diff --git a/tests/console/cron/run_test.php b/tests/console/cron/run_test.php index 999e0df4be..a3fc72141f 100644 --- a/tests/console/cron/run_test.php +++ b/tests/console/cron/run_test.php @@ -109,12 +109,11 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case $this->assertSame(false, $this->lock->owns_lock()); } - /** - * @expectedException \phpbb\exception\runtime_exception - * @expectedExceptionMessage CRON_LOCK_ERROR - */ public function test_error_lock() { + $this->expectException(\phpbb\exception\runtime_exception::class); + $this->expectException('CRON_LOCK_ERROR'); + $this->lock->acquire(); $command_tester = $this->get_command_tester(); $exit_status = $command_tester->execute(array('command' => $this->command_name)); @@ -231,12 +230,11 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case $this->assertSame(false, $this->lock->owns_lock()); } - /** - * @expectedException \phpbb\exception\runtime_exception - * @expectedExceptionMessage CRON_NO_SUCH_TASK - */ public function test_arg_invalid() { + $this->expectException(\phpbb\exception\runtime_exception::class); + $this->expectException('CRON_NO_SUCH_TASK'); + $command_tester = $this->get_command_tester(); $exit_status = $command_tester->execute(array('command' => $this->command_name, 'name' => 'foo')); diff --git a/tests/console/update/check_test.php b/tests/console/update/check_test.php index 7a23318cf6..3d52212325 100644 --- a/tests/console/update/check_test.php +++ b/tests/console/update/check_test.php @@ -65,11 +65,10 @@ class phpbb_console_command_check_test extends phpbb_test_case $this->assertSame($status, 1); } - /** - * @expectedException phpbb\exception\runtime_exception - */ public function test_error() { + $this->expectException(\phpbb\exception\runtime_exception::class); + $command_tester = $this->get_command_tester('1'); $this->version_helper->set_file_location('acme.corp','foo', 'bar.json'); diff --git a/tests/event/php_exporter_test.php b/tests/event/php_exporter_test.php index 5c9e20aa7d..ff2f0ee575 100644 --- a/tests/event/php_exporter_test.php +++ b/tests/event/php_exporter_test.php @@ -169,10 +169,10 @@ class phpbb_event_php_exporter_test extends phpbb_test_case /** * @dataProvider validate_since_throws_data - * @expectedException LogicException */ public function test_validate_since_throws($since) { + $this->expectException('LogicException'); $this->exporter->validate_since($since); } @@ -203,7 +203,6 @@ class phpbb_event_php_exporter_test extends phpbb_test_case /** * @dataProvider validate_event_throws_data - * @expectedException LogicException */ public function test_validate_event_throws($event_name, $event, $exception_code) { @@ -240,10 +239,10 @@ class phpbb_event_php_exporter_test extends phpbb_test_case /** * @dataProvider validate_vars_docblock_array_throws_data - * @expectedException LogicException */ public function test_validate_vars_docblock_array_throws($vars_array, $vars_docblock) { + $this->expectException('LogicException'); $this->exporter->validate_vars_docblock_array($vars_array, $vars_docblock); } @@ -282,10 +281,10 @@ class phpbb_event_php_exporter_test extends phpbb_test_case /** * @dataProvider get_dispatch_name_throws_data - * @expectedException LogicException */ public function test_get_dispatch_name_throws($event_line) { + $this->expectException('LogicException'); $this->exporter->set_content(array($event_line)); $this->exporter->get_event_name(0, true); } @@ -328,10 +327,10 @@ class phpbb_event_php_exporter_test extends phpbb_test_case /** * @dataProvider get_trigger_event_name_throws_data - * @expectedException LogicException */ public function test_get_trigger_event_name_throws($event_line) { + $this->expectException('LogicException'); $this->exporter->set_content(array($event_line)); $this->exporter->get_event_name(0, false); } @@ -459,7 +458,6 @@ class phpbb_event_php_exporter_test extends phpbb_test_case /** * @dataProvider get_vars_from_array_throws_data - * @expectedException LogicException */ public function test_get_vars_from_array_throws($lines, $event_line, $exception_code) { @@ -545,7 +543,6 @@ class phpbb_event_php_exporter_test extends phpbb_test_case /** * @dataProvider get_vars_from_docblock_throws_data - * @expectedException LogicException */ public function test_get_vars_from_docblock_throws($lines, $event_line, $exception_code) { @@ -649,7 +646,6 @@ class phpbb_event_php_exporter_test extends phpbb_test_case /** * @dataProvider find_since_throws_data - * @expectedException LogicException */ public function test_find_since_throws($lines, $event_line, $exception_code) { @@ -751,7 +747,6 @@ class phpbb_event_php_exporter_test extends phpbb_test_case /** * @dataProvider find_description_throws_data - * @expectedException LogicException */ public function test_find_description_throws($lines, $event_line, $exception_code) { diff --git a/tests/functional/lang_test.php b/tests/functional/lang_test.php index 7cffd0ef61..ed3b6786d2 100644 --- a/tests/functional/lang_test.php +++ b/tests/functional/lang_test.php @@ -22,11 +22,9 @@ class phpbb_functional_lang_test extends phpbb_functional_test_case $this->assertEquals('Board index', $this->lang('FORUM_INDEX')); } - /** - * @expectedException RuntimeException - */ public function test_lang_missing() { + $this->expectException('RuntimeException'); $this->assertEquals('Your account has now been activated. Thank you for registering.', $this->lang('ACCOUNT_ACTIVE')); } diff --git a/tests/functions_privmsgs/get_max_setting_from_group_test.php b/tests/functions_privmsgs/get_max_setting_from_group_test.php index b96f490c88..6a9018b6d3 100644 --- a/tests/functions_privmsgs/get_max_setting_from_group_test.php +++ b/tests/functions_privmsgs/get_max_setting_from_group_test.php @@ -54,11 +54,9 @@ class phpbb_functions_privmsgs_get_max_setting_from_group_test extends phpbb_dat $this->assertEquals($expected, phpbb_get_max_setting_from_group($this->db, $user_id, $setting)); } - /** - * @expectedException InvalidArgumentException - */ public function test_get_max_setting_from_group_throws() { + $this->expectException('InvalidArgumentException'); phpbb_get_max_setting_from_group($this->db, ANONYMOUS, 'not_a_setting'); } } diff --git a/tests/migrator/schema_generator_test.php b/tests/migrator/schema_generator_test.php index 1349b98953..f4324b0e08 100644 --- a/tests/migrator/schema_generator_test.php +++ b/tests/migrator/schema_generator_test.php @@ -46,11 +46,9 @@ class schema_generator_test extends phpbb_test_case return $this->generator; } - /** - * @expectedException \UnexpectedValueException - */ public function test_check_dependencies_fail() { + $this->expectException(\UnexpectedValueException::class); $this->get_schema_generator(array('\phpbb\db\migration\data\v310\forgot_password')); $this->generator->get_schema(); diff --git a/tests/mimetype/guesser_test.php b/tests/mimetype/guesser_test.php index 238e7ae2d6..959e0e59cf 100644 --- a/tests/mimetype/guesser_test.php +++ b/tests/mimetype/guesser_test.php @@ -123,11 +123,10 @@ class guesser_test extends \phpbb_test_case /** * @dataProvider data_incorrect_guessers - * - * @expectedException \LogicException */ public function test_incorrect_guesser($guessers) { + $this->expectException(\LogicException::class); $guesser = new \phpbb\mimetype\guesser($guessers); } diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 01c132e032..51d519a2b1 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -1073,11 +1073,9 @@ EOT $this->assertEquals("outer - 0 - Test assigning block vars array loop 0:outer - 1 - Test assigning block vars array loop 1:middle - 0 - 1st iterationmiddle - 1 - 2nd iterationmiddle - 2 - 3rd iteration", $this->display('test'), 'Ensuring assigning block vars array to template is working correctly'); } - /** - * @expectedException Twig_Error_Syntax - */ public function test_define_error() { + $this->expectException('Twig_Error_Syntax'); $this->run_template('define_error.html', array(), array(), array(), ''); } } diff --git a/tests/tree/nestedset_forum_insert_delete_test.php b/tests/tree/nestedset_forum_insert_delete_test.php index 6393752010..79ba12b353 100644 --- a/tests/tree/nestedset_forum_insert_delete_test.php +++ b/tests/tree/nestedset_forum_insert_delete_test.php @@ -66,12 +66,11 @@ class phpbb_tests_tree_nestedset_forum_add_remove_test extends phpbb_tests_tree_ /** * @dataProvider delete_throws_data - * - * @expectedException OutOfBoundsException - * @expectedExceptionMessage FORUM_NESTEDSET_INVALID_ITEM */ public function test_delete_throws($explain, $forum_id) { + $this->expectException('OutOfBoundsException'); + $this->expectExceptionMessage('FORUM_NESTEDSET_INVALID_ITEM'); $this->set->delete($forum_id); } diff --git a/tests/tree/nestedset_forum_move_test.php b/tests/tree/nestedset_forum_move_test.php index 108faf5b71..d884117fa0 100644 --- a/tests/tree/nestedset_forum_move_test.php +++ b/tests/tree/nestedset_forum_move_test.php @@ -386,12 +386,11 @@ class phpbb_tests_tree_nestedset_forum_move_test extends phpbb_tests_tree_nested /** * @dataProvider move_children_throws_item_data - * - * @expectedException OutOfBoundsException - * @expectedExceptionMessage FORUM_NESTEDSET_INVALID_ITEM */ public function test_move_children_throws_item($explain, $forum_id, $target_id) { + $this->expectException('OutOfBoundsException'); + $this->expectExceptionMessage('FORUM_NESTEDSET_INVALID_ITEM'); $this->set->move_children($forum_id, $target_id); } @@ -406,12 +405,11 @@ class phpbb_tests_tree_nestedset_forum_move_test extends phpbb_tests_tree_nested /** * @dataProvider move_children_throws_parent_data - * - * @expectedException OutOfBoundsException - * @expectedExceptionMessage FORUM_NESTEDSET_INVALID_PARENT */ public function test_move_children_throws_parent($explain, $forum_id, $target_id) { + $this->expectException('OutOfBoundsException'); + $this->expectExceptionMessage('FORUM_NESTEDSET_INVALID_PARENT'); $this->set->move_children($forum_id, $target_id); } @@ -542,12 +540,11 @@ class phpbb_tests_tree_nestedset_forum_move_test extends phpbb_tests_tree_nested /** * @dataProvider change_parent_throws_item_data - * - * @expectedException OutOfBoundsException - * @expectedExceptionMessage FORUM_NESTEDSET_INVALID_ITEM */ public function test_change_parent_throws_item($explain, $forum_id, $target_id) { + $this->expectException('OutOfBoundsException'); + $this->expectExceptionMessage('FORUM_NESTEDSET_INVALID_ITEM'); $this->set->change_parent($forum_id, $target_id); } @@ -562,12 +559,11 @@ class phpbb_tests_tree_nestedset_forum_move_test extends phpbb_tests_tree_nested /** * @dataProvider change_parent_throws_parent_data - * - * @expectedException OutOfBoundsException - * @expectedExceptionMessage FORUM_NESTEDSET_INVALID_PARENT */ public function test_change_parent_throws_parent($explain, $forum_id, $target_id) { + $this->expectException('OutOfBoundsException'); + $this->expectExceptionMessage('FORUM_NESTEDSET_INVALID_PARENT'); $this->set->change_parent($forum_id, $target_id); } } From 659e1e4a26ab2cba3b44b4b8216633a38acc1277 Mon Sep 17 00:00:00 2001 From: rxu Date: Mon, 13 Jul 2020 20:05:56 +0700 Subject: [PATCH 04/17] [ticket/16549] Fix wrong exception message function names PHPBB3-16549 --- tests/console/cron/run_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/console/cron/run_test.php b/tests/console/cron/run_test.php index a3fc72141f..15ff935f3e 100644 --- a/tests/console/cron/run_test.php +++ b/tests/console/cron/run_test.php @@ -112,7 +112,7 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case public function test_error_lock() { $this->expectException(\phpbb\exception\runtime_exception::class); - $this->expectException('CRON_LOCK_ERROR'); + $this->expectExceptionMessage('CRON_LOCK_ERROR'); $this->lock->acquire(); $command_tester = $this->get_command_tester(); @@ -233,7 +233,7 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case public function test_arg_invalid() { $this->expectException(\phpbb\exception\runtime_exception::class); - $this->expectException('CRON_NO_SUCH_TASK'); + $this->expectExceptionMessage('CRON_NO_SUCH_TASK'); $command_tester = $this->get_command_tester(); $exit_status = $command_tester->execute(array('command' => $this->command_name, 'name' => 'foo')); From f6a7fe168a83b9e352c62efc016431f0574fc0bf Mon Sep 17 00:00:00 2001 From: rxu Date: Mon, 13 Jul 2020 20:44:56 +0700 Subject: [PATCH 05/17] [ticket/16549] update dependencies for nightly tests PHPBB3-16549 --- tests/notification/fixtures/services_notification.yml | 3 --- travis/setup-phpbb.sh | 7 +++++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/notification/fixtures/services_notification.yml b/tests/notification/fixtures/services_notification.yml index c83d8bd323..470768d986 100644 --- a/tests/notification/fixtures/services_notification.yml +++ b/tests/notification/fixtures/services_notification.yml @@ -38,9 +38,6 @@ services: groupposition.teampage: synthetic: true - groupposition.teampage: - synthetic: true - text_formatter.s9e.factory: synthetic: true diff --git a/travis/setup-phpbb.sh b/travis/setup-phpbb.sh index be9eb703d5..82cec22058 100755 --- a/travis/setup-phpbb.sh +++ b/travis/setup-phpbb.sh @@ -38,4 +38,11 @@ fi cd phpBB php ../composer.phar install --dev --no-interaction +if [ "$TRAVIS_PHP_VERSION" == "nightly" ] +then + php ../composer.phar config minimum-stability dev \ + && php ../composer.phar config prefer-stable true \ + && php ../composer.phar remove phpunit/dbunit --dev --update-with-dependencies \ + && php ../composer.phar require symfony/yaml:~4.4 misantron/dbunit:~5.0 phpunit/phpunit:^9.3 --dev --update-with-dependencies --ignore-platform-reqs +fi cd .. From c954249dfaab098e1bb2e9631fc9e2287a2f83dd Mon Sep 17 00:00:00 2001 From: rxu Date: Mon, 13 Jul 2020 22:23:55 +0700 Subject: [PATCH 06/17] [ticket/16549] Avoid deprecated properties/methods in newer PHPUnit versions PHPBB3-16549 --- tests/controller/controller_test.php | 5 +- tests/functional/feed_test.php | 4 +- tests/functional/ucp_allow_pm_test.php | 6 +- .../phpbb_database_test_case.php | 88 ++++++++++++-- .../phpbb_functional_test_case.php | 9 +- tests/test_framework/phpbb_test_case.php | 107 ++++++++++++++++-- 6 files changed, 190 insertions(+), 29 deletions(-) diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index ddc1921b0e..37df094d40 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -107,7 +107,10 @@ class phpbb_controller_controller_test extends phpbb_test_case array(new foo\controller(), array(), array()), array(array(new foo\controller(), 'handle_fail'), array(), array(), '\phpbb\controller\exception', 'CONTROLLER_ARGUMENT_VALUE_MISSING'), array('', array(), array(), '\ReflectionException', 'Function () does not exist'), - array(new phpbb\controller\foo, array(), array(), '\ReflectionException', 'Method __invoke does not exist'), + // Before PHP 8: 'Method __invoke does not exist' + // As of PHP 8: 'Method phpbb\controller\foo::__invoke() does not exist' + array(new phpbb\controller\foo, array(), array(), '\ReflectionException', + 'Method ' . (version_compare(PHP_VERSION, '8', '>=') ? 'phpbb\controller\foo::__invoke()' : '__invoke') . ' does not exist'), ); } diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index 9dde6ffcb0..2f3ae4e39a 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -30,7 +30,9 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case { parent::__construct($name, $data, $dataName); - $this->backupStaticAttributesBlacklist['phpbb_functional_feed_test'] = array('init_values'); + $this->excludeBackupStaticAttributes([ + 'phpbb_functional_feed_test' => ['init_values'], + ]); $this->purge_cache(); } diff --git a/tests/functional/ucp_allow_pm_test.php b/tests/functional/ucp_allow_pm_test.php index 2d41296ddf..01418b25b1 100644 --- a/tests/functional/ucp_allow_pm_test.php +++ b/tests/functional/ucp_allow_pm_test.php @@ -22,9 +22,9 @@ class phpbb_functional_ucp_allow_pm_test extends phpbb_functional_test_case { parent::__construct(); - $this->backupStaticAttributesBlacklist += array( - 'phpbb_functional_ucp_allow_pm_test' => array('data'), - ); + $this->excludeBackupStaticAttributes([ + 'phpbb_functional_ucp_allow_pm_test' => ['data'], + ]); } // user A sends a PM to user B where B accepts PM diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index 04324e0df1..ecfc948793 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -29,21 +29,35 @@ abstract class phpbb_database_test_case extends TestCase static protected $install_schema_file; - public function __construct($name = NULL, array $data = array(), $dataName = '') + static protected $phpunit_version; + + public function __construct($name = NULL, array $data = [], $dataName = '') { parent::__construct($name, $data, $dataName); - $this->backupStaticAttributesBlacklist += array( - 'SebastianBergmann\CodeCoverage\CodeCoverage' => array('instance'), - 'SebastianBergmann\CodeCoverage\Filter' => array('instance'), - 'SebastianBergmann\CodeCoverage\Util' => array('ignoredLines', 'templateMethods'), - 'SebastianBergmann\Timer\Timer' => array('startTimes',), - 'PHP_Token_Stream' => array('customTokens'), - 'PHP_Token_Stream_CachingFactory' => array('cache'), - 'phpbb_database_test_case' => array('already_connected'), - ); + self::$phpunit_version = PHPUnit\Runner\Version::id(); - $this->db_connections = array(); + $backupStaticAttributesBlacklist = [ + 'SebastianBergmann\CodeCoverage\CodeCoverage' => ['instance'], + 'SebastianBergmann\CodeCoverage\Filter' => ['instance'], + 'SebastianBergmann\CodeCoverage\Util' => ['ignoredLines', 'templateMethods'], + 'SebastianBergmann\Timer\Timer' => ['startTimes'], + 'PHP_Token_Stream' => ['customTokens'], + 'PHP_Token_Stream_CachingFactory' => ['cache'], + + 'phpbb_database_test_case' => ['already_connected'], + ]; + + if (version_compare(self::$phpunit_version, '9.0', '>=')) + { + $this->backupStaticAttributesExcludeList += $backupStaticAttributesBlacklist; + } + else + { + $this->backupStaticAttributesBlacklist += $backupStaticAttributesBlacklist; + } + + $this->db_connections = []; } /** @@ -353,4 +367,56 @@ abstract class phpbb_database_test_case extends TestCase $this->assertTrue(true); } } + + /** + * PHPUnit deprecates several methods and properties in its recent versions + * Provide BC layer to be able to test in multiple environment settings + */ + public function expectException(string $exception): void + { + if (version_compare(self::$phpunit_version, '9.0', '>=')) + { + switch ($exception) { + case PHPUnit\Framework\Error\Deprecated::class: + parent::expectDeprecation(); + break; + + case PHPUnit\Framework\Error\Error::class: + parent::expectError(); + break; + + case PHPUnit\Framework\Error\Notice::class: + parent::expectNotice(); + break; + + case PHPUnit\Framework\Error\Warning::class: + parent::expectWarning(); + break; + + default: + parent::expectException($exception); + break; + } + } + else + { + parent::expectException($exception); + } + } + + /** + * PHPUnit deprecates several methods and properties in its recent versions + * Provide BC layer to be able to test in multiple environment settings + */ + public static function assertFileNotExists(string $filename, string $message = ''): void + { + if (version_compare(self::$phpunit_version, '9.0', '>=')) + { + parent::assertFileDoesNotExist($filename, $message); + } + else + { + parent::assertFileNotExists($filename, $message); + } + } } diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 10e444dee5..f21e49b65b 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -183,13 +183,14 @@ class phpbb_functional_test_case extends phpbb_test_case { } - public function __construct($name = NULL, array $data = array(), $dataName = '') + public function __construct($name = NULL, array $data = [], $dataName = '') { parent::__construct($name, $data, $dataName); - $this->backupStaticAttributesBlacklist += array( - 'phpbb_functional_test_case' => array('config', 'already_installed'), - ); + $backupStaticAttributesBlacklist = [ + 'phpbb_functional_test_case' => ['config', 'already_installed'], + ]; + $this->excludeBackupStaticAttributes($backupStaticAttributesBlacklist); } protected function get_db() diff --git a/tests/test_framework/phpbb_test_case.php b/tests/test_framework/phpbb_test_case.php index 8e09f17ede..cb48de23d4 100644 --- a/tests/test_framework/phpbb_test_case.php +++ b/tests/test_framework/phpbb_test_case.php @@ -16,20 +16,25 @@ use PHPUnit\Framework\TestCase; class phpbb_test_case extends TestCase { protected $test_case_helpers; + static protected $phpunit_version; public function __construct($name = NULL, array $data = array(), $dataName = '') { parent::__construct($name, $data, $dataName); - $this->backupStaticAttributesBlacklist += array( - 'SebastianBergmann\CodeCoverage\CodeCoverage' => array('instance'), - 'SebastianBergmann\CodeCoverage\Filter' => array('instance'), - 'SebastianBergmann\CodeCoverage\Util' => array('ignoredLines', 'templateMethods'), - 'SebastianBergmann\Timer\Timer' => array('startTimes',), - 'PHP_Token_Stream' => array('customTokens'), - 'PHP_Token_Stream_CachingFactory' => array('cache'), - 'phpbb_database_test_case' => array('already_connected', 'last_post_timestamp'), - ); + self::$phpunit_version = PHPUnit\Runner\Version::id(); + + $backupStaticAttributesBlacklist = [ + 'SebastianBergmann\CodeCoverage\CodeCoverage' => ['instance'], + 'SebastianBergmann\CodeCoverage\Filter' => ['instance'], + 'SebastianBergmann\CodeCoverage\Util' => ['ignoredLines', 'templateMethods'], + 'SebastianBergmann\Timer\Timer' => ['startTimes'], + 'PHP_Token_Stream' => ['customTokens'], + 'PHP_Token_Stream_CachingFactory' => ['cache'], + + 'phpbb_database_test_case' => ['already_connected', 'last_post_timestamp'], + ]; + $this->excludeBackupStaticAttributes($backupStaticAttributesBlacklist); } public function get_test_case_helpers() @@ -46,4 +51,88 @@ class phpbb_test_case extends TestCase { $this->get_test_case_helpers()->setExpectedTriggerError($errno, $message); } + + /** + * PHPUnit deprecates several methods and properties in its recent versions + * Provide BC layer to be able to test in multiple environment settings + */ + public function excludeBackupStaticAttributes($attributes_array) + { + if (version_compare(self::$phpunit_version, '9.0', '>=')) + { + $this->backupStaticAttributesExcludeList += $attributes_array; + } + else + { + $this->backupStaticAttributesBlacklist += $attributes_array; + } + } + + /** + * PHPUnit deprecates several methods and properties in its recent versions + * Provide BC layer to be able to test in multiple environment settings + */ + public static function assertRegExp(string $pattern, string $string, string $message = ''): void + { + if (version_compare(self::$phpunit_version, '9.0', '>=')) + { + parent::assertMatchesRegularExpression($pattern, $string, $message); + } + else + { + parent::assertRegExp($pattern, $string, $message); + } + } + + /** + * PHPUnit deprecates several methods and properties in its recent versions + * Provide BC layer to be able to test in multiple environment settings + */ + public function expectException(string $exception): void + { + if (version_compare(self::$phpunit_version, '9.0', '>=')) + { + switch ($exception) { + case PHPUnit\Framework\Error\Deprecated::class: + parent::expectDeprecation(); + break; + + case PHPUnit\Framework\Error\Error::class: + parent::expectError(); + break; + + case PHPUnit\Framework\Error\Notice::class: + parent::expectNotice(); + break; + + case PHPUnit\Framework\Error\Warning::class: + parent::expectWarning(); + break; + + default: + parent::expectException($exception); + break; + } + } + else + { + parent::expectException($exception); + } + } + + /** + * PHPUnit deprecates several methods and properties in its recent versions + * Provide BC layer to be able to test in multiple environment settings + */ + public static function assertFileNotExists(string $filename, string $message = ''): void + { + if (version_compare(self::$phpunit_version, '9.0', '>=')) + { + parent::assertFileDoesNotExist($filename, $message); + } + else + { + parent::assertFileNotExists($filename, $message); + } + } } From 7323e4467b0247c18805d72d52c7547c56a7290b Mon Sep 17 00:00:00 2001 From: rxu Date: Tue, 14 Jul 2020 20:20:53 +0700 Subject: [PATCH 07/17] [ticket/16549] rename lint_test.php As of PHPUnit 9.1, test filename should match test class name. PHPBB3-16549 --- .travis.yml | 2 +- phpunit.xml.dist | 4 ++-- tests/{lint_test.php => phpbb_lint_test.php} | 0 3 files changed, 3 insertions(+), 3 deletions(-) rename tests/{lint_test.php => phpbb_lint_test.php} (100%) diff --git a/.travis.yml b/.travis.yml index 75cee6660c..48c32b4ed3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,7 +45,7 @@ script: - travis/check-doctum-parse-errors.sh $DB $TRAVIS_PHP_VERSION $NOTESTS - travis/check-image-icc-profiles.sh $DB $TRAVIS_PHP_VERSION $NOTESTS - travis/check-executable-files.sh $DB $TRAVIS_PHP_VERSION $NOTESTS ./ - - sh -c "if [ '$SLOWTESTS' != '1' -a '$DB' = 'mysqli' ]; then phpBB/vendor/bin/phpunit tests/lint_test.php; fi" + - sh -c "if [ '$SLOWTESTS' != '1' -a '$DB' = 'mysqli' ]; then phpBB/vendor/bin/phpunit tests/phpbb_lint_test.php; fi" - sh -c "if [ '$NOTESTS' != '1' -a '$SLOWTESTS' != '1' ]; then phpBB/vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.xml --verbose --stop-on-error; fi" - sh -c "if [ '$SLOWTESTS' = '1' ]; then phpBB/vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.xml --group slow; fi" - sh -c "set -x;if [ '$NOTESTS' = '1' -a '$TRAVIS_PULL_REQUEST' != 'false' ]; then git remote set-branches --add origin $TRAVIS_BRANCH && git fetch && git-tools/commit-msg-hook-range.sh origin/$TRAVIS_BRANCH..$TRAVIS_PULL_REQUEST_SHA; fi" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 6888fe0357..642537e50d 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -14,13 +14,13 @@ ./tests ./tests/functional - ./tests/lint_test.php + ./tests/phpbb_lint_test.php ./tests/functional - ./tests/lint_test.php + ./tests/phpbb_lint_test.php diff --git a/tests/lint_test.php b/tests/phpbb_lint_test.php similarity index 100% rename from tests/lint_test.php rename to tests/phpbb_lint_test.php From 4c4debf0045918c6d838a7a5ff56e07483fb4340 Mon Sep 17 00:00:00 2001 From: rxu Date: Wed, 15 Jul 2020 15:11:20 +0700 Subject: [PATCH 08/17] [ticket/16549] PHPUnit function declarations tiny cleanup PHPBB3-16549 --- tests/acp_board/select_auth_method_test.php | 2 +- tests/attachment/delete_test.php | 2 +- tests/attachment/manager_test.php | 2 +- tests/attachment/resync_test.php | 2 +- tests/attachment/upload_test.php | 2 +- tests/auth/provider_apache_test.php | 2 +- tests/auth/provider_ldap_test.php | 2 +- tests/auth/provider_oauth_token_storage_test.php | 2 +- tests/avatar/manager_test.php | 2 +- tests/captcha/qa_test.php | 2 +- tests/class_loader/class_loader_test.php | 4 ++-- tests/config/db_test.php | 2 +- tests/config/db_text_test.php | 2 +- tests/console/config/config_test.php | 2 +- tests/console/cron/run_test.php | 2 +- tests/console/thumbnail_test.php | 2 +- tests/console/user/activate_test.php | 2 +- tests/console/user/base.php | 2 +- tests/controller/common_helper_route.php | 2 +- tests/controller/controller_test.php | 2 +- tests/cron/manager_test.php | 2 +- tests/dbal/migrator_test.php | 2 +- tests/dbal/migrator_tool_config_test.php | 2 +- tests/dbal/migrator_tool_config_text_test.php | 2 +- tests/dbal/migrator_tool_module_test.php | 2 +- tests/dbal/migrator_tool_permission_test.php | 2 +- tests/dbal/sql_affected_rows_test.php | 2 +- tests/dbal/sql_insert_buffer_test.php | 2 +- tests/di/create_container_test.php | 2 +- tests/di/ordered_service_collection_test.php | 2 +- tests/di/service_collection_test.php | 2 +- tests/email/email_parsing_test.php | 2 +- tests/error_collector_test.php | 2 +- tests/event/export_php_test.php | 2 +- tests/event/php_exporter_test.php | 2 +- tests/extension/extension_base_test.php | 2 +- tests/extension/finder_test.php | 2 +- tests/extension/modules_test.php | 2 +- tests/feed/attachments_base_test.php | 2 +- tests/filesystem/clean_path_test.php | 2 +- tests/filesystem/is_absolute_test.php | 2 +- tests/filesystem/realpath_test.php | 2 +- tests/functional/acp_permissions_test.php | 2 +- tests/functional/acp_profile_field_test.php | 2 +- tests/functional/acp_users_test.php | 2 +- tests/functional/common_avatar_test_case.php | 2 +- tests/functional/extension_acp_test.php | 2 +- tests/functional/extension_controller_test.php | 2 +- tests/functional/extension_global_lang_test.php | 4 ++-- tests/functional/extension_module_test.php | 2 +- tests/functional/extension_permission_lang_test.php | 2 +- tests/functional/feed_test.php | 2 +- tests/functional/fileupload_form_test.php | 4 ++-- tests/functional/fileupload_remote_test.php | 4 ++-- tests/functional/forgot_password_test.php | 2 +- tests/functional/metadata_manager_test.php | 4 ++-- tests/functional/plupload_test.php | 4 ++-- tests/functional/ucp_pm_test.php | 2 +- tests/functions/generate_string_list.php | 2 +- tests/functions/phpbb_get_banned_user_ids.php | 2 +- tests/functions_content/get_username_string_test.php | 2 +- tests/functions_content/phpbb_format_quote_test.php | 2 +- tests/group/helper_test_case.php | 2 +- tests/help/manager_test.php | 2 +- tests/installer/database_helper_test.php | 2 +- tests/installer/installer_config_test.php | 2 +- tests/installer/module_base_test.php | 2 +- tests/language/language_test.php | 2 +- tests/lock/db_test.php | 2 +- tests/migrations/migrations_check_config_added_test.php | 2 +- tests/migrator/get_callable_from_step_test.php | 2 +- tests/migrator/get_schema_steps_test.php | 2 +- tests/migrator/reverse_update_data_test.php | 2 +- tests/migrator/schema_generator_test.php | 2 +- tests/mimetype/guesser_test.php | 2 +- tests/notification/submit_post_base.php | 2 +- tests/notification/submit_post_type_bookmark_test.php | 2 +- tests/notification/submit_post_type_post_in_queue_test.php | 2 +- tests/notification/submit_post_type_post_test.php | 2 +- tests/notification/submit_post_type_quote_test.php | 2 +- tests/notification/submit_post_type_topic_test.php | 2 +- tests/notification/user_list_trim_test.php | 2 +- tests/pagination/pagination_test.php | 2 +- tests/passwords/drivers_test.php | 2 +- tests/passwords/manager_test.php | 2 +- tests/path_helper/path_helper_test.php | 2 +- tests/profilefields/manager_test.php | 2 +- tests/profilefields/type_bool_test.php | 2 +- tests/profilefields/type_date_test.php | 2 +- tests/profilefields/type_dropdown_test.php | 2 +- tests/profilefields/type_int_test.php | 2 +- tests/profilefields/type_string_test.php | 2 +- tests/profilefields/type_url_test.php | 2 +- tests/random/gen_rand_string_test.php | 2 +- tests/regex/email_test.php | 2 +- tests/regex/ipv4_test.php | 2 +- tests/regex/ipv6_test.php | 2 +- tests/security/hash_test.php | 2 +- tests/session/check_ban_test.php | 4 ++-- tests/session/garbage_collection_test.php | 2 +- tests/test_framework/phpbb_functional_test_case.php | 2 +- tests/test_framework/phpbb_session_test_case.php | 2 +- tests/text_formatter/s9e/factory_test.php | 2 +- tests/text_processing/decode_message_test.php | 2 +- tests/text_processing/generate_text_for_display_test.php | 2 +- tests/text_processing/generate_text_for_storage_test.php | 2 +- tests/text_processing/message_parser_test.php | 2 +- tests/text_reparser/base_test.php | 2 +- tests/text_reparser/manager_test.php | 2 +- tests/text_reparser/plugins/contact_admin_info_test.php | 2 +- tests/text_reparser/plugins/poll_option_test.php | 2 +- tests/text_reparser/plugins/test_row_based_plugin.php | 2 +- tests/tree/nestedset_forum_base.php | 2 +- tests/upload/imagesize_test.php | 2 +- tests/user/user_loader_test.php | 2 +- tests/version/version_fetch_test.php | 2 +- tests/version/version_helper_remote_test.php | 2 +- tests/version/version_test.php | 2 +- tests/viewonline/helper_test.php | 2 +- tests/wrapper/phpbb_php_ini_test.php | 2 +- 120 files changed, 127 insertions(+), 127 deletions(-) diff --git a/tests/acp_board/select_auth_method_test.php b/tests/acp_board/select_auth_method_test.php index 3cb8ea7cd6..0ca3384469 100644 --- a/tests/acp_board/select_auth_method_test.php +++ b/tests/acp_board/select_auth_method_test.php @@ -27,7 +27,7 @@ class phpbb_acp_board_select_auth_method_test extends phpbb_test_case ); } - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/attachment/delete_test.php b/tests/attachment/delete_test.php index 59669c87e9..2fac3344a8 100644 --- a/tests/attachment/delete_test.php +++ b/tests/attachment/delete_test.php @@ -40,7 +40,7 @@ class phpbb_attachment_delete_test extends \phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/resync.xml'); } - public function setUp(): void + protected function setUp(): void { global $phpbb_root_path; diff --git a/tests/attachment/manager_test.php b/tests/attachment/manager_test.php index c440dcf101..8fcea043eb 100644 --- a/tests/attachment/manager_test.php +++ b/tests/attachment/manager_test.php @@ -17,7 +17,7 @@ class phpbb_attachment_manager_test extends \phpbb_test_case protected $resync; protected $upload; - public function setUp(): void + protected function setUp(): void { $this->delete = $this->getMockBuilder('\phpbb\attachment\delete') ->disableOriginalConstructor() diff --git a/tests/attachment/resync_test.php b/tests/attachment/resync_test.php index de5ead5bff..f1ddaa00a5 100644 --- a/tests/attachment/resync_test.php +++ b/tests/attachment/resync_test.php @@ -24,7 +24,7 @@ class phpbb_attachment_resync_test extends \phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/resync.xml'); } - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/attachment/upload_test.php b/tests/attachment/upload_test.php index a3f51dd34e..3389b34e65 100644 --- a/tests/attachment/upload_test.php +++ b/tests/attachment/upload_test.php @@ -67,7 +67,7 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/resync.xml'); } - public function setUp(): void + protected function setUp(): void { global $config, $phpbb_root_path, $phpEx; diff --git a/tests/auth/provider_apache_test.php b/tests/auth/provider_apache_test.php index 0f9169ff8b..d1154fd9b6 100644 --- a/tests/auth/provider_apache_test.php +++ b/tests/auth/provider_apache_test.php @@ -17,7 +17,7 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case protected $user; protected $request; - protected function setup(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/auth/provider_ldap_test.php b/tests/auth/provider_ldap_test.php index 1ba47fd1f4..7234138a7d 100644 --- a/tests/auth/provider_ldap_test.php +++ b/tests/auth/provider_ldap_test.php @@ -21,7 +21,7 @@ class phpbb_auth_provider_ldap_test extends phpbb_database_test_case protected $user; - protected function setup() : void + protected function setUp() : void { parent::setUp(); diff --git a/tests/auth/provider_oauth_token_storage_test.php b/tests/auth/provider_oauth_token_storage_test.php index 0c0e55dec6..9b675e4b4e 100644 --- a/tests/auth/provider_oauth_token_storage_test.php +++ b/tests/auth/provider_oauth_token_storage_test.php @@ -25,7 +25,7 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c protected $state_table; protected $user; - protected function setup(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index 81a0655e02..7d3b93dc0f 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -25,7 +25,7 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/users.xml'); } - public function setUp(): void + protected function setUp(): void { global $phpbb_root_path, $phpEx; diff --git a/tests/captcha/qa_test.php b/tests/captcha/qa_test.php index 0856bbd3c3..361b5482f1 100644 --- a/tests/captcha/qa_test.php +++ b/tests/captcha/qa_test.php @@ -23,7 +23,7 @@ class phpbb_captcha_qa_test extends \phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__) . '/../fixtures/empty.xml'); } - public function setUp(): void + protected function setUp(): void { global $db, $request, $phpbb_container; diff --git a/tests/class_loader/class_loader_test.php b/tests/class_loader/class_loader_test.php index 60d8d26b13..b10010df3f 100644 --- a/tests/class_loader/class_loader_test.php +++ b/tests/class_loader/class_loader_test.php @@ -13,7 +13,7 @@ class phpbb_class_loader_test extends \phpbb_test_case { - public function setUp(): void + protected function setUp(): void { global $phpbb_class_loader; $phpbb_class_loader->unregister(); @@ -22,7 +22,7 @@ class phpbb_class_loader_test extends \phpbb_test_case $phpbb_class_loader_ext->unregister(); } - public function tearDown(): void + protected function tearDown(): void { global $phpbb_class_loader_ext; $phpbb_class_loader_ext->register(); diff --git a/tests/config/db_test.php b/tests/config/db_test.php index 46addc9d38..49d869e388 100644 --- a/tests/config/db_test.php +++ b/tests/config/db_test.php @@ -22,7 +22,7 @@ class phpbb_config_db_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); } - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/config/db_text_test.php b/tests/config/db_text_test.php index 0683abc1a9..9bf5a2007d 100644 --- a/tests/config/db_text_test.php +++ b/tests/config/db_text_test.php @@ -21,7 +21,7 @@ class phpbb_config_db_text_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config_text.xml'); } - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/console/config/config_test.php b/tests/console/config/config_test.php index 653ce89bed..2e6bb0d91b 100644 --- a/tests/console/config/config_test.php +++ b/tests/console/config/config_test.php @@ -20,7 +20,7 @@ class phpbb_console_command_config_test extends phpbb_test_case protected $command_name; protected $user; - public function setUp(): void + protected function setUp(): void { global $phpbb_root_path, $phpEx; diff --git a/tests/console/cron/run_test.php b/tests/console/cron/run_test.php index 15ff935f3e..a75635660d 100644 --- a/tests/console/cron/run_test.php +++ b/tests/console/cron/run_test.php @@ -32,7 +32,7 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); } - public function setUp(): void + protected function setUp(): void { global $db, $config, $phpbb_root_path, $phpEx; diff --git a/tests/console/thumbnail_test.php b/tests/console/thumbnail_test.php index 8f4da5a414..fb8e146e3c 100644 --- a/tests/console/thumbnail_test.php +++ b/tests/console/thumbnail_test.php @@ -32,7 +32,7 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/thumbnail.xml'); } - public function setUp(): void + protected function setUp(): void { global $config, $phpbb_root_path, $phpEx, $phpbb_filesystem; diff --git a/tests/console/user/activate_test.php b/tests/console/user/activate_test.php index e461879723..59c426bb4f 100644 --- a/tests/console/user/activate_test.php +++ b/tests/console/user/activate_test.php @@ -21,7 +21,7 @@ class phpbb_console_user_activate_test extends phpbb_console_user_base { protected $notifications; - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/console/user/base.php b/tests/console/user/base.php index 74f04cf686..e34efa85b1 100644 --- a/tests/console/user/base.php +++ b/tests/console/user/base.php @@ -31,7 +31,7 @@ abstract class phpbb_console_user_base extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml'); } - public function setUp(): void + protected function setUp(): void { global $auth, $db, $cache, $config, $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpEx; diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php index d29a631285..506d422819 100644 --- a/tests/controller/common_helper_route.php +++ b/tests/controller/common_helper_route.php @@ -41,7 +41,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_database_test_ return $this->createXMLDataSet(dirname(__FILE__) . '/../fixtures/empty.xml'); } - public function setUp(): void + protected function setUp(): void { global $phpbb_dispatcher, $phpbb_root_path, $phpEx; diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index 37df094d40..bed06f8053 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -21,7 +21,7 @@ use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; class phpbb_controller_controller_test extends phpbb_test_case { - public function setUp(): void + protected function setUp(): void { $this->extension_manager = new phpbb_mock_extension_manager( dirname(__FILE__) . '/', diff --git a/tests/cron/manager_test.php b/tests/cron/manager_test.php index 0dae404a2a..88251bf79d 100644 --- a/tests/cron/manager_test.php +++ b/tests/cron/manager_test.php @@ -20,7 +20,7 @@ require_once dirname(__FILE__) . '/tasks/simple_should_not_run.php'; class phpbb_cron_manager_test extends \phpbb_test_case { - public function setUp(): void + protected function setUp(): void { $this->manager = $this->create_cron_manager(array( new phpbb_cron_task_core_dummy_task(), diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php index 7d6b100449..e8de47a309 100644 --- a/tests/dbal/migrator_test.php +++ b/tests/dbal/migrator_test.php @@ -44,7 +44,7 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/migrator.xml'); } - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/dbal/migrator_tool_config_test.php b/tests/dbal/migrator_tool_config_test.php index 74d816dbcd..01f5d9e54f 100644 --- a/tests/dbal/migrator_tool_config_test.php +++ b/tests/dbal/migrator_tool_config_test.php @@ -13,7 +13,7 @@ class phpbb_dbal_migrator_tool_config_test extends phpbb_test_case { - public function setUp(): void + protected function setUp(): void { $this->config = new \phpbb\config\config(array()); diff --git a/tests/dbal/migrator_tool_config_text_test.php b/tests/dbal/migrator_tool_config_text_test.php index 051e0a7556..e31a74acdb 100644 --- a/tests/dbal/migrator_tool_config_text_test.php +++ b/tests/dbal/migrator_tool_config_text_test.php @@ -18,7 +18,7 @@ class phpbb_dbal_migrator_tool_config_text_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/migrator_config_text.xml'); } - public function setUp(): void + protected function setUp(): void { parent::setup(); diff --git a/tests/dbal/migrator_tool_module_test.php b/tests/dbal/migrator_tool_module_test.php index ecc7b384e7..8edd81f8b9 100644 --- a/tests/dbal/migrator_tool_module_test.php +++ b/tests/dbal/migrator_tool_module_test.php @@ -21,7 +21,7 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/migrator_module.xml'); } - public function setUp(): void + protected function setUp(): void { // Need global $db, $user for delete_module function in acp_modules global $phpbb_root_path, $phpEx, $skip_add_log, $db, $user, $phpbb_log; diff --git a/tests/dbal/migrator_tool_permission_test.php b/tests/dbal/migrator_tool_permission_test.php index e9cf55a0ce..d1eb6b2349 100644 --- a/tests/dbal/migrator_tool_permission_test.php +++ b/tests/dbal/migrator_tool_permission_test.php @@ -30,7 +30,7 @@ class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/migrator_permission.xml'); } - public function setUp(): void + protected function setUp(): void { // Global $db and $cache are needed in acp/auth.php constructor global $phpbb_root_path, $phpEx, $db, $cache; diff --git a/tests/dbal/sql_affected_rows_test.php b/tests/dbal/sql_affected_rows_test.php index e9fb1f2724..e6d0b79c40 100644 --- a/tests/dbal/sql_affected_rows_test.php +++ b/tests/dbal/sql_affected_rows_test.php @@ -16,7 +16,7 @@ class phpbb_dbal_sql_affected_rows_test extends phpbb_database_test_case /** @var \phpbb\db\driver\driver_interface */ protected $db; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->db = $this->new_dbal(); diff --git a/tests/dbal/sql_insert_buffer_test.php b/tests/dbal/sql_insert_buffer_test.php index b0e678b9da..f06d013924 100644 --- a/tests/dbal/sql_insert_buffer_test.php +++ b/tests/dbal/sql_insert_buffer_test.php @@ -16,7 +16,7 @@ class phpbb_dbal_sql_insert_buffer_test extends phpbb_database_test_case protected $db; protected $buffer; - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php index 16b49d1f17..bb87a57a7b 100644 --- a/tests/di/create_container_test.php +++ b/tests/di/create_container_test.php @@ -26,7 +26,7 @@ namespace protected $phpbb_root_path; protected $filename; - public function setUp(): void + protected function setUp(): void { $this->phpbb_root_path = dirname(__FILE__) . '/'; $this->config_php = new \phpbb\config_php_file($this->phpbb_root_path . 'fixtures/', 'php'); diff --git a/tests/di/ordered_service_collection_test.php b/tests/di/ordered_service_collection_test.php index baa9776573..e1d768d814 100644 --- a/tests/di/ordered_service_collection_test.php +++ b/tests/di/ordered_service_collection_test.php @@ -18,7 +18,7 @@ class phpbb_ordered_service_collection_test extends \phpbb_test_case */ protected $service_collection; - public function setUp(): void + protected function setUp(): void { $container = new phpbb_mock_container_builder(); $container->set('foo', new StdClass); diff --git a/tests/di/service_collection_test.php b/tests/di/service_collection_test.php index 97c13ab163..fd0e13e48b 100644 --- a/tests/di/service_collection_test.php +++ b/tests/di/service_collection_test.php @@ -18,7 +18,7 @@ class phpbb_service_collection_test extends \phpbb_test_case */ protected $service_collection; - public function setUp(): void + protected function setUp(): void { $container = new phpbb_mock_container_builder(); $container->set('foo', new StdClass); diff --git a/tests/email/email_parsing_test.php b/tests/email/email_parsing_test.php index fdb8eaa7ff..38ce5968a0 100644 --- a/tests/email/email_parsing_test.php +++ b/tests/email/email_parsing_test.php @@ -19,7 +19,7 @@ class phpbb_email_parsing_test extends phpbb_test_case /** @var \ReflectionProperty */ protected $reflection_template_property; - public function setUp(): void + protected function setUp(): void { global $phpbb_container, $config, $phpbb_root_path, $phpEx, $request, $user; diff --git a/tests/error_collector_test.php b/tests/error_collector_test.php index c7701cfad0..7b73679fda 100644 --- a/tests/error_collector_test.php +++ b/tests/error_collector_test.php @@ -13,7 +13,7 @@ class phpbb_error_collector_test extends phpbb_test_case { - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/event/export_php_test.php b/tests/event/export_php_test.php index 92280b6f4f..0dd60b2a92 100644 --- a/tests/event/export_php_test.php +++ b/tests/event/export_php_test.php @@ -16,7 +16,7 @@ class phpbb_event_export_php_test extends phpbb_test_case /** @var \phpbb\event\php_exporter */ protected $exporter; - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/event/php_exporter_test.php b/tests/event/php_exporter_test.php index ff2f0ee575..e93b8a7876 100644 --- a/tests/event/php_exporter_test.php +++ b/tests/event/php_exporter_test.php @@ -16,7 +16,7 @@ class phpbb_event_php_exporter_test extends phpbb_test_case /** @var \phpbb\event\php_exporter */ protected $exporter; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->exporter = new \phpbb\event\php_exporter(dirname(__FILE__) . '/fixtures/'); diff --git a/tests/extension/extension_base_test.php b/tests/extension/extension_base_test.php index 1181498004..03d5547c7c 100644 --- a/tests/extension/extension_base_test.php +++ b/tests/extension/extension_base_test.php @@ -30,7 +30,7 @@ class phpbb_extension_extension_base_test extends phpbb_test_case self::$reflection_method_get_migration_file_list->setAccessible(true); } - public function setUp(): void + protected function setUp(): void { $container = new phpbb_mock_container_builder(); $migrator = new phpbb_mock_migrator(); diff --git a/tests/extension/finder_test.php b/tests/extension/finder_test.php index 7649b4f19a..0c67629c6a 100644 --- a/tests/extension/finder_test.php +++ b/tests/extension/finder_test.php @@ -18,7 +18,7 @@ class phpbb_extension_finder_test extends phpbb_test_case /** @var \phpbb\finder */ protected $finder; - public function setUp(): void + protected function setUp(): void { $this->extension_manager = new phpbb_mock_extension_manager( dirname(__FILE__) . '/', diff --git a/tests/extension/modules_test.php b/tests/extension/modules_test.php index f8c65bc147..0d4202dcb3 100644 --- a/tests/extension/modules_test.php +++ b/tests/extension/modules_test.php @@ -24,7 +24,7 @@ class phpbb_extension_modules_test extends phpbb_test_case protected $finder; protected $module_manager; - public function setUp(): void + protected function setUp(): void { global $phpbb_extension_manager; diff --git a/tests/feed/attachments_base_test.php b/tests/feed/attachments_base_test.php index 82e5f3fbf2..7a04e1a143 100644 --- a/tests/feed/attachments_base_test.php +++ b/tests/feed/attachments_base_test.php @@ -25,7 +25,7 @@ class phpbb_feed_attachments_base_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__) . '/../extension/fixtures/extensions.xml'); } - public function setUp(): void + protected function setUp(): void { global $phpbb_root_path, $phpEx; diff --git a/tests/filesystem/clean_path_test.php b/tests/filesystem/clean_path_test.php index dbb06e5e74..f64d306d90 100644 --- a/tests/filesystem/clean_path_test.php +++ b/tests/filesystem/clean_path_test.php @@ -15,7 +15,7 @@ class phpbb_filesystem_clean_path_test extends phpbb_test_case { protected $filesystem; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->filesystem = new \phpbb\filesystem\filesystem(); diff --git a/tests/filesystem/is_absolute_test.php b/tests/filesystem/is_absolute_test.php index 55e729feb7..165130ae85 100644 --- a/tests/filesystem/is_absolute_test.php +++ b/tests/filesystem/is_absolute_test.php @@ -16,7 +16,7 @@ class phpbb_filesystem_is_absolute_test extends phpbb_test_case /** @var \phpbb\filesystem\filesystem_interface */ protected $filesystem; - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/filesystem/realpath_test.php b/tests/filesystem/realpath_test.php index c4d1ac9472..145ded7cfa 100644 --- a/tests/filesystem/realpath_test.php +++ b/tests/filesystem/realpath_test.php @@ -27,7 +27,7 @@ class phpbb_filesystem_realpath_test extends phpbb_test_case self::$filesystem_own_realpath->setAccessible(true); } - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/functional/acp_permissions_test.php b/tests/functional/acp_permissions_test.php index 19885570c3..36cbbf2359 100644 --- a/tests/functional/acp_permissions_test.php +++ b/tests/functional/acp_permissions_test.php @@ -16,7 +16,7 @@ */ class phpbb_functional_acp_permissions_test extends phpbb_functional_test_case { - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/functional/acp_profile_field_test.php b/tests/functional/acp_profile_field_test.php index 4c0414f03a..44755675b4 100644 --- a/tests/functional/acp_profile_field_test.php +++ b/tests/functional/acp_profile_field_test.php @@ -16,7 +16,7 @@ */ class phpbb_functional_acp_profile_field_test extends phpbb_functional_test_case { - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/functional/acp_users_test.php b/tests/functional/acp_users_test.php index b1f7e71c67..2470b55f06 100644 --- a/tests/functional/acp_users_test.php +++ b/tests/functional/acp_users_test.php @@ -16,7 +16,7 @@ */ class phpbb_functional_acp_users_test extends phpbb_functional_test_case { - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/functional/common_avatar_test_case.php b/tests/functional/common_avatar_test_case.php index a1ab7124c1..3ad82d2c86 100644 --- a/tests/functional/common_avatar_test_case.php +++ b/tests/functional/common_avatar_test_case.php @@ -21,7 +21,7 @@ abstract class phpbb_functional_common_avatar_test_case extends phpbb_functional abstract function get_url(); - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->path = __DIR__ . '/fixtures/files/'; diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php index af06168466..4ad2cb0e3f 100644 --- a/tests/functional/extension_acp_test.php +++ b/tests/functional/extension_acp_test.php @@ -37,7 +37,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case self::$helper->restore_original_ext_dir(); } - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index 575af62c29..17b5803041 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -45,7 +45,7 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c self::$helper->restore_original_ext_dir(); } - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/functional/extension_global_lang_test.php b/tests/functional/extension_global_lang_test.php index 7c30a5fc22..0cd096e867 100644 --- a/tests/functional/extension_global_lang_test.php +++ b/tests/functional/extension_global_lang_test.php @@ -41,7 +41,7 @@ class phpbb_functional_extension_global_lang_test extends phpbb_functional_test_ self::$helper->restore_original_ext_dir(); } - public function setUp(): void + protected function setUp(): void { parent::setUp(); @@ -52,7 +52,7 @@ class phpbb_functional_extension_global_lang_test extends phpbb_functional_test_ $this->purge_cache(); } - public function tearDown(): void + protected function tearDown(): void { parent::tearDown(); diff --git a/tests/functional/extension_module_test.php b/tests/functional/extension_module_test.php index d94f9e0173..d9c01175ea 100644 --- a/tests/functional/extension_module_test.php +++ b/tests/functional/extension_module_test.php @@ -40,7 +40,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case self::$helper->restore_original_ext_dir(); } - public function setUp(): void + protected function setUp(): void { global $db; diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php index a8caee0eeb..5c57c37146 100644 --- a/tests/functional/extension_permission_lang_test.php +++ b/tests/functional/extension_permission_lang_test.php @@ -41,7 +41,7 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t self::$helper->restore_original_ext_dir(); } - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index 2f3ae4e39a..16ef468eea 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -20,7 +20,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case static public $init_values = array(); - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->purge_cache(); diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php index 8722a14350..e81c0b6e1e 100644 --- a/tests/functional/fileupload_form_test.php +++ b/tests/functional/fileupload_form_test.php @@ -18,14 +18,14 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case { private $path; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->path = __DIR__ . '/fixtures/files/'; $this->add_lang('posting'); } - public function tearDown(): void + protected function tearDown(): void { $iterator = new DirectoryIterator(__DIR__ . '/../../phpBB/files/'); foreach ($iterator as $fileinfo) diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index 25fc9f0508..ac67329186 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -34,7 +34,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case /** @var string phpBB root path */ protected $phpbb_root_path; - public function setUp(): void + protected function setUp(): void { parent::setUp(); // Only doing this within the functional framework because we need a @@ -65,7 +65,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case $this->phpbb_root_path = $phpbb_root_path; } - public function tearDown(): void + protected function tearDown(): void { global $config, $user; $user = null; diff --git a/tests/functional/forgot_password_test.php b/tests/functional/forgot_password_test.php index 490ba4cbb2..112c40efd5 100644 --- a/tests/functional/forgot_password_test.php +++ b/tests/functional/forgot_password_test.php @@ -45,7 +45,7 @@ class phpbb_functional_forgot_password_test extends phpbb_functional_test_case } - public function tearDown(): void + protected function tearDown(): void { $this->login(); $this->admin_login(); diff --git a/tests/functional/metadata_manager_test.php b/tests/functional/metadata_manager_test.php index 3072351c25..4ecbdd37ca 100644 --- a/tests/functional/metadata_manager_test.php +++ b/tests/functional/metadata_manager_test.php @@ -24,7 +24,7 @@ class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case 'foo/bar/', ); - public function tearDown(): void + protected function tearDown(): void { $this->purge_cache(); @@ -46,7 +46,7 @@ class phpbb_functional_metadata_manager_test extends phpbb_functional_test_case self::$helper->restore_original_ext_dir(); } - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/functional/plupload_test.php b/tests/functional/plupload_test.php index 19c09bafb6..f28b3f621e 100644 --- a/tests/functional/plupload_test.php +++ b/tests/functional/plupload_test.php @@ -30,7 +30,7 @@ class phpbb_functional_plupload_test extends phpbb_functional_test_case $db->sql_query($query); } - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->purge_cache(); @@ -40,7 +40,7 @@ class phpbb_functional_plupload_test extends phpbb_functional_test_case $this->login(); } - public function tearDown(): void + protected function tearDown(): void { $this->set_extension_group_permission(0); $iterator = new DirectoryIterator(__DIR__ . '/../../phpBB/files/'); diff --git a/tests/functional/ucp_pm_test.php b/tests/functional/ucp_pm_test.php index 53de247202..283df83292 100644 --- a/tests/functional/ucp_pm_test.php +++ b/tests/functional/ucp_pm_test.php @@ -16,7 +16,7 @@ */ class phpbb_functional_ucp_pm_test extends phpbb_functional_test_case { - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->login(); diff --git a/tests/functions/generate_string_list.php b/tests/functions/generate_string_list.php index 0f9975bcac..b23c38854b 100644 --- a/tests/functions/generate_string_list.php +++ b/tests/functions/generate_string_list.php @@ -15,7 +15,7 @@ class phpbb_generate_string_list_test extends phpbb_test_case { public $user; - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/functions/phpbb_get_banned_user_ids.php b/tests/functions/phpbb_get_banned_user_ids.php index e1cb7a4636..cbabb85485 100644 --- a/tests/functions/phpbb_get_banned_user_ids.php +++ b/tests/functions/phpbb_get_banned_user_ids.php @@ -43,7 +43,7 @@ class phpbb_get_banned_user_ids_test extends phpbb_database_test_case ); } - public function setUp(): void + protected function setUp(): void { global $db; diff --git a/tests/functions_content/get_username_string_test.php b/tests/functions_content/get_username_string_test.php index 17c8a2f2e1..94ac99f272 100644 --- a/tests/functions_content/get_username_string_test.php +++ b/tests/functions_content/get_username_string_test.php @@ -13,7 +13,7 @@ class phpbb_functions_content_get_username_string_test extends phpbb_test_case { - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/functions_content/phpbb_format_quote_test.php b/tests/functions_content/phpbb_format_quote_test.php index 52a792517a..eed1ec5e46 100644 --- a/tests/functions_content/phpbb_format_quote_test.php +++ b/tests/functions_content/phpbb_format_quote_test.php @@ -18,7 +18,7 @@ class phpbb_functions_content_phpbb_format_quote_test extends phpbb_test_case /** @var \phpbb\language\language */ protected $lang; - public function setUp(): void + protected function setUp(): void { global $cache, $user, $phpbb_root_path, $phpEx; diff --git a/tests/group/helper_test_case.php b/tests/group/helper_test_case.php index 5a5956e0f1..c7abaea76e 100644 --- a/tests/group/helper_test_case.php +++ b/tests/group/helper_test_case.php @@ -116,7 +116,7 @@ class phpbb_group_helper_test_case extends phpbb_test_case $this->group_helper = new \phpbb\group\helper($auth, $cache_service, $config, $lang, $phpbb_dispatcher, $path_helper, $user); } - public function setUp(): void + protected function setUp(): void { $this->setup_engine(); } diff --git a/tests/help/manager_test.php b/tests/help/manager_test.php index 118a38ad3e..e841a23a53 100644 --- a/tests/help/manager_test.php +++ b/tests/help/manager_test.php @@ -20,7 +20,7 @@ class phpbb_help_manager_test extends phpbb_test_case /** @var \phpbb\language\language */ protected $language; - public function setUp(): void + protected function setUp(): void { $this->template = $this->getMockBuilder('\phpbb\template\template') ->disableOriginalConstructor() diff --git a/tests/installer/database_helper_test.php b/tests/installer/database_helper_test.php index 9ffdad3e03..03c9152a5b 100644 --- a/tests/installer/database_helper_test.php +++ b/tests/installer/database_helper_test.php @@ -18,7 +18,7 @@ class phpbb_installer_database_helper_test extends phpbb_test_case */ private $database_helper; - public function setUp(): void + protected function setUp(): void { $filesystem = new \phpbb\filesystem\filesystem(); $phpbb_root_path = ''; diff --git a/tests/installer/installer_config_test.php b/tests/installer/installer_config_test.php index 6fa8248b68..9b08dc3b26 100644 --- a/tests/installer/installer_config_test.php +++ b/tests/installer/installer_config_test.php @@ -20,7 +20,7 @@ class phpbb_installer_config_test extends phpbb_test_case */ private $config; - public function setUp(): void + protected function setUp(): void { $phpbb_root_path = __DIR__ . './../../phpBB/'; $filesystem = $this->createMock('\phpbb\filesystem\filesystem'); diff --git a/tests/installer/module_base_test.php b/tests/installer/module_base_test.php index 887d29f4c6..e5377ae5f0 100644 --- a/tests/installer/module_base_test.php +++ b/tests/installer/module_base_test.php @@ -26,7 +26,7 @@ class module_base_test extends phpbb_test_case */ protected $container; - public function setUp(): void + protected function setUp(): void { // DI container mock $this->container = new phpbb_mock_container_builder(); diff --git a/tests/language/language_test.php b/tests/language/language_test.php index 8b822472cd..2b1b245491 100644 --- a/tests/language/language_test.php +++ b/tests/language/language_test.php @@ -16,7 +16,7 @@ class phpbb_language_test extends phpbb_test_case /** @var \phpbb\language\language */ protected $lang; - public function setUp(): void + protected function setUp(): void { global $phpbb_root_path, $phpEx; diff --git a/tests/lock/db_test.php b/tests/lock/db_test.php index e96920ed1f..c940422f0a 100644 --- a/tests/lock/db_test.php +++ b/tests/lock/db_test.php @@ -22,7 +22,7 @@ class phpbb_lock_db_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/config.xml'); } - public function setUp(): void + protected function setUp(): void { global $db, $config; diff --git a/tests/migrations/migrations_check_config_added_test.php b/tests/migrations/migrations_check_config_added_test.php index 9c34428dae..25b5e89a44 100644 --- a/tests/migrations/migrations_check_config_added_test.php +++ b/tests/migrations/migrations_check_config_added_test.php @@ -13,7 +13,7 @@ class migrations_check_config_added_test extends phpbb_test_case { - public function setUp(): void + protected function setUp(): void { global $phpbb_root_path; diff --git a/tests/migrator/get_callable_from_step_test.php b/tests/migrator/get_callable_from_step_test.php index b0abb6199c..1dbcc264b5 100644 --- a/tests/migrator/get_callable_from_step_test.php +++ b/tests/migrator/get_callable_from_step_test.php @@ -13,7 +13,7 @@ class get_callable_from_step_test extends phpbb_database_test_case { - public function setUp(): void + protected function setUp(): void { global $phpbb_root_path, $php_ext, $table_prefix, $phpbb_log, $user; diff --git a/tests/migrator/get_schema_steps_test.php b/tests/migrator/get_schema_steps_test.php index 10accb3d68..9b5e6c6697 100644 --- a/tests/migrator/get_schema_steps_test.php +++ b/tests/migrator/get_schema_steps_test.php @@ -13,7 +13,7 @@ class get_schema_steps_test extends phpbb_test_case { - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/migrator/reverse_update_data_test.php b/tests/migrator/reverse_update_data_test.php index b93680c2e2..83ae8e780d 100644 --- a/tests/migrator/reverse_update_data_test.php +++ b/tests/migrator/reverse_update_data_test.php @@ -16,7 +16,7 @@ class reverse_update_data_test extends phpbb_test_case /** @var \phpbb\db\migration\helper */ protected $helper; - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/migrator/schema_generator_test.php b/tests/migrator/schema_generator_test.php index f4324b0e08..e19f8d9640 100644 --- a/tests/migrator/schema_generator_test.php +++ b/tests/migrator/schema_generator_test.php @@ -24,7 +24,7 @@ class schema_generator_test extends phpbb_test_case /** @var \phpbb\db\migration\schema_generator */ protected $generator; - public function setUp(): void + protected function setUp(): void { global $phpbb_root_path, $phpEx; diff --git a/tests/mimetype/guesser_test.php b/tests/mimetype/guesser_test.php index 959e0e59cf..2b6423f1ee 100644 --- a/tests/mimetype/guesser_test.php +++ b/tests/mimetype/guesser_test.php @@ -27,7 +27,7 @@ class guesser_test extends \phpbb_test_case protected $fileinfo_supported = false; - public function setUp(): void + protected function setUp(): void { global $phpbb_root_path; diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index 3906c1d74c..b940a3237f 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -47,7 +47,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/submit_post_' . $this->item_type . '.xml'); } - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/notification/submit_post_type_bookmark_test.php b/tests/notification/submit_post_type_bookmark_test.php index 9af247b3c3..073dcf03e7 100644 --- a/tests/notification/submit_post_type_bookmark_test.php +++ b/tests/notification/submit_post_type_bookmark_test.php @@ -17,7 +17,7 @@ class phpbb_notification_submit_post_type_bookmark_test extends phpbb_notificati { protected $item_type = 'notification.type.bookmark'; - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/notification/submit_post_type_post_in_queue_test.php b/tests/notification/submit_post_type_post_in_queue_test.php index bced0ea48c..a53e6e386b 100644 --- a/tests/notification/submit_post_type_post_in_queue_test.php +++ b/tests/notification/submit_post_type_post_in_queue_test.php @@ -17,7 +17,7 @@ class phpbb_notification_submit_post_type_post_in_queue_test extends phpbb_notif { protected $item_type = 'notification.type.post_in_queue'; - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/notification/submit_post_type_post_test.php b/tests/notification/submit_post_type_post_test.php index 9d94358f99..0e680dae01 100644 --- a/tests/notification/submit_post_type_post_test.php +++ b/tests/notification/submit_post_type_post_test.php @@ -17,7 +17,7 @@ class phpbb_notification_submit_post_type_post_test extends phpbb_notification_s { protected $item_type = 'notification.type.post'; - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/notification/submit_post_type_quote_test.php b/tests/notification/submit_post_type_quote_test.php index 655f12661b..b4469bdaff 100644 --- a/tests/notification/submit_post_type_quote_test.php +++ b/tests/notification/submit_post_type_quote_test.php @@ -17,7 +17,7 @@ class phpbb_notification_submit_post_type_quote_test extends phpbb_notification_ { protected $item_type = 'notification.type.quote'; - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/notification/submit_post_type_topic_test.php b/tests/notification/submit_post_type_topic_test.php index 070b2fa21e..a2adfcdda8 100644 --- a/tests/notification/submit_post_type_topic_test.php +++ b/tests/notification/submit_post_type_topic_test.php @@ -17,7 +17,7 @@ class phpbb_notification_submit_post_type_topic_test extends phpbb_notification_ { protected $item_type = 'notification.type.topic'; - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/notification/user_list_trim_test.php b/tests/notification/user_list_trim_test.php index bf3058c342..0542d6ab78 100644 --- a/tests/notification/user_list_trim_test.php +++ b/tests/notification/user_list_trim_test.php @@ -20,7 +20,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/user_list_trim.xml'); } - public function setUp(): void + protected function setUp(): void { global $phpbb_root_path, $phpEx, $phpbb_dispatcher, $user, $cache, $auth; diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php index 0b2c89f829..688fa7d677 100644 --- a/tests/pagination/pagination_test.php +++ b/tests/pagination/pagination_test.php @@ -22,7 +22,7 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case return implode('-', func_get_args()); } - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/passwords/drivers_test.php b/tests/passwords/drivers_test.php index 37b333e23a..cb8c58b54e 100644 --- a/tests/passwords/drivers_test.php +++ b/tests/passwords/drivers_test.php @@ -13,7 +13,7 @@ class phpbb_passwords_helper_test extends \phpbb_test_case { - public function setUp(): void + protected function setUp(): void { // Prepare dependencies for drivers $config = new \phpbb\config\config(array()); diff --git a/tests/passwords/manager_test.php b/tests/passwords/manager_test.php index 90dbb47f46..74b257ac38 100644 --- a/tests/passwords/manager_test.php +++ b/tests/passwords/manager_test.php @@ -19,7 +19,7 @@ class phpbb_passwords_manager_test extends \phpbb_test_case protected $default_pw = 'foobar'; - public function setUp(): void + protected function setUp(): void { // Prepare dependencies for manager and driver $config = new \phpbb\config\config(array()); diff --git a/tests/path_helper/path_helper_test.php b/tests/path_helper/path_helper_test.php index 31182c2daf..fc1f31027e 100644 --- a/tests/path_helper/path_helper_test.php +++ b/tests/path_helper/path_helper_test.php @@ -17,7 +17,7 @@ class phpbb_path_helper_test extends phpbb_test_case protected $path_helper; protected $phpbb_root_path = ''; - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/profilefields/manager_test.php b/tests/profilefields/manager_test.php index 191869d62b..51b627e226 100644 --- a/tests/profilefields/manager_test.php +++ b/tests/profilefields/manager_test.php @@ -39,7 +39,7 @@ class manager_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/manager.xml'); } - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/profilefields/type_bool_test.php b/tests/profilefields/type_bool_test.php index 3e7cace288..302a24ee9c 100644 --- a/tests/profilefields/type_bool_test.php +++ b/tests/profilefields/type_bool_test.php @@ -23,7 +23,7 @@ class phpbb_profilefield_type_bool_test extends phpbb_test_case * @access public * @return void */ - public function setUp(): void + protected function setUp(): void { global $phpbb_root_path, $phpEx; diff --git a/tests/profilefields/type_date_test.php b/tests/profilefields/type_date_test.php index b70aa60368..f671a52fd9 100644 --- a/tests/profilefields/type_date_test.php +++ b/tests/profilefields/type_date_test.php @@ -23,7 +23,7 @@ class phpbb_profilefield_type_date_test extends phpbb_test_case * @access public * @return null */ - public function setUp(): void + protected function setUp(): void { global $phpbb_root_path, $phpEx; diff --git a/tests/profilefields/type_dropdown_test.php b/tests/profilefields/type_dropdown_test.php index 738801d524..5234c0141a 100644 --- a/tests/profilefields/type_dropdown_test.php +++ b/tests/profilefields/type_dropdown_test.php @@ -23,7 +23,7 @@ class phpbb_profilefield_type_dropdown_test extends phpbb_test_case * @access public * @return null */ - public function setUp(): void + protected function setUp(): void { global $phpbb_root_path, $phpEx; diff --git a/tests/profilefields/type_int_test.php b/tests/profilefields/type_int_test.php index 943f130835..6088c5a03f 100644 --- a/tests/profilefields/type_int_test.php +++ b/tests/profilefields/type_int_test.php @@ -22,7 +22,7 @@ class phpbb_profilefield_type_int_test extends phpbb_test_case * @access public * @return null */ - public function setUp(): void + protected function setUp(): void { global $phpbb_root_path, $phpEx; diff --git a/tests/profilefields/type_string_test.php b/tests/profilefields/type_string_test.php index 19bfbbc926..90362ddc97 100644 --- a/tests/profilefields/type_string_test.php +++ b/tests/profilefields/type_string_test.php @@ -22,7 +22,7 @@ class phpbb_profilefield_type_string_test extends phpbb_test_case * @access public * @return null */ - public function setUp(): void + protected function setUp(): void { global $config, $request, $user, $cache, $phpbb_root_path, $phpEx; diff --git a/tests/profilefields/type_url_test.php b/tests/profilefields/type_url_test.php index 5ed5fb4c2f..6ec1193d3c 100644 --- a/tests/profilefields/type_url_test.php +++ b/tests/profilefields/type_url_test.php @@ -26,7 +26,7 @@ class phpbb_profilefield_type_url_test extends phpbb_test_case * @access public * @return null */ - public function setUp(): void + protected function setUp(): void { global $config, $request, $user, $cache, $phpbb_root_path, $phpEx; diff --git a/tests/random/gen_rand_string_test.php b/tests/random/gen_rand_string_test.php index 044fd3cc15..13ca0df245 100644 --- a/tests/random/gen_rand_string_test.php +++ b/tests/random/gen_rand_string_test.php @@ -17,7 +17,7 @@ class phpbb_random_gen_rand_string_test extends phpbb_test_case const MIN_STRING_LENGTH = 1; const MAX_STRING_LENGTH = 15; - public function setUp(): void + protected function setUp(): void { global $config; diff --git a/tests/regex/email_test.php b/tests/regex/email_test.php index 7b10b0a6ef..b281941c49 100644 --- a/tests/regex/email_test.php +++ b/tests/regex/email_test.php @@ -15,7 +15,7 @@ class phpbb_regex_email_test extends phpbb_test_case { protected $regex; - public function setUp(): void + protected function setUp(): void { $this->regex = '#^' . get_preg_expression('email') . '$#i'; } diff --git a/tests/regex/ipv4_test.php b/tests/regex/ipv4_test.php index 5d859c240b..1bd8948b87 100644 --- a/tests/regex/ipv4_test.php +++ b/tests/regex/ipv4_test.php @@ -15,7 +15,7 @@ class phpbb_regex_ipv4_test extends phpbb_test_case { protected $regex; - public function setUp(): void + protected function setUp(): void { $this->regex = get_preg_expression('ipv4'); } diff --git a/tests/regex/ipv6_test.php b/tests/regex/ipv6_test.php index d4a86015ae..92e74a0220 100644 --- a/tests/regex/ipv6_test.php +++ b/tests/regex/ipv6_test.php @@ -15,7 +15,7 @@ class phpbb_regex_ipv6_test extends phpbb_test_case { protected $regex; - public function setUp(): void + protected function setUp(): void { $this->regex = get_preg_expression('ipv6'); } diff --git a/tests/security/hash_test.php b/tests/security/hash_test.php index 40d14f24bf..49eefa3411 100644 --- a/tests/security/hash_test.php +++ b/tests/security/hash_test.php @@ -13,7 +13,7 @@ class phpbb_security_hash_test extends phpbb_test_case { - public function setUp(): void + protected function setUp(): void { global $phpbb_container; diff --git a/tests/session/check_ban_test.php b/tests/session/check_ban_test.php index 0ee655f4ac..96e550609e 100644 --- a/tests/session/check_ban_test.php +++ b/tests/session/check_ban_test.php @@ -38,7 +38,7 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case ); } - public function setUp(): void + protected function setUp(): void { parent::setUp(); // Get session here so that config is mocked correctly @@ -60,7 +60,7 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case ); } - public function tearDown(): void + protected function tearDown(): void { parent::tearDown(); // Set cache back to what it was before the test changed it diff --git a/tests/session/garbage_collection_test.php b/tests/session/garbage_collection_test.php index ec248b2904..1c54e79428 100644 --- a/tests/session/garbage_collection_test.php +++ b/tests/session/garbage_collection_test.php @@ -22,7 +22,7 @@ class phpbb_session_garbage_collection_test extends phpbb_session_test_case return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/sessions_garbage.xml'); } - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->session = $this->session_factory->get_session($this->db); diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index f21e49b65b..0f174d6cca 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -75,7 +75,7 @@ class phpbb_functional_test_case extends phpbb_test_case return array(); } - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/test_framework/phpbb_session_test_case.php b/tests/test_framework/phpbb_session_test_case.php index 7eeaa3d2dc..c12e0b316e 100644 --- a/tests/test_framework/phpbb_session_test_case.php +++ b/tests/test_framework/phpbb_session_test_case.php @@ -25,7 +25,7 @@ abstract class phpbb_session_test_case extends phpbb_database_test_case /** @var \phpbb\db\driver\driver_interface */ protected $db; - function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php index d3be7d2fb4..f57bbdd6dc 100644 --- a/tests/text_formatter/s9e/factory_test.php +++ b/tests/text_formatter/s9e/factory_test.php @@ -15,7 +15,7 @@ require_once __DIR__ . '/../../test_framework/phpbb_database_test_case.php'; class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case { - public function setUp(): void + protected function setUp(): void { $this->cache = new phpbb_mock_cache; $this->dispatcher = new phpbb_mock_event_dispatcher; diff --git a/tests/text_processing/decode_message_test.php b/tests/text_processing/decode_message_test.php index 805dd89039..0d902c9130 100644 --- a/tests/text_processing/decode_message_test.php +++ b/tests/text_processing/decode_message_test.php @@ -13,7 +13,7 @@ class phpbb_text_processing_decode_message_test extends phpbb_test_case { - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/text_processing/generate_text_for_display_test.php b/tests/text_processing/generate_text_for_display_test.php index f7da27cc35..8429c16c3a 100644 --- a/tests/text_processing/generate_text_for_display_test.php +++ b/tests/text_processing/generate_text_for_display_test.php @@ -13,7 +13,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_case { - public function setUp(): void + protected function setUp(): void { global $cache, $user, $phpbb_dispatcher; diff --git a/tests/text_processing/generate_text_for_storage_test.php b/tests/text_processing/generate_text_for_storage_test.php index c6c62c7579..68320ec7d1 100644 --- a/tests/text_processing/generate_text_for_storage_test.php +++ b/tests/text_processing/generate_text_for_storage_test.php @@ -13,7 +13,7 @@ class phpbb_text_processing_generate_text_for_storage_test extends phpbb_test_case { - public function setUp(): void + protected function setUp(): void { global $config, $phpbb_container, $phpbb_dispatcher; diff --git a/tests/text_processing/message_parser_test.php b/tests/text_processing/message_parser_test.php index 0090a6c41c..f7193ea74c 100644 --- a/tests/text_processing/message_parser_test.php +++ b/tests/text_processing/message_parser_test.php @@ -25,7 +25,7 @@ class phpbb_text_processing_message_parser_test extends phpbb_test_case stream_wrapper_register('http', __CLASS__ . '_proxy'); } - public static function tearDownAfterClass(): void + static public function tearDownAfterClass(): void { parent::tearDownAfterClass(); stream_wrapper_restore('http'); diff --git a/tests/text_reparser/base_test.php b/tests/text_reparser/base_test.php index 59604da4e3..edf39e7f10 100644 --- a/tests/text_reparser/base_test.php +++ b/tests/text_reparser/base_test.php @@ -17,7 +17,7 @@ class phpbb_textreparser_base_test extends phpbb_database_test_case { protected $db; - public function setUp(): void + protected function setUp(): void { global $config; if (!isset($config)) diff --git a/tests/text_reparser/manager_test.php b/tests/text_reparser/manager_test.php index afa557deff..a70e41dce7 100644 --- a/tests/text_reparser/manager_test.php +++ b/tests/text_reparser/manager_test.php @@ -30,7 +30,7 @@ class phpbb_text_reparser_manager_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config_text.xml'); } - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/text_reparser/plugins/contact_admin_info_test.php b/tests/text_reparser/plugins/contact_admin_info_test.php index 690d3a4046..f8a925ccea 100644 --- a/tests/text_reparser/plugins/contact_admin_info_test.php +++ b/tests/text_reparser/plugins/contact_admin_info_test.php @@ -39,7 +39,7 @@ class phpbb_textreparser_contact_admin_info_test extends phpbb_database_test_cas return $rows; } - public function setUp(): void + protected function setUp(): void { global $config; if (!isset($config)) diff --git a/tests/text_reparser/plugins/poll_option_test.php b/tests/text_reparser/plugins/poll_option_test.php index 32fb8a0411..b18cb07153 100644 --- a/tests/text_reparser/plugins/poll_option_test.php +++ b/tests/text_reparser/plugins/poll_option_test.php @@ -39,7 +39,7 @@ class phpbb_textreparser_poll_option_test extends phpbb_database_test_case return $rows; } - public function setUp(): void + protected function setUp(): void { global $config; if (!isset($config)) diff --git a/tests/text_reparser/plugins/test_row_based_plugin.php b/tests/text_reparser/plugins/test_row_based_plugin.php index cf913c9c1e..700bead7e5 100644 --- a/tests/text_reparser/plugins/test_row_based_plugin.php +++ b/tests/text_reparser/plugins/test_row_based_plugin.php @@ -39,7 +39,7 @@ abstract class phpbb_textreparser_test_row_based_plugin extends phpbb_database_t return $rows; } - public function setUp(): void + protected function setUp(): void { global $config; if (!isset($config)) diff --git a/tests/tree/nestedset_forum_base.php b/tests/tree/nestedset_forum_base.php index e91e816b2a..44d51f7100 100644 --- a/tests/tree/nestedset_forum_base.php +++ b/tests/tree/nestedset_forum_base.php @@ -48,7 +48,7 @@ class phpbb_tests_tree_nestedset_forum_base extends phpbb_database_test_case $lock, $db; - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/upload/imagesize_test.php b/tests/upload/imagesize_test.php index 3adf61dedc..654e32054a 100644 --- a/tests/upload/imagesize_test.php +++ b/tests/upload/imagesize_test.php @@ -20,7 +20,7 @@ class phpbb_upload_imagesize_test extends \phpbb_test_case /** @var string Path to fixtures */ protected $path; - public function setUp(): void + protected function setUp(): void { parent::setUp(); $this->imagesize = new \FastImageSize\FastImageSize(); diff --git a/tests/user/user_loader_test.php b/tests/user/user_loader_test.php index f283e993dc..b22b3690ad 100644 --- a/tests/user/user_loader_test.php +++ b/tests/user/user_loader_test.php @@ -21,7 +21,7 @@ class phpbb_user_loader_test extends phpbb_database_test_case return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/user_loader.xml'); } - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/version/version_fetch_test.php b/tests/version/version_fetch_test.php index 4e8e82567a..c6c1dcfca6 100644 --- a/tests/version/version_fetch_test.php +++ b/tests/version/version_fetch_test.php @@ -16,7 +16,7 @@ */ class phpbb_version_helper_fetch_test extends phpbb_test_case { - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/version/version_helper_remote_test.php b/tests/version/version_helper_remote_test.php index d392d6d256..959fc5625c 100644 --- a/tests/version/version_helper_remote_test.php +++ b/tests/version/version_helper_remote_test.php @@ -17,7 +17,7 @@ class version_helper_remote_test extends \phpbb_test_case protected $cache; protected $version_helper; - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/version/version_test.php b/tests/version/version_test.php index 3298213487..dec9bdc42b 100644 --- a/tests/version/version_test.php +++ b/tests/version/version_test.php @@ -13,7 +13,7 @@ class phpbb_version_helper_test extends phpbb_test_case { - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/viewonline/helper_test.php b/tests/viewonline/helper_test.php index d7c9965ad1..32bda75533 100644 --- a/tests/viewonline/helper_test.php +++ b/tests/viewonline/helper_test.php @@ -13,7 +13,7 @@ class phpbb_viewonline_helper_test extends phpbb_test_case { - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/wrapper/phpbb_php_ini_test.php b/tests/wrapper/phpbb_php_ini_test.php index d6ce11219f..858cf473a3 100644 --- a/tests/wrapper/phpbb_php_ini_test.php +++ b/tests/wrapper/phpbb_php_ini_test.php @@ -18,7 +18,7 @@ class phpbb_wrapper_phpbb_php_ini_test extends phpbb_test_case /** @var \phpbb_php_ini_fake php_ini */ protected $php_ini; - public function setUp(): void + protected function setUp(): void { $this->php_ini = new phpbb_php_ini_fake; } From 72c4c183648cb36c2c1dd903192531c63946e650 Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 9 Aug 2020 14:20:17 +0700 Subject: [PATCH 09/17] [ticket/16549] Require stable versions as PHPUnit 9.3 has been released PHPBB3-16549 --- tests/functional/forum_style_test.php | 10 ---------- travis/setup-phpbb.sh | 6 ++---- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/tests/functional/forum_style_test.php b/tests/functional/forum_style_test.php index 7c7df32184..3533735056 100644 --- a/tests/functional/forum_style_test.php +++ b/tests/functional/forum_style_test.php @@ -48,15 +48,6 @@ class phpbb_functional_forum_style_test extends phpbb_functional_test_case $db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_style = 2 WHERE forum_id = 2'); $crawler = self::request('GET', 'viewtopic.php?t=1&f=2'); -<<<<<<< HEAD - $this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href')); - - $crawler = self::request('GET', 'viewtopic.php?t=1'); - $this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href')); - - $crawler = self::request('GET', 'viewtopic.php?t=1&view=next'); - $this->assertContains('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->eq(1)->attr('href')); -======= $this->assertStringContainsString('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->eq(2)->attr('href')); $crawler = self::request('GET', 'viewtopic.php?t=1'); @@ -64,7 +55,6 @@ class phpbb_functional_forum_style_test extends phpbb_functional_test_case $crawler = self::request('GET', 'viewtopic.php?t=1&view=next'); $this->assertStringContainsString('styles/test_style/', $crawler->filter('head > link[rel=stylesheet]')->eq(2)->attr('href')); ->>>>>>> 33be5dc489... [ticket/16549] Move from assert[Not]Contains to assertString[Not]ContainsString $db->sql_query('UPDATE ' . FORUMS_TABLE . ' SET forum_style = 0 WHERE forum_id = 2'); $this->delete_style(2, 'test_style'); diff --git a/travis/setup-phpbb.sh b/travis/setup-phpbb.sh index 82cec22058..daa71bd8aa 100755 --- a/travis/setup-phpbb.sh +++ b/travis/setup-phpbb.sh @@ -40,9 +40,7 @@ cd phpBB php ../composer.phar install --dev --no-interaction if [ "$TRAVIS_PHP_VERSION" == "nightly" ] then - php ../composer.phar config minimum-stability dev \ - && php ../composer.phar config prefer-stable true \ - && php ../composer.phar remove phpunit/dbunit --dev --update-with-dependencies \ - && php ../composer.phar require symfony/yaml:~4.4 misantron/dbunit:~5.0 phpunit/phpunit:^9.3 --dev --update-with-dependencies --ignore-platform-reqs + php ../composer.phar remove phpunit/dbunit --dev --update-with-dependencies \ + && php ../composer.phar require misantron/dbunit:~5.0 phpunit/phpunit:^9.3 --dev --update-with-dependencies --ignore-platform-reqs fi cd .. From 615d5eaa77016ba210d25b91b840cf328b66f95c Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 9 Aug 2020 15:17:49 +0700 Subject: [PATCH 10/17] [ticket/16549] Fix select auth method test PHPBB3-16549 --- tests/acp_board/select_auth_method_test.php | 26 ++++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/tests/acp_board/select_auth_method_test.php b/tests/acp_board/select_auth_method_test.php index 0ca3384469..b651fbedf9 100644 --- a/tests/acp_board/select_auth_method_test.php +++ b/tests/acp_board/select_auth_method_test.php @@ -21,23 +21,31 @@ class phpbb_acp_board_select_auth_method_test extends phpbb_test_case public static function select_auth_method_data() { - return array( - array('acp_board_valid', ''), - array('acp_board_invalid', ''), - ); + return [ + ['acp_board_valid', ''], + ['acp_board_invalid', ''], + ]; } protected function setUp(): void { parent::setUp(); - global $phpbb_container; + global $phpbb_container, $config; $phpbb_container = new phpbb_mock_container_builder(); + $config = new \phpbb\config\config([]); - $phpbb_container->set('auth.provider_collection', array( - 'auth.provider.acp_board_valid' => new phpbb\auth\provider\acp\board_valid, - 'auth.provider.acp_board_invalid' => new phpbb\auth\provider\acp\board_invalid, - )); + // Create auth provider service collection + $auth_provider_collection = new \phpbb\auth\provider_collection($phpbb_container, $config); + $phpbb_container->set('auth.provider_collection', $auth_provider_collection); + + // Create auth provider services + $phpbb_container->set('auth.provider.acp_board_valid', new phpbb\auth\provider\acp\board_valid); + $phpbb_container->set('auth.provider.acp_board_invalid', new phpbb\auth\provider\acp\board_invalid); + + // Add auth provider servives to the service collection + $auth_provider_collection->add('auth.provider.acp_board_valid'); + $auth_provider_collection->add('auth.provider.acp_board_invalid'); $this->acp_board = new acp_board(); } From fc631040fdb571da2ef69ba6163a5d401846a3ab Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 9 Aug 2020 15:56:57 +0700 Subject: [PATCH 11/17] [ticket/16549] Fix composer dependencies PHPBB3-16549 --- travis/setup-phpbb.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/travis/setup-phpbb.sh b/travis/setup-phpbb.sh index daa71bd8aa..8d23865d08 100755 --- a/travis/setup-phpbb.sh +++ b/travis/setup-phpbb.sh @@ -41,6 +41,6 @@ php ../composer.phar install --dev --no-interaction if [ "$TRAVIS_PHP_VERSION" == "nightly" ] then php ../composer.phar remove phpunit/dbunit --dev --update-with-dependencies \ - && php ../composer.phar require misantron/dbunit:~5.0 phpunit/phpunit:^9.3 --dev --update-with-dependencies --ignore-platform-reqs + && php ../composer.phar require symfony/yaml:~4.4 misantron/dbunit:~5.0 nikic/php-parser:~4.7 phpunit/phpunit:^9.3 --dev --update-with-all-dependencies --ignore-platform-reqs fi cd .. From ec565de6cbb779fd33f30d6d5a35fd0cf28f52a3 Mon Sep 17 00:00:00 2001 From: rxu Date: Mon, 10 Aug 2020 15:02:25 +0700 Subject: [PATCH 12/17] [ticket/16549] Fix tests PHPBB3-16549 --- tests/attachment/upload_test.php | 21 ++- tests/avatar/manager_test.php | 12 +- tests/cache/cache_memory.php | 2 +- tests/cache/cache_memory_test.php | 2 +- tests/console/user/base.php | 1 + tests/content_visibility/delete_post_test.php | 2 + tests/dbal/db_tools_test.php | 2 +- tests/email/email_parsing_test.php | 1 + tests/error_collector_test.php | 10 +- tests/files/types_local_test.php | 10 +- tests/functional/acp_groups_test.php | 6 +- tests/functional/avatar_acp_groups_test.php | 2 +- tests/functional/smilies_test.php | 2 +- tests/functions/user_delete_test.php | 1 + tests/functions/validate_num_test.php | 4 +- tests/functions/validate_user_email_test.php | 1 + .../phpbb_format_quote_test.php | 1 + tests/notification/base.php | 2 + .../notification_method_email_test.php | 11 +- tests/notification/notification_test.php | 7 + tests/notification/submit_post_base.php | 4 + .../submit_post_type_topic_test.php | 7 +- tests/notification/user_list_trim_test.php | 5 +- tests/profilefields/manager_test.php | 2 + tests/profilefields/type_bool_test.php | 6 +- tests/profilefields/type_date_test.php | 2 + tests/profilefields/type_dropdown_test.php | 5 +- tests/profilefields/type_int_test.php | 4 + tests/profilefields/type_string_test.php | 4 + tests/profilefields/type_url_test.php | 4 + tests/session/check_ban_test.php | 10 ++ tests/session/session_key_test.php | 6 + tests/session/testable_facade.php | 4 +- tests/template/extension_test.php | 2 + tests/template/template_test.php | 3 +- .../template/templates/loop_expressions.html | 12 +- .../phpbb_functional_test_case.php | 4 + .../phpbb_test_case_helpers.php | 21 ++- tests/text_formatter/s9e/renderer_test.php | 13 +- .../generate_text_for_display_test.php | 7 +- tests/upload/fileupload_test.php | 24 +++- tests/version/version_test.php | 134 ++++++++++++++++++ travis/setup-phpbb.sh | 2 +- 43 files changed, 334 insertions(+), 51 deletions(-) diff --git a/tests/attachment/upload_test.php b/tests/attachment/upload_test.php index 3389b34e65..2743ee596d 100644 --- a/tests/attachment/upload_test.php +++ b/tests/attachment/upload_test.php @@ -137,6 +137,7 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case $this->files_upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $this->php_ini, $this->request, $this->phpbb_root_path); $this->phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $this->user = new \phpbb\user($this->language, '\phpbb\datetime'); + $this->user->data['user_id'] = ANONYMOUS; $this->upload = new \phpbb\attachment\upload( @@ -181,7 +182,14 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case ) ), array('foobar', 1, true, - array(), + // Instead of setting to false or empty array, set default filedata array + // as otherwise it throws PHP undefined array key warnings + // in different file upload related services + array( + 'realname' => null, + 'type' => null, + 'size' => null, + ), array( 'error' => array( 'NOT_UPLOADED', @@ -244,7 +252,16 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case $this->phpbb_root_path ); - $filedata = $this->upload->upload('foobar', 1, true); + // Instead of setting to false or empty array, set default filedata array + // as otherwise it throws PHP undefined array key warnings + // in different file upload related services + $filedata = $this->upload->upload('foobar', 1, true, '', false, + [ + 'realname' => null, + 'type' => null, + 'size' => null, + ] + ); $this->assertSame(array( 'error' => array(), diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index 7d3b93dc0f..d5a32f7061 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -333,7 +333,9 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case 'avatar_type' => '', 'avatar_width' => 0, 'avatar_height' => 0, - ), 1, array( + ), + array( + 'id' => 1, 'avatar' => 'foobar@example.com', 'avatar_type' => 'avatar.driver.gravatar', 'avatar_width' => '16', @@ -346,7 +348,9 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case 'avatar_type' => '', 'avatar_width' => 0, 'avatar_height' => 0, - ), 5, array( + ), + array( + 'id' => 5, 'avatar' => 'g5_1414350991.jpg', 'avatar_type' => 'avatar.driver.upload', 'avatar_width' => '80', @@ -359,13 +363,13 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case /** * @dataProvider data_handle_avatar_delete */ - public function test_handle_avatar_delete($expected, $id, $avatar_data, $table, $prefix) + public function test_handle_avatar_delete($expected, $avatar_data, $table, $prefix) { $this->config['allow_avatar_gravatar'] = true; $this->assertNull($this->manager->handle_avatar_delete($this->db, $this->user, $avatar_data, $table, $prefix)); $sql = 'SELECT * FROM ' . $table . ' - WHERE ' . $prefix . 'id = ' . $id; + WHERE ' . $prefix . 'id = ' . (int) $avatar_data['id']; $result = $this->db->sql_query_limit($sql, 1); $row = $this->manager->clean_row($this->db->sql_fetchrow($result), substr($prefix, 0, -1)); diff --git a/tests/cache/cache_memory.php b/tests/cache/cache_memory.php index 565e9a48eb..1f7b31a86b 100644 --- a/tests/cache/cache_memory.php +++ b/tests/cache/cache_memory.php @@ -31,7 +31,7 @@ class phpbb_cache_memory extends \phpbb\cache\driver\memory */ function _read($var) { - return $this->data[$var]; + return $this->data[$var] ?? false; } /** diff --git a/tests/cache/cache_memory_test.php b/tests/cache/cache_memory_test.php index b3d19f1782..3a465aef7e 100644 --- a/tests/cache/cache_memory_test.php +++ b/tests/cache/cache_memory_test.php @@ -123,7 +123,7 @@ class phpbb_cache_memory_test extends phpbb_database_test_case foreach ($sql_queries as $query) { - $this->assertNotEquals(false, $this->cache->sql_load($query[0])); + $this->assertFalse($this->cache->sql_load($query[0])); } } } diff --git a/tests/console/user/base.php b/tests/console/user/base.php index e34efa85b1..c9ddecc7a4 100644 --- a/tests/console/user/base.php +++ b/tests/console/user/base.php @@ -66,6 +66,7 @@ abstract class phpbb_console_user_base extends phpbb_database_test_case $this->language, '\phpbb\datetime' )); + $user->data['user_email'] = ''; $this->user_loader = new \phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE); diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php index 1c1796a1fc..77f2559ad6 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -309,6 +309,8 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case $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'); + $user->data['user_id'] = ANONYMOUS; + $attachment_delete = new \phpbb\attachment\delete($config, $db, new \phpbb_mock_event_dispatcher(), new \phpbb\filesystem\filesystem(), new \phpbb\attachment\resync($db), $phpbb_root_path); $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php index 20ea2b3729..37cdedaaf5 100644 --- a/tests/dbal/db_tools_test.php +++ b/tests/dbal/db_tools_test.php @@ -425,7 +425,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case public function test_create_int_default_null() { $this->assertFalse($this->tools->sql_column_exists('prefix_table_name', 'c_bug_13282')); - $this->assertTrue($this->tools->sql_column_add('prefix_table_name', 'c_bug_13282', array('TINT:2'))); + $this->assertTrue($this->tools->sql_column_add('prefix_table_name', 'c_bug_13282', array('TINT:2', null))); $this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_bug_13282')); } diff --git a/tests/email/email_parsing_test.php b/tests/email/email_parsing_test.php index 38ce5968a0..b9d30628b0 100644 --- a/tests/email/email_parsing_test.php +++ b/tests/email/email_parsing_test.php @@ -53,6 +53,7 @@ class phpbb_email_parsing_test extends phpbb_test_case $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'); + $user->data['user_lang'] = 'en'; $phpbb_container->set('user', $user); $extension_manager = new phpbb_mock_extension_manager( dirname(__FILE__) . '/', diff --git a/tests/error_collector_test.php b/tests/error_collector_test.php index 7b73679fda..e1bbd89f12 100644 --- a/tests/error_collector_test.php +++ b/tests/error_collector_test.php @@ -51,14 +51,16 @@ class phpbb_error_collector_test extends phpbb_test_case // Cause a warning 1/0; $line = __LINE__; - // Cause a notice - $array = array(0 => 'value'); - $value = $array[1]; $line2 = __LINE__; + // Cause a "Notice: unserialize(): Error at offset 0 of 27 bytes in ..." + // "Undefined array index" used earlier was promoted to warning in PHP 8.0, + // see https://github.com/php/php-src/commit/c48b745f0090c944e77c1fbcfb6c4df3b54356ad + unserialize("obvious non-serialized data"); $line2 = __LINE__; $collector->uninstall(); // The notice should not be collected - $this->assertEmpty($collector->errors[1]); + $this->assertFalse(isset($collector->errors[1])); + $this->assertEquals(count($collector->errors), 1); list($errno, $msg_text, $errfile, $errline) = $collector->errors[0]; $error_contents = $collector->format_errors(); diff --git a/tests/files/types_local_test.php b/tests/files/types_local_test.php index 7468e9c4a7..001014a77e 100644 --- a/tests/files/types_local_test.php +++ b/tests/files/types_local_test.php @@ -104,6 +104,7 @@ class phpbb_files_types_local_test extends phpbb_test_case array( 'foo', array( + 'realname' => null, 'tmp_name' => 'foo', 'size' => 500, 'type' => 'image/png', @@ -112,13 +113,17 @@ class phpbb_files_types_local_test extends phpbb_test_case ), array( 'none', - false, + array( + 'realname' => null, + 'size' => null, + 'type' => null, + ), array('PHP_SIZE_OVERRUN'), ), array( 'tests/upload/fixture/png', array( - 'realname' => 'foo.png', + 'realname' => 'foo.png', 'size' => 500, 'type' => 'image/png', 'local_mode' => true, @@ -153,7 +158,6 @@ class phpbb_files_types_local_test extends phpbb_test_case $upload->set_allowed_extensions(array('png')); $type_local->set_upload($upload); - $file = $type_local->upload($filename, $upload_ary); $this->assertSame($expected, $file->error); $this->assertInstanceOf('\phpbb\files\filespec', $file); diff --git a/tests/functional/acp_groups_test.php b/tests/functional/acp_groups_test.php index f574115d62..06001fd262 100644 --- a/tests/functional/acp_groups_test.php +++ b/tests/functional/acp_groups_test.php @@ -117,8 +117,10 @@ class phpbb_functional_acp_groups_test extends phpbb_functional_common_groups_te else { $this->form_data = $form->getValues(); - $this->assertEquals($tick_legend, $this->form_data['group_legend']); - $this->assertEquals($tick_teampage, $this->form_data['group_teampage']); + // form_data[] values can be bool or null if not ticked, $tick_* value can be bool or null if not set. + // Cast both to the same type to correctly compare the values. + $this->assertEquals((bool) $tick_legend, (bool) ($this->form_data['group_legend'] ?? false)); + $this->assertEquals((bool) $tick_teampage, (bool) ($this->form_data['group_teampage'] ?? false)); } } } diff --git a/tests/functional/avatar_acp_groups_test.php b/tests/functional/avatar_acp_groups_test.php index ca8c84ab2e..f9251fd2f0 100644 --- a/tests/functional/avatar_acp_groups_test.php +++ b/tests/functional/avatar_acp_groups_test.php @@ -80,6 +80,6 @@ class phpbb_functional_avatar_acp_groups_test extends phpbb_functional_common_av $crawler = self::request('GET', $this->get_url() . '&sid=' . $this->sid); $form = $crawler->selectButton($this->lang('SUBMIT'))->form(); $form_data = $form->getValues(); - $this->assertEmpty($form_data['avatar_type']); + $this->assertFalse(isset($form_data['avatar_type'])); } } diff --git a/tests/functional/smilies_test.php b/tests/functional/smilies_test.php index f17171bd1f..11d36908a7 100644 --- a/tests/functional/smilies_test.php +++ b/tests/functional/smilies_test.php @@ -39,7 +39,7 @@ class phpbb_functional_smilies_test extends phpbb_functional_test_case $crawler = self::request('GET', 'posting.php?mode=smilies'); foreach ($smilies as $index => $smiley) { - $this->assertContains($smiley['smiley_url'], + $this->assertStringContainsString($smiley['smiley_url'], $crawler->filter('div[class="inner"] > a > img')->eq($index)->attr('src') ); } diff --git a/tests/functions/user_delete_test.php b/tests/functions/user_delete_test.php index f4ea5696b9..8417be5ede 100644 --- a/tests/functions/user_delete_test.php +++ b/tests/functions/user_delete_test.php @@ -33,6 +33,7 @@ class phpbb_functions_user_delete_test extends phpbb_database_test_case $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'); + $user->data['user_id'] = 2; $phpbb_dispatcher = new phpbb_mock_event_dispatcher(); $phpbb_container = new phpbb_mock_container_builder(); $config = new \phpbb\config\config(array( diff --git a/tests/functions/validate_num_test.php b/tests/functions/validate_num_test.php index acbdc49614..26470d12f4 100644 --- a/tests/functions/validate_num_test.php +++ b/tests/functions/validate_num_test.php @@ -30,7 +30,7 @@ class phpbb_functions_validate_num_test extends phpbb_test_case $this->helper->assert_valid_data(array( 'empty' => array( array(), - '', + null, // '' < 0 is true since PHP 8.0, hence use null instead of '' (empty string) array('num'), ), 'zero' => array( @@ -54,7 +54,7 @@ class phpbb_functions_validate_num_test extends phpbb_test_case array('num', false, 2, 3), ), 'string' => array( - array(), + version_compare(PHP_VERSION, '7.5', '<=') ? [] : ['TOO_LARGE'], // See https://wiki.php.net/rfc/string_to_number_comparison 'foobar', array('num'), ), diff --git a/tests/functions/validate_user_email_test.php b/tests/functions/validate_user_email_test.php index eeb5bfc2a9..fc22b7ac64 100644 --- a/tests/functions/validate_user_email_test.php +++ b/tests/functions/validate_user_email_test.php @@ -38,6 +38,7 @@ class phpbb_functions_validate_user_email_test extends phpbb_database_test_case $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); } diff --git a/tests/functions_content/phpbb_format_quote_test.php b/tests/functions_content/phpbb_format_quote_test.php index eed1ec5e46..2f19c198e7 100644 --- a/tests/functions_content/phpbb_format_quote_test.php +++ b/tests/functions_content/phpbb_format_quote_test.php @@ -25,6 +25,7 @@ class phpbb_functions_content_phpbb_format_quote_test extends phpbb_test_case $lang_file_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx); $this->lang = new \phpbb\language\language($lang_file_loader); $user = new \phpbb\user($this->lang, '\phpbb\datetime'); + $user->data['user_options'] = 230271; $cache = new phpbb_mock_cache(); parent::setUp(); diff --git a/tests/notification/base.php b/tests/notification/base.php index 1622d12363..e9de0daac1 100644 --- a/tests/notification/base.php +++ b/tests/notification/base.php @@ -74,6 +74,8 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case $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'); + $user->data['user_id'] = 0; + $user->data['user_type'] = USER_NORMAL; $this->user = $user; $this->user_loader = new \phpbb\user_loader($this->db, $phpbb_root_path, $phpEx, 'phpbb_users'); $auth = $this->auth = new phpbb_mock_notifications_auth(); diff --git a/tests/notification/notification_method_email_test.php b/tests/notification/notification_method_email_test.php index cf84ddc795..8c442d4e0b 100644 --- a/tests/notification/notification_method_email_test.php +++ b/tests/notification/notification_method_email_test.php @@ -249,7 +249,16 @@ class notification_method_email_test extends phpbb_tests_notification_base */ public function test_notification_email($notification_type, $post_data, $expected_users) { - $post_data = array_merge(['post_time' => 1349413322], $post_data); + $post_data = array_merge([ + 'post_time' => 1349413322, + 'poster_id' => 1, + 'topic_title' => '', + 'post_subject' => '', + 'post_username' => '', + 'forum_name' => '', + ], + + $post_data); $notification_options = [ 'item_id' => $post_data['post_id'], 'item_parent_id' => $post_data['topic_id'], diff --git a/tests/notification/notification_test.php b/tests/notification/notification_test.php index 24a9d2e686..307f67ac10 100644 --- a/tests/notification/notification_test.php +++ b/tests/notification/notification_test.php @@ -160,6 +160,8 @@ class phpbb_notification_test extends phpbb_tests_notification_base 'post_subject' => 'Re: test-title', 'forum_id' => 2, 'forum_name' => 'Your first forum', + 'post_username' => '', + 'post_text' => 'test text', )); $this->db->sql_query('INSERT INTO ' . BOOKMARKS_TABLE . ' ' . $this->db->sql_build_array('INSERT', array( @@ -176,6 +178,8 @@ class phpbb_notification_test extends phpbb_tests_notification_base 'post_subject' => 'Re: test-title', 'forum_id' => 2, 'forum_name' => 'Your first forum', + 'post_username' => '', + 'post_text' => 'test text', )); $this->notifications->delete_subscription('test'); @@ -267,6 +271,9 @@ class phpbb_notification_test extends phpbb_tests_notification_base 'post_subject' => 'Re: test-title2', // change post_subject 'forum_id' => 3, // change forum_id 'forum_name' => 'Your second forum', // change forum_name + 'post_username' => '', + 'post_text' => 'test text2', + 'post_time' => 1349413325, )); $this->assert_notifications( diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php index b940a3237f..393ae245e1 100644 --- a/tests/notification/submit_post_base.php +++ b/tests/notification/submit_post_base.php @@ -39,6 +39,9 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c 'bbcode_bitfield' => '', 'bbcode_uid' => '', 'post_edit_locked' => false, + 'notify_set' => 0, + 'notify' => false, + 'forum_name' => 'Test forum name', //'force_approved_state' => 1, ); @@ -102,6 +105,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c 'username' => 'user-name', 'is_registered' => true, 'user_colour' => '', + 'user_lastmark' => 0, ); // Request diff --git a/tests/notification/submit_post_type_topic_test.php b/tests/notification/submit_post_type_topic_test.php index a2adfcdda8..e5da423903 100644 --- a/tests/notification/submit_post_type_topic_test.php +++ b/tests/notification/submit_post_type_topic_test.php @@ -135,9 +135,10 @@ class phpbb_notification_submit_post_type_topic_test extends phpbb_notification_ $this->db->sql_freeresult($result); $result = $this->db->sql_query( - 'SELECT * - FROM ' . POSTS_TABLE . ' - WHERE post_id = ' . $reply_id); + 'SELECT p.*, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted, t.topic_first_post_id, t.topic_last_post_id + FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t + WHERE p.topic_id = t.topic_id + AND p.post_id = ' . $reply_id); $reply_edit_data = array_merge($this->post_data, $this->db->sql_fetchrow($result), array( 'force_approved_state' => false, 'post_edit_reason' => 'PHPBB3-12370', diff --git a/tests/notification/user_list_trim_test.php b/tests/notification/user_list_trim_test.php index 0542d6ab78..f4cebda515 100644 --- a/tests/notification/user_list_trim_test.php +++ b/tests/notification/user_list_trim_test.php @@ -51,7 +51,10 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case $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'); - $user->data = array('user_lang' => 'en'); + $user->data = [ + 'user_id' => 1, + 'user_lang' => 'en', + ]; $lang->add_lang('common'); $user_loader = new phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE); diff --git a/tests/profilefields/manager_test.php b/tests/profilefields/manager_test.php index 51b627e226..5503061fa6 100644 --- a/tests/profilefields/manager_test.php +++ b/tests/profilefields/manager_test.php @@ -66,6 +66,8 @@ class manager_test extends phpbb_database_test_case $language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)); $collection = new \phpbb\di\service_collection($container); $user = new \phpbb\user($language, '\phpbb\datetime'); + $user->data['user_id'] = 2; + $user->ip = ''; $this->log = new \phpbb\log\log($this->db, $user, $auth, $dispatcher, $phpbb_root_path, 'adm/', $phpEx, $table_prefix . 'log'); diff --git a/tests/profilefields/type_bool_test.php b/tests/profilefields/type_bool_test.php index 302a24ee9c..9683bdfe7b 100644 --- a/tests/profilefields/type_bool_test.php +++ b/tests/profilefields/type_bool_test.php @@ -67,8 +67,10 @@ class phpbb_profilefield_type_bool_test extends phpbb_test_case 'lang_id' => 1, 'lang_name' => 'field', 'field_required' => false, - 'field_default_value' => 1, - 'field_length' => 1, + 'field_default_value' => 1, + 'field_length' => 1, + 'field_show_novalue' => null, + 'field_novalue' => null, ); $this->options = array( diff --git a/tests/profilefields/type_date_test.php b/tests/profilefields/type_date_test.php index f671a52fd9..442931fe62 100644 --- a/tests/profilefields/type_date_test.php +++ b/tests/profilefields/type_date_test.php @@ -61,6 +61,8 @@ class phpbb_profilefield_type_date_test extends phpbb_test_case 'lang_id' => 1, 'lang_name' => 'field', 'field_required' => false, + 'field_show_novalue' => null, + 'field_novalue' => null, ); } diff --git a/tests/profilefields/type_dropdown_test.php b/tests/profilefields/type_dropdown_test.php index 5234c0141a..270c82d75a 100644 --- a/tests/profilefields/type_dropdown_test.php +++ b/tests/profilefields/type_dropdown_test.php @@ -69,6 +69,7 @@ class phpbb_profilefield_type_dropdown_test extends phpbb_test_case 'field_required' => false, 'field_validation' => '.*', 'field_novalue' => 0, + 'field_show_novalue' => null, ); $this->dropdown_options = array( @@ -156,7 +157,7 @@ class phpbb_profilefield_type_dropdown_test extends phpbb_test_case 'Field should output nothing for empty value', ), array( - '', + null, // Since PHP 8, '' == 0 returns false, hence use null instead of '' (empty string) array('field_show_novalue' => false), null, 'Field should simply output null for empty value', @@ -187,7 +188,7 @@ class phpbb_profilefield_type_dropdown_test extends phpbb_test_case 'Field should return the correct raw value', ), array( - '', + null, // Since PHP 8, '' == 0 returns false, hence use null instead of '' (empty string) array('field_show_novalue' => false), null, 'Field should null for empty value without show_novalue', diff --git a/tests/profilefields/type_int_test.php b/tests/profilefields/type_int_test.php index 6088c5a03f..c03c9d6123 100644 --- a/tests/profilefields/type_int_test.php +++ b/tests/profilefields/type_int_test.php @@ -50,6 +50,10 @@ class phpbb_profilefield_type_int_test extends phpbb_test_case 'lang_id' => 1, 'lang_name' => 'field', 'field_required' => false, + 'field_show_novalue' => null, + 'field_novalue' => null, + 'field_minlen' => null, + 'field_maxlen' => null, ); } diff --git a/tests/profilefields/type_string_test.php b/tests/profilefields/type_string_test.php index 90362ddc97..9dc96fecfc 100644 --- a/tests/profilefields/type_string_test.php +++ b/tests/profilefields/type_string_test.php @@ -53,6 +53,10 @@ class phpbb_profilefield_type_string_test extends phpbb_test_case 'lang_name' => 'field', 'field_required' => false, 'field_validation' => '.*', + 'field_show_novalue' => null, + 'field_novalue' => null, + 'field_minlen' => null, + 'field_maxlen' => null, ); } diff --git a/tests/profilefields/type_url_test.php b/tests/profilefields/type_url_test.php index 6ec1193d3c..db0aa43a9c 100644 --- a/tests/profilefields/type_url_test.php +++ b/tests/profilefields/type_url_test.php @@ -56,6 +56,10 @@ class phpbb_profilefield_type_url_test extends phpbb_test_case 'lang_id' => 1, 'lang_name' => 'field', 'field_required' => false, + 'field_show_novalue' => null, + 'field_novalue' => null, + 'field_minlen' => null, + 'field_maxlen' => null, ); } diff --git a/tests/session/check_ban_test.php b/tests/session/check_ban_test.php index 96e550609e..ef92ad5451 100644 --- a/tests/session/check_ban_test.php +++ b/tests/session/check_ban_test.php @@ -43,6 +43,16 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case parent::setUp(); // Get session here so that config is mocked correctly $this->session = $this->session_factory->get_session($this->db); + $this->session->data['user_id'] = ANONYMOUS; // Don't get into the session_kill() procedure + $this->session->lang = [ + 'BOARD_BAN_TIME' => 'BOARD_BAN_TIME', + 'BOARD_BAN_PERM' => 'BOARD_BAN_PERM', + 'BOARD_BAN_REASON' => 'BOARD_BAN_REASON', + 'BAN_TRIGGERED_BY_EMAIL' => 'BAN_TRIGGERED_BY_EMAIL', + 'BAN_TRIGGERED_BY_IP' => 'BAN_TRIGGERED_BY_IP', + 'BAN_TRIGGERED_BY_USER' => 'BAN_TRIGGERED_BY_USER', + ]; + global $cache, $config, $phpbb_root_path, $phpEx, $phpbb_filesystem; $phpbb_filesystem = new \phpbb\filesystem\filesystem(); diff --git a/tests/session/session_key_test.php b/tests/session/session_key_test.php index 2499ea1d55..2a62da2eb5 100644 --- a/tests/session/session_key_test.php +++ b/tests/session/session_key_test.php @@ -34,6 +34,8 @@ class phpbb_session_login_keys_test extends phpbb_session_test_case $session->cookie_data['k'] = $this->key_id; // Try to access session with the session key + global $request, $symfony_request, $phpbb_filesystem, $phpbb_root_path; + $session->page = $session->extract_current_page($phpbb_root_path); $session->session_create(false, false, false); $this->assertEquals($this->user_id, $session->data['user_id'], 'User should be logged in by the session key'); } @@ -45,6 +47,8 @@ class phpbb_session_login_keys_test extends phpbb_session_test_case $session = $this->session_factory->get_session($this->db); // Reset of the keys for this user + $session->cookie_data['k'] = $this->key_id; + $session->data['user_id'] = $this->user_id; $session->reset_login_keys($this->user_id); // Using a user_id and key that was in the database (before reset) @@ -52,6 +56,8 @@ class phpbb_session_login_keys_test extends phpbb_session_test_case $session->cookie_data['k'] = $this->key_id; // Try to access session with the session key + global $request, $symfony_request, $phpbb_filesystem, $phpbb_root_path; + $session->page = $session->extract_current_page($phpbb_root_path); $session->session_create(false, false, $this->user_id); $this->assertNotEquals($this->user_id, $session->data['user_id'], 'User is not logged in because the session key is invalid'); diff --git a/tests/session/testable_facade.php b/tests/session/testable_facade.php index 05858c8a63..2a2b24fb27 100644 --- a/tests/session/testable_facade.php +++ b/tests/session/testable_facade.php @@ -94,10 +94,12 @@ class phpbb_session_testable_facade $this->session_factory->merge_config_data($config_overrides); // Bots $this->session_factory->merge_cache_data(array('_bots' => $bot_overrides)); - global $request; + global $request, $symfony_request, $phpbb_filesystem, $phpbb_root_path; $session = $this->session_factory->get_session($this->db); $session->browser = $user_agent; $session->ip = $ip_address; + $session->page = $session->extract_current_page($phpbb_root_path); + // Uri sid if ($uri_sid) { diff --git a/tests/template/extension_test.php b/tests/template/extension_test.php index d633001060..1d2221bb09 100644 --- a/tests/template/extension_test.php +++ b/tests/template/extension_test.php @@ -32,6 +32,8 @@ class phpbb_template_extension_test extends phpbb_template_template_test_case global $auth, $request, $symfony_request, $user; $user = new phpbb_mock_user(); $user->optionset('user_id', 2); + $user->style['style_path'] = ''; + $user->data['user_id'] = 2; $auth = $this->getMockBuilder('phpbb\auth\auth') ->disableOriginalConstructor() ->setMethods(['acl_get']) diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 51d519a2b1..fa84cb9770 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -493,7 +493,8 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array( 'loop_expressions.html', array(), - array('loop' => array(array(),array(),array(),array(),array(),array()),), + // Do not use 'loop' as a block name to not override Twig's internal 'loop' object + array('loop1' => array(array(),array(),array(),array(),array(),array()),), array(), 'yesnononoyesnoyesnonoyesnono', ), diff --git a/tests/template/templates/loop_expressions.html b/tests/template/templates/loop_expressions.html index ddb9fd52fa..e983c0cc42 100644 --- a/tests/template/templates/loop_expressions.html +++ b/tests/template/templates/loop_expressions.html @@ -1,11 +1,11 @@ - + -yesno +yesno - + - + -yesno +yesno - + diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 0f174d6cca..a77278441e 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -725,6 +725,8 @@ class phpbb_functional_test_case extends phpbb_test_case new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), '\phpbb\datetime' )); + $user->data['user_id'] = 2; // admin + $user->ip = ''; $auth = $this->createMock('\phpbb\auth\auth'); $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); @@ -762,6 +764,8 @@ class phpbb_functional_test_case extends phpbb_test_case new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), '\phpbb\datetime' )); + $user->data['user_id'] = 2; // admin + $user->ip = ''; $auth = $this->createMock('\phpbb\auth\auth'); $phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE); diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index ce394fc510..347f70f3c9 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -531,6 +531,14 @@ class phpbb_test_case_helpers if ($container->has('user')) { $user = $container->get('user'); + + // Set default required user data if not set + $user->data['is_bot'] = $user->data['is_bot'] ?? false; + $user->data['is_registered'] = $user->data['is_registered'] ?? false; + $user->data['style_id'] = $user->data['style_id'] ?? 1; + $user->data['user_id'] = $user->data['user_id'] ?? ANONYMOUS; + $user->data['user_options'] = $user->data['user_options'] ?? 230271; + $user->style['style_id'] = $user->style['style_id'] ?? 1; } else { @@ -545,6 +553,14 @@ class phpbb_test_case_helpers ->method('format_date') ->will($this->test_case->returnCallback(__CLASS__ . '::format_date')); + // Set default required user data + $user->data['is_bot'] = false; + $user->data['is_registered'] = false; + $user->data['style_id'] = 1; + $user->data['user_id'] = ANONYMOUS; + $user->data['user_options'] = 230271; + $user->style['style_id'] = 1; + $user->date_format = 'Y-m-d H:i:s'; $user->optionset('viewcensors', true); $user->optionset('viewflash', true); @@ -555,11 +571,6 @@ class phpbb_test_case_helpers } $user->add_lang('common'); - if (!isset($user->style)) - { - $user->style = array('style_id' => 1); - } - // Create and register a quote_helper $quote_helper = new \phpbb\textformatter\s9e\quote_helper( $container->get('user'), diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php index 672069590a..f34c656359 100644 --- a/tests/text_formatter/s9e/renderer_test.php +++ b/tests/text_formatter/s9e/renderer_test.php @@ -61,7 +61,10 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case ->getMock(); $factory->expects($this->once()) ->method('regenerate') - ->will($this->returnValue(array('parser' => $mock))); + ->will($this->returnValue([ + 'parser' => $mock, + 'renderer' => $mock, + ])); $renderer = new \phpbb\textformatter\s9e\renderer( $cache, @@ -160,6 +163,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case $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'); + $user->data['user_options'] = 230271; $user->optionset('viewcensors', false); $phpbb_container->set('user', $user); @@ -175,6 +179,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case $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'); + $user->data['user_options'] = 230271; $user->optionset('viewcensors', false); $config = new \phpbb\config\config(array('allow_nocensors' => true)); @@ -193,6 +198,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case $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'); + $user->data['user_options'] = 230271; $user->optionset('viewcensors', false); $config = new \phpbb\config\config(array('allow_nocensors' => true)); @@ -222,6 +228,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case $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'); + $user->data['user_options'] = 230271; $user->optionset('viewflash', false); $phpbb_container->set('user', $user); @@ -241,6 +248,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case $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'); + $user->data['user_options'] = 230271; $user->optionset('viewimg', false); $phpbb_container->set('user', $user); @@ -260,7 +268,8 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case $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'); - $user->optionset('smilies', false); + $user->data['user_options'] = 230271; + $user->optionset('viewsmilies', false); $phpbb_container->set('user', $user); } diff --git a/tests/text_processing/generate_text_for_display_test.php b/tests/text_processing/generate_text_for_display_test.php index 8429c16c3a..64ab695c6e 100644 --- a/tests/text_processing/generate_text_for_display_test.php +++ b/tests/text_processing/generate_text_for_display_test.php @@ -37,6 +37,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca $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'); + $user->data['user_options'] = 230271; $user->optionset('viewcensors', true); $user->optionset('viewflash', true); $user->optionset('viewimg', true); @@ -72,6 +73,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca $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'); + $user->data['user_options'] = 230271; // Do not ignore word censoring by user (switch censoring on in UCP) $user->optionset('viewcensors', true); @@ -172,6 +174,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca $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'); + $user->data['user_options'] = 230271; $user->optionset('viewflash', false); $phpbb_container->set('user', $user); @@ -192,6 +195,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca $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'); + $user->data['user_options'] = 230271; $user->optionset('viewimg', false); $phpbb_container->set('user', $user); @@ -212,7 +216,8 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca $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'); - $user->optionset('smilies', false); + $user->data['user_options'] = 230271; + $user->optionset('viewsmilies', false); $phpbb_container->set('user', $user); } diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php index ca9259d357..2f55b7e83a 100644 --- a/tests/upload/fileupload_test.php +++ b/tests/upload/fileupload_test.php @@ -183,7 +183,13 @@ class phpbb_fileupload_test extends phpbb_test_case ->set_max_filesize(1000); copy($this->path . 'jpg', $this->path . 'jpg.jpg'); - $file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg'); + // Upload file data should be set to prevent "Undefined array key" PHP 8 warning + $filedata = [ + 'size' => 519, + 'realname' => $this->path . 'jpg.jpg', + 'type' => false, + ]; + $file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg', $filedata); $this->assertEquals(0, count($file->error)); $this->assertFalse($file->additional_checks()); $this->assertTrue($file->move_file('../tests/upload/fixture/copies', true)); @@ -197,7 +203,13 @@ class phpbb_fileupload_test extends phpbb_test_case ->set_max_filesize(1000); copy($this->path . 'jpg', $this->path . 'jpg.jpg'); - $file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg'); + // Upload file data should be set to prevent "Undefined array key" PHP 8 warning + $filedata = [ + 'size' => 519, + 'realname' => $this->path . 'jpg.jpg', + 'type' => false, + ]; + $file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg', $filedata); $this->assertEquals(0, count($file->error)); $this->assertFalse($file->move_file('../tests/upload/fixture')); $this->assertFalse($file->get('file_moved')); @@ -212,7 +224,13 @@ class phpbb_fileupload_test extends phpbb_test_case copy($this->path . 'jpg', $this->path . 'jpg.jpg'); copy($this->path . 'jpg', $this->path . 'copies/jpg.jpg'); - $file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg'); + // Upload file data should be set to prevent "Undefined array key" PHP 8 warning + $filedata = [ + 'size' => 519, + 'realname' => $this->path . 'jpg.jpg', + 'type' => false, + ]; + $file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg', $filedata); $this->assertEquals(0, count($file->error)); $file->move_file('../tests/upload/fixture/copies', true); $this->assertEquals(0, count($file->error)); diff --git a/tests/version/version_test.php b/tests/version/version_test.php index dec9bdc42b..e5101b3c6e 100644 --- a/tests/version/version_test.php +++ b/tests/version/version_test.php @@ -350,13 +350,19 @@ class phpbb_version_helper_test extends phpbb_test_case array( '1.0' => array( 'current' => '1.0.1', + 'eol' => false, + 'security' => false, ), '1.1' => array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array( 'current' => '1.0.1', + 'eol' => false, + 'security' => false, ), ), array( @@ -364,9 +370,13 @@ class phpbb_version_helper_test extends phpbb_test_case array( '1.0' => array( 'current' => '1.0.1', + 'eol' => false, + 'security' => false, ), '1.1' => array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array(), @@ -376,13 +386,19 @@ class phpbb_version_helper_test extends phpbb_test_case array( '1.0' => array( 'current' => '1.0.1-a2', + 'eol' => false, + 'security' => false, ), '1.1' => array( 'current' => '1.1.0', + 'eol' => false, + 'security' => false, ), ), array( 'current' => '1.0.1-a2', + 'eol' => false, + 'security' => false, ), ), array( @@ -390,13 +406,19 @@ class phpbb_version_helper_test extends phpbb_test_case array( '1.0' => array( 'current' => '1.0.1', + 'eol' => false, + 'security' => false, ), '1.1' => array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array( @@ -404,9 +426,13 @@ class phpbb_version_helper_test extends phpbb_test_case array( '1.0' => array( 'current' => '1.0.1', + 'eol' => false, + 'security' => false, ), '1.1' => array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array(), @@ -416,13 +442,19 @@ class phpbb_version_helper_test extends phpbb_test_case array( '1.0' => array( 'current' => '1.0.1', + 'eol' => false, + 'security' => false, ), '1.1' => array( 'current' => '1.1.0-a2', + 'eol' => false, + 'security' => false, ), ), array( 'current' => '1.1.0-a2', + 'eol' => false, + 'security' => false, ), ), array( @@ -436,14 +468,18 @@ class phpbb_version_helper_test extends phpbb_test_case array( '1.0' => array( 'current' => '1.0.1', + 'eol' => false, 'security' => '1.0.1', ), '1.1' => array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array( 'current' => '1.0.1', + 'eol' => false, 'security' => '1.0.1', ), ), @@ -453,14 +489,18 @@ class phpbb_version_helper_test extends phpbb_test_case array( '1.0' => array( 'current' => '1.0.1', + 'eol' => false, 'security' => '1.0.0', ), '1.1' => array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array( 'current' => '1.0.1', + 'eol' => false, 'security' => '1.0.0', ), ), @@ -470,14 +510,19 @@ class phpbb_version_helper_test extends phpbb_test_case array( '1.0' => array( 'current' => '1.0.1', + 'eol' => false, 'security' => '1.1.0', ), '1.1' => array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), // Latest 1.0 release is EOL @@ -487,13 +532,18 @@ class phpbb_version_helper_test extends phpbb_test_case '1.0' => array( 'current' => '1.0.1', 'eol' => true, + 'security' => false, ), '1.1' => array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), // All are EOL -- somewhat undefined behavior @@ -503,10 +553,12 @@ class phpbb_version_helper_test extends phpbb_test_case '1.0' => array( 'current' => '1.0.1', 'eol' => true, + 'security' => false, ), '1.1' => array( 'current' => '1.1.1', 'eol' => true, + 'security' => false, ), ), array(), @@ -557,10 +609,14 @@ class phpbb_version_helper_test extends phpbb_test_case array( '3.1' => array( 'current' => '1.0.1', + 'eol' => false, + 'security' => false, ), ), array( 'current' => '1.0.1', + 'eol' => false, + 'security' => false, ), ), array( @@ -569,6 +625,8 @@ class phpbb_version_helper_test extends phpbb_test_case array( '3.1' => array( 'current' => '1.0.1', + 'eol' => false, + 'security' => false, ), ), array(), @@ -579,10 +637,14 @@ class phpbb_version_helper_test extends phpbb_test_case array( '3.2' => array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array( @@ -591,6 +653,8 @@ class phpbb_version_helper_test extends phpbb_test_case array( '3.2' => array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array(), @@ -602,10 +666,14 @@ class phpbb_version_helper_test extends phpbb_test_case array( '3.2' => array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array( @@ -614,6 +682,8 @@ class phpbb_version_helper_test extends phpbb_test_case array( '3.2' => array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array(), @@ -624,10 +694,14 @@ class phpbb_version_helper_test extends phpbb_test_case array( '3.1' => array( 'current' => '1.0.1', + 'eol' => false, + 'security' => false, ), ), array( 'current' => '1.0.1', + 'eol' => false, + 'security' => false, ), ), array( @@ -636,6 +710,8 @@ class phpbb_version_helper_test extends phpbb_test_case array( '3.1' => array( 'current' => '1.0.1', + 'eol' => false, + 'security' => false, ), ), array(), @@ -646,10 +722,14 @@ class phpbb_version_helper_test extends phpbb_test_case array( '3.2' => array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array( @@ -658,6 +738,8 @@ class phpbb_version_helper_test extends phpbb_test_case array( '3.2' => array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array(), @@ -669,13 +751,19 @@ class phpbb_version_helper_test extends phpbb_test_case array( '3.1' => array( 'current' => '1.0.1', + 'eol' => false, + 'security' => false, ), '3.2' => array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array( 'current' => '1.0.1', + 'eol' => false, + 'security' => false, ), ), array( @@ -684,9 +772,13 @@ class phpbb_version_helper_test extends phpbb_test_case array( '3.1' => array( 'current' => '1.0.1', + 'eol' => false, + 'security' => false, ), '3.2' => array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array(), @@ -697,9 +789,13 @@ class phpbb_version_helper_test extends phpbb_test_case array( '3.1' => array( 'current' => '1.0.1', + 'eol' => false, + 'security' => false, ), '3.2' => array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array(), @@ -710,13 +806,19 @@ class phpbb_version_helper_test extends phpbb_test_case array( '3.1' => array( 'current' => '1.0.1', + 'eol' => false, + 'security' => false, ), '3.2' => array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array( @@ -725,13 +827,19 @@ class phpbb_version_helper_test extends phpbb_test_case array( '3.1' => array( 'current' => '1.0.1', + 'eol' => false, + 'security' => false, ), '3.2' => array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array( @@ -740,9 +848,13 @@ class phpbb_version_helper_test extends phpbb_test_case array( '3.1' => array( 'current' => '1.0.1', + 'eol' => false, + 'security' => false, ), '3.2' => array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array(), @@ -754,13 +866,19 @@ class phpbb_version_helper_test extends phpbb_test_case array( '3.1' => array( 'current' => '1.0.1', + 'eol' => false, + 'security' => false, ), '3.2' => array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array( @@ -769,13 +887,19 @@ class phpbb_version_helper_test extends phpbb_test_case array( '3.1' => array( 'current' => '1.0.1', + 'eol' => false, + 'security' => false, ), '3.2' => array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array( @@ -784,13 +908,19 @@ class phpbb_version_helper_test extends phpbb_test_case array( '3.1' => array( 'current' => '1.0.1', + 'eol' => false, + 'security' => false, ), '3.2' => array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array( @@ -799,9 +929,13 @@ class phpbb_version_helper_test extends phpbb_test_case array( '3.1' => array( 'current' => '1.0.1', + 'eol' => false, + 'security' => false, ), '3.2' => array( 'current' => '1.1.1', + 'eol' => false, + 'security' => false, ), ), array(), diff --git a/travis/setup-phpbb.sh b/travis/setup-phpbb.sh index 8d23865d08..ed736517b2 100755 --- a/travis/setup-phpbb.sh +++ b/travis/setup-phpbb.sh @@ -41,6 +41,6 @@ php ../composer.phar install --dev --no-interaction if [ "$TRAVIS_PHP_VERSION" == "nightly" ] then php ../composer.phar remove phpunit/dbunit --dev --update-with-dependencies \ - && php ../composer.phar require symfony/yaml:~4.4 misantron/dbunit:~5.0 nikic/php-parser:~4.7 phpunit/phpunit:^9.3 --dev --update-with-all-dependencies --ignore-platform-reqs + && php ../composer.phar require symfony/yaml:~4.4 misantron/dbunit:~5.0 phpunit/phpunit:^9.3 --dev --update-with-all-dependencies --ignore-platform-reqs fi cd .. From cc753db132da695823853eb16d5b504cca070147 Mon Sep 17 00:00:00 2001 From: rxu Date: Fri, 14 Aug 2020 14:10:20 +0700 Subject: [PATCH 13/17] [ticket/16549] Fix new tests PHPBB3-16549 --- tests/functional/ucp_profile_test.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/functional/ucp_profile_test.php b/tests/functional/ucp_profile_test.php index 10d3cb2da1..18839a5a68 100644 --- a/tests/functional/ucp_profile_test.php +++ b/tests/functional/ucp_profile_test.php @@ -86,14 +86,14 @@ class phpbb_functional_ucp_profile_test extends phpbb_functional_test_case $key_id = substr($db->sql_fetchfield('key_id'), 0, 8); $db->sql_freeresult($result); - $this->assertContains($key_id, $crawler->filter('label[for="' . $key_id . '"]')->text()); + $this->assertStringContainsString($key_id, $crawler->filter('label[for="' . $key_id . '"]')->text()); $form = $crawler->selectButton('submit')->form(); $form['keys'][0]->tick(); $crawler = self::submit($form); - $this->assertContains($this->lang('AUTOLOGIN_SESSION_KEYS_DELETED'), $crawler->filter('html')->text()); + $this->assertStringContainsString($this->lang('AUTOLOGIN_SESSION_KEYS_DELETED'), $crawler->filter('html')->text()); $crawler = self::request('GET', 'ucp.php?i=ucp_profile&mode=autologin_keys'); - $this->assertContains($this->lang('PROFILE_NO_AUTOLOGIN_KEYS'), $crawler->filter('tbody > tr > td[class="bg1"]')->text()); + $this->assertStringContainsString($this->lang('PROFILE_NO_AUTOLOGIN_KEYS'), $crawler->filter('tbody > tr > td[class="bg1"]')->text()); } } From fff200b1d87e12bffb488af51fe770ad73efe00c Mon Sep 17 00:00:00 2001 From: rxu Date: Thu, 10 Sep 2020 20:19:21 +0700 Subject: [PATCH 14/17] [ticket/16549] Rename class phpbb_lint_test rather than the test file PHPBB3-16549 --- .travis.yml | 2 +- phpunit.xml.dist | 4 ++-- tests/functions_user/whois_test.php | 2 +- tests/{phpbb_lint_test.php => lint_test.php} | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) rename tests/{phpbb_lint_test.php => lint_test.php} (98%) diff --git a/.travis.yml b/.travis.yml index 48c32b4ed3..75cee6660c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -45,7 +45,7 @@ script: - travis/check-doctum-parse-errors.sh $DB $TRAVIS_PHP_VERSION $NOTESTS - travis/check-image-icc-profiles.sh $DB $TRAVIS_PHP_VERSION $NOTESTS - travis/check-executable-files.sh $DB $TRAVIS_PHP_VERSION $NOTESTS ./ - - sh -c "if [ '$SLOWTESTS' != '1' -a '$DB' = 'mysqli' ]; then phpBB/vendor/bin/phpunit tests/phpbb_lint_test.php; fi" + - sh -c "if [ '$SLOWTESTS' != '1' -a '$DB' = 'mysqli' ]; then phpBB/vendor/bin/phpunit tests/lint_test.php; fi" - sh -c "if [ '$NOTESTS' != '1' -a '$SLOWTESTS' != '1' ]; then phpBB/vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.xml --verbose --stop-on-error; fi" - sh -c "if [ '$SLOWTESTS' = '1' ]; then phpBB/vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.xml --group slow; fi" - sh -c "set -x;if [ '$NOTESTS' = '1' -a '$TRAVIS_PULL_REQUEST' != 'false' ]; then git remote set-branches --add origin $TRAVIS_BRANCH && git fetch && git-tools/commit-msg-hook-range.sh origin/$TRAVIS_BRANCH..$TRAVIS_PULL_REQUEST_SHA; fi" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 642537e50d..6888fe0357 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -14,13 +14,13 @@ ./tests ./tests/functional - ./tests/phpbb_lint_test.php + ./tests/lint_test.php ./tests/functional - ./tests/phpbb_lint_test.php + ./tests/lint_test.php diff --git a/tests/functions_user/whois_test.php b/tests/functions_user/whois_test.php index b99854ba60..0ab5bc0ef6 100644 --- a/tests/functions_user/whois_test.php +++ b/tests/functions_user/whois_test.php @@ -11,7 +11,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php'; class phpbb_functions_user_whois_test extends phpbb_test_case { - public function setUp() + public function setUp(): void { global $config, $phpbb_dispatcher, $user, $request, $symfony_request, $phpbb_root_path, $phpEx; diff --git a/tests/phpbb_lint_test.php b/tests/lint_test.php similarity index 98% rename from tests/phpbb_lint_test.php rename to tests/lint_test.php index 172a399c7e..6486441f18 100644 --- a/tests/phpbb_lint_test.php +++ b/tests/lint_test.php @@ -11,7 +11,7 @@ * */ -class phpbb_lint_test extends phpbb_test_case +class lint_test extends phpbb_test_case { static protected $php_binary; static protected $exclude; From fe38280a1a3336c38297d5004d483940a30d1915 Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 18 Oct 2020 14:47:03 +0700 Subject: [PATCH 15/17] [ticket/16549] Fix tests 1. If $service array is empty, $service[0] call will throw fatal error in PHP 8. 2. Division by zero was promoted to fatal error and throws DivisionByZeroError exception in PHP 8+ 3. Adjust make_clickable() logic to avoid 'Undefined array key 3' error. PHPBB3-16549 --- phpBB/includes/functions_content.php | 2 +- tests/error_collector_test.php | 10 ++++++---- tests/mock/container_builder.php | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index bfd6b179cd..28d07bac7d 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -1011,7 +1011,7 @@ function make_clickable($text, $server_url = false, string $class = 'postlink') if (preg_match($magic_args[0], $text, $matches)) { // Only apply $class from the corresponding function call argument (excepting emails which never has a class) - if ($magic_args[3] != $static_class && $magic_args[1] != MAGIC_URL_EMAIL) + if ($magic_args[1] != MAGIC_URL_EMAIL && $magic_args[3] != $static_class) { continue; } diff --git a/tests/error_collector_test.php b/tests/error_collector_test.php index e1bbd89f12..6073eac6fe 100644 --- a/tests/error_collector_test.php +++ b/tests/error_collector_test.php @@ -28,7 +28,8 @@ class phpbb_error_collector_test extends phpbb_test_case $collector->install(); // Cause a warning - 1/0; $line = __LINE__; + // Division by zero was promoted to fatal error and throws DivisionByZeroError exception in PHP 8+ + version_compare(PHP_VERSION, '8', '>=') ? '1b'['0xFF'] : 1/0; $line = __LINE__; $collector->uninstall(); @@ -39,7 +40,7 @@ class phpbb_error_collector_test extends phpbb_test_case // Unfortunately $error_contents will contain the full path here, // because the tests directory is outside of phpbb root path. - $this->assertStringStartsWith('Errno 2: Division by zero at ', $error_contents); + $this->assertStringStartsWith(version_compare(PHP_VERSION, '8', '>=') ? 'Errno 2: Illegal string offset "0xFF" at ' : 'Errno 2: Division by zero at ', $error_contents); $this->assertStringEndsWith(" line $line", $error_contents); } @@ -49,7 +50,8 @@ class phpbb_error_collector_test extends phpbb_test_case $collector->install(); // Cause a warning - 1/0; $line = __LINE__; + // Division by zero was promoted to fatal error and throws DivisionByZeroError exception in PHP 8+ + version_compare(PHP_VERSION, '8', '>=') ? '1b'['0xFF'] : 1/0; $line = __LINE__; // Cause a "Notice: unserialize(): Error at offset 0 of 27 bytes in ..." // "Undefined array index" used earlier was promoted to warning in PHP 8.0, @@ -69,7 +71,7 @@ class phpbb_error_collector_test extends phpbb_test_case // Unfortunately $error_contents will contain the full path here, // because the tests directory is outside of phpbb root path. - $this->assertStringStartsWith('Errno 2: Division by zero at ', $error_contents); + $this->assertStringStartsWith(version_compare(PHP_VERSION, '8', '>=') ? 'Errno 2: Illegal string offset "0xFF" at ' : 'Errno 2: Division by zero at ', $error_contents); $this->assertStringEndsWith(" line $line", $error_contents); } } diff --git a/tests/mock/container_builder.php b/tests/mock/container_builder.php index 17c4ae22dd..31513d0f31 100644 --- a/tests/mock/container_builder.php +++ b/tests/mock/container_builder.php @@ -59,7 +59,7 @@ class phpbb_mock_container_builder implements ContainerInterface if ($this->has($id)) { $service = $this->services[$id]; - if (is_array($service) && is_callable($service[0])) + if (is_array($service) && isset($service[0]) && is_callable($service[0])) { return call_user_func_array($service[0], $service[1]); } From eb754e3a840f31f1edb541dca8e8bc238b8f523c Mon Sep 17 00:00:00 2001 From: rxu Date: Sat, 14 Nov 2020 23:18:52 +0700 Subject: [PATCH 16/17] [ticket/16549] Fix database testcase transactions handling, fix indentations PHPBB3-16549 --- tests/test_framework/phpbb_database_test_case.php | 8 ++++---- .../phpbb_database_test_connection_manager.php | 6 +++++- tests/test_framework/phpbb_test_case.php | 8 ++++---- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index ecfc948793..ebaf573753 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -372,8 +372,8 @@ abstract class phpbb_database_test_case extends TestCase * PHPUnit deprecates several methods and properties in its recent versions * Provide BC layer to be able to test in multiple environment settings */ - public function expectException(string $exception): void - { + public function expectException(string $exception): void + { if (version_compare(self::$phpunit_version, '9.0', '>=')) { switch ($exception) { @@ -408,8 +408,8 @@ abstract class phpbb_database_test_case extends TestCase * PHPUnit deprecates several methods and properties in its recent versions * Provide BC layer to be able to test in multiple environment settings */ - public static function assertFileNotExists(string $filename, string $message = ''): void - { + public static function assertFileNotExists(string $filename, string $message = ''): void + { if (version_compare(self::$phpunit_version, '9.0', '>=')) { parent::assertFileDoesNotExist($filename, $message); diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php index fec4709fbd..c32ebf0c71 100644 --- a/tests/test_framework/phpbb_database_test_connection_manager.php +++ b/tests/test_framework/phpbb_database_test_connection_manager.php @@ -392,12 +392,16 @@ class phpbb_database_test_connection_manager { $this->pdo->beginTransaction(); } - else if ($query === 'commit') + else if ($query === 'commit' && $this->pdo->inTransaction()) { $this->pdo->commit(); } else { + if (!$this->pdo->inTransaction()) + { + $this->pdo->beginTransaction(); + } $this->pdo->exec($query); } } diff --git a/tests/test_framework/phpbb_test_case.php b/tests/test_framework/phpbb_test_case.php index cb48de23d4..726f6671ae 100644 --- a/tests/test_framework/phpbb_test_case.php +++ b/tests/test_framework/phpbb_test_case.php @@ -88,8 +88,8 @@ class phpbb_test_case extends TestCase * PHPUnit deprecates several methods and properties in its recent versions * Provide BC layer to be able to test in multiple environment settings */ - public function expectException(string $exception): void - { + public function expectException(string $exception): void + { if (version_compare(self::$phpunit_version, '9.0', '>=')) { switch ($exception) { @@ -124,8 +124,8 @@ class phpbb_test_case extends TestCase * PHPUnit deprecates several methods and properties in its recent versions * Provide BC layer to be able to test in multiple environment settings */ - public static function assertFileNotExists(string $filename, string $message = ''): void - { + public static function assertFileNotExists(string $filename, string $message = ''): void + { if (version_compare(self::$phpunit_version, '9.0', '>=')) { parent::assertFileDoesNotExist($filename, $message); From f1c178b5447bbea380faf794514823916d0b961a Mon Sep 17 00:00:00 2001 From: rxu Date: Sat, 14 Nov 2020 22:21:15 +0700 Subject: [PATCH 17/17] [ticket/16549] Rewrite at() calls See https://github.com/sebastianbergmann/phpunit/issues/4297 PHPBB3-16549 --- tests/auth/provider_apache_test.php | 20 ++-- tests/dbal/db_tools_test.php | 17 ++- tests/help/manager_test.php | 116 +++++++++------------ tests/text_formatter/s9e/factory_test.php | 17 +-- tests/text_formatter/s9e/parser_test.php | 52 +++++---- tests/text_formatter/s9e/renderer_test.php | 26 ++--- 6 files changed, 100 insertions(+), 148 deletions(-) diff --git a/tests/auth/provider_apache_test.php b/tests/auth/provider_apache_test.php index d1154fd9b6..3690a55cee 100644 --- a/tests/auth/provider_apache_test.php +++ b/tests/auth/provider_apache_test.php @@ -67,14 +67,10 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case ->with('PHP_AUTH_USER', \phpbb\request\request_interface::SERVER) ->will($this->returnValue(true)); - $this->request->expects($this->at(1)) + $this->request->expects($this->exactly(2)) ->method('server') - ->with('PHP_AUTH_USER') - ->will($this->returnValue('foobar')); - $this->request->expects($this->at(2)) - ->method('server') - ->with('PHP_AUTH_PW') - ->will($this->returnValue('example')); + ->withConsecutive(['PHP_AUTH_USER'], ['PHP_AUTH_PW']) + ->will($this->onConsecutiveCalls($this->returnValue('foobar'), $this->returnValue('example'))); $expected = array( 'status' => LOGIN_SUCCESS, @@ -99,14 +95,10 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case ->with('PHP_AUTH_USER', \phpbb\request\request_interface::SERVER) ->will($this->returnValue(true)); - $this->request->expects($this->at(1)) + $this->request->expects($this->exactly(2)) ->method('server') - ->with('PHP_AUTH_USER') - ->will($this->returnValue('foobar')); - $this->request->expects($this->at(2)) - ->method('server') - ->with('PHP_AUTH_PW') - ->will($this->returnValue('example')); + ->withConsecutive(['PHP_AUTH_USER'], ['PHP_AUTH_PW']) + ->will($this->onConsecutiveCalls($this->returnValue('foobar'), $this->returnValue('example'))); $expected = array( 'user_id' => 1, diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php index 37cdedaaf5..9ee48c8412 100644 --- a/tests/dbal/db_tools_test.php +++ b/tests/dbal/db_tools_test.php @@ -356,11 +356,8 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case ->will($this->returnValue(true)); // drop tables - $db_tools->expects($this->exactly(2))->method('sql_table_drop'); - $db_tools->expects($this->at(1))->method('sql_table_drop') - ->with($this->equalTo('dropped_table_1')); - $db_tools->expects($this->at(3))->method('sql_table_drop') - ->with($this->equalTo('dropped_table_2')); + $db_tools->expects($this->exactly(2))->method('sql_table_drop') + ->withConsecutive([$this->equalTo('dropped_table_1')], [$this->equalTo('dropped_table_2')]); $db_tools->perform_schema_changes(array( 'drop_tables' => array( @@ -384,11 +381,11 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case ->will($this->returnValue(true)); // drop columns - $db_tools->expects($this->exactly(2))->method('sql_column_remove'); - $db_tools->expects($this->at(1))->method('sql_column_remove') - ->with($this->equalTo('existing_table'), $this->equalTo('dropped_column_1')); - $db_tools->expects($this->at(3))->method('sql_column_remove') - ->with($this->equalTo('existing_table'), $this->equalTo('dropped_column_2')); + $db_tools->expects($this->exactly(2))->method('sql_column_remove') + ->withConsecutive( + [$this->equalTo('existing_table'), $this->equalTo('dropped_column_1')], + [$this->equalTo('existing_table'), $this->equalTo('dropped_column_2')] + ); $db_tools->perform_schema_changes(array( 'drop_columns' => array( diff --git a/tests/help/manager_test.php b/tests/help/manager_test.php index e841a23a53..02695806b6 100644 --- a/tests/help/manager_test.php +++ b/tests/help/manager_test.php @@ -64,44 +64,33 @@ class phpbb_help_manager_test extends phpbb_test_case */ public function test_add_block($block_name, $switch, $questions, $switch_expected) { - $this->language->expects($this->at(0)) - ->method('lang') - ->with($block_name) - ->willReturn(strtoupper($block_name)); - $lang_call_count = 1; + $question_ary = $question_ary_upper = $template_call_args = []; foreach ($questions as $question => $answer) { - $this->language->expects($this->at($lang_call_count)) - ->method('lang') - ->with($question) - ->willReturn(strtoupper($question)); - $lang_call_count++; - - $this->language->expects($this->at($lang_call_count)) - ->method('lang') - ->with($answer) - ->willReturn(strtoupper($answer)); - $lang_call_count++; - } - - $this->template->expects($this->at(0)) - ->method('assign_block_vars') - ->with('faq_block', array( - 'BLOCK_TITLE' => strtoupper($block_name), - 'SWITCH_COLUMN' => $switch_expected, - )); - $template_call_count = 1; - foreach ($questions as $question => $answer) - { - $this->template->expects($this->at($template_call_count)) - ->method('assign_block_vars') - ->with('faq_block.faq_row', array( + $question_ary = array_merge($question_ary, [[$question], [$answer]]); + $question_ary_upper = array_merge($question_ary_upper, [strtoupper($question), strtoupper($answer)]); + $template_call_args = array_merge($template_call_args, [['faq_block.faq_row', [ 'FAQ_QUESTION' => strtoupper($question), 'FAQ_ANSWER' => strtoupper($answer), - )); - $template_call_count++; + ] + ]]); } + $this->language->expects($this->exactly(count($questions)*2 + 1)) + ->method('lang') + ->withConsecutive([$block_name], ...$question_ary) + ->will($this->onConsecutiveCalls(strtoupper($block_name), ...$question_ary_upper)); + + $this->template->expects($this->exactly(count($questions) + 1)) + ->method('assign_block_vars') + ->withConsecutive( + ['faq_block', [ + 'BLOCK_TITLE' => strtoupper($block_name), + 'SWITCH_COLUMN' => $switch_expected, + ]], + ...$template_call_args + ); + $this->manager->add_block($block_name, $switch, $questions); $this->assertEquals($switch_expected, $this->manager->switched_column()); @@ -110,8 +99,8 @@ class phpbb_help_manager_test extends phpbb_test_case public function add_question_data() { return array( - array('abc', false, false), - array('def', true, true), + array('question1', 'answer1'), + array('question2', 'answer2'), ); } @@ -123,14 +112,13 @@ class phpbb_help_manager_test extends phpbb_test_case */ public function test_add_question($question, $answer) { - $this->language->expects($this->at(0)) + $this->language->expects($this->exactly(2)) ->method('lang') - ->with($question) - ->willReturn(strtoupper($question)); - $this->language->expects($this->at(1)) - ->method('lang') - ->with($answer) - ->willReturn(strtoupper($answer)); + ->withConsecutive( + [$question], + [$answer] + ) + ->will($this->onConsecutiveCalls(strtoupper($question), strtoupper($answer))); $this->template->expects($this->once()) ->method('assign_block_vars') @@ -144,41 +132,33 @@ class phpbb_help_manager_test extends phpbb_test_case public function test_add_block_double_switch() { - $block_name = 'abc'; - $switch_expected = true; + $block_name = ['abc', 'def']; + $switch_expected = [true, false]; - $this->language->expects($this->at(0)) + $this->language->expects($this->exactly(2)) ->method('lang') - ->with($block_name) - ->willReturn(strtoupper($block_name)); + ->withConsecutive([$block_name[0]], [$block_name[1]]) + ->will($this->onConsecutiveCalls(strtoupper($block_name[0]), strtoupper($block_name[1]))); - $this->template->expects($this->at(0)) + $this->template->expects($this->exactly(2)) ->method('assign_block_vars') - ->with('faq_block', array( - 'BLOCK_TITLE' => strtoupper($block_name), - 'SWITCH_COLUMN' => $switch_expected, - )); + ->withConsecutive( + ['faq_block', [ + 'BLOCK_TITLE' => strtoupper($block_name[0]), + 'SWITCH_COLUMN' => $switch_expected[0], + ]], + ['faq_block', [ + 'BLOCK_TITLE' => strtoupper($block_name[1]), + 'SWITCH_COLUMN' => $switch_expected[1], + ]] + + ); - $this->manager->add_block($block_name, true); + $this->manager->add_block($block_name[0], true); $this->assertTrue($this->manager->switched_column()); // Add a second block with switch - $block_name = 'def'; - $switch_expected = false; - - $this->language->expects($this->at(0)) - ->method('lang') - ->with($block_name) - ->willReturn(strtoupper($block_name)); - - $this->template->expects($this->at(0)) - ->method('assign_block_vars') - ->with('faq_block', array( - 'BLOCK_TITLE' => strtoupper($block_name), - 'SWITCH_COLUMN' => $switch_expected, - )); - - $this->manager->add_block($block_name, true); + $this->manager->add_block($block_name[1], true); $this->assertTrue($this->manager->switched_column()); } } diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php index f57bbdd6dc..d9ba86b05d 100644 --- a/tests/text_formatter/s9e/factory_test.php +++ b/tests/text_formatter/s9e/factory_test.php @@ -288,22 +288,13 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case { $this->dispatcher = $this->createMock('phpbb\\event\\dispatcher_interface'); $this->dispatcher - ->expects($this->at(0)) + ->expects($this->exactly(2)) ->method('trigger_event') - ->with( - 'core.text_formatter_s9e_configure_before', - $this->callback(array($this, 'configure_event_callback')) + ->withConsecutive( + ['core.text_formatter_s9e_configure_before', $this->callback(array($this, 'configure_event_callback'))], + ['core.text_formatter_s9e_configure_after', $this->callback(array($this, 'configure_event_callback'))] ) ->will($this->returnArgument(1)); - $this->dispatcher - ->expects($this->at(1)) - ->method('trigger_event') - ->with( - 'core.text_formatter_s9e_configure_after', - $this->callback(array($this, 'configure_event_callback')) - ) - ->will($this->returnArgument(1)); - $this->get_factory()->get_configurator(); } diff --git a/tests/text_formatter/s9e/parser_test.php b/tests/text_formatter/s9e/parser_test.php index e10ebd29ee..ef9a1184ee 100644 --- a/tests/text_formatter/s9e/parser_test.php +++ b/tests/text_formatter/s9e/parser_test.php @@ -101,15 +101,19 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case public function test_options($adapter_method, $adapter_arg, $concrete_method, $concrete_arg) { $mock = $this->getMockBuilder('s9e\\TextFormatter\\Parser') - ->setMethods(array($concrete_method)) + ->setMethods([$concrete_method]) ->disableOriginalConstructor() ->getMock(); - foreach ((array) $concrete_arg as $i => $concrete_arg) - { - $mock->expects($this->at($i)) - ->method($concrete_method) - ->with($concrete_arg); - } + + $concrete_args = (array) $concrete_arg; + array_walk($concrete_args, function(&$value) + { + $value = (array) $value; + } + ); + $mock->expects($this->exactly(count($concrete_args))) + ->method($concrete_method) + ->withConsecutive(...$concrete_args); $cache = new phpbb_mock_cache; $cache->put('_foo_parser', $mock); @@ -141,11 +145,11 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case ), array( 'disable_magic_url', null, - 'disablePlugin', array('Autoemail', 'Autolink') + 'disablePlugin', ['Autoemail', 'Autolink'] ), array( 'disable_smilies', null, - 'disablePlugin', 'Emoticons' + 'disablePlugin', ['Emoticons', 'Emoji'] ), array( 'enable_bbcode', 'url', @@ -157,11 +161,11 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case ), array( 'enable_magic_url', null, - 'enablePlugin', array('Autoemail', 'Autolink') + 'enablePlugin', ['Autoemail', 'Autolink'] ), array( 'enable_smilies', null, - 'enablePlugin', 'Emoticons' + 'enablePlugin', ['Emoticons', 'Emoji'] ) ); } @@ -207,22 +211,6 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case ->expects($this->any()) ->method('trigger_event') ->will($this->returnArgument(1)); - $dispatcher - ->expects($this->at(1)) - ->method('trigger_event') - ->with( - 'core.text_formatter_s9e_parse_before', - $this->callback(array($this, 'parse_before_event_callback')) - ) - ->will($this->returnArgument(1)); - $dispatcher - ->expects($this->at(2)) - ->method('trigger_event') - ->with( - 'core.text_formatter_s9e_parse_after', - $this->callback(array($this, 'parse_after_event_callback')) - ) - ->will($this->returnArgument(1)); $parser = new \phpbb\textformatter\s9e\parser( $container->get('cache.driver'), @@ -230,6 +218,16 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case $container->get('text_formatter.s9e.factory'), $dispatcher ); + + $dispatcher + ->expects($this->exactly(2)) + ->method('trigger_event') + ->withConsecutive( + ['core.text_formatter_s9e_parse_before', $this->callback(array($this, 'parse_before_event_callback'))], + ['core.text_formatter_s9e_parse_after', $this->callback(array($this, 'parse_after_event_callback'))] + ) + ->will($this->returnArgument(1)); + $parser->parse('...'); } diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php index f34c656359..69075ebaca 100644 --- a/tests/text_formatter/s9e/renderer_test.php +++ b/tests/text_formatter/s9e/renderer_test.php @@ -438,22 +438,6 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case ->expects($this->any()) ->method('trigger_event') ->will($this->returnArgument(1)); - $dispatcher - ->expects($this->at(1)) - ->method('trigger_event') - ->with( - 'core.text_formatter_s9e_render_before', - $this->callback(array($this, 'render_before_event_callback')) - ) - ->will($this->returnArgument(1)); - $dispatcher - ->expects($this->at(2)) - ->method('trigger_event') - ->with( - 'core.text_formatter_s9e_render_after', - $this->callback(array($this, 'render_after_event_callback')) - ) - ->will($this->returnArgument(1)); $renderer = new \phpbb\textformatter\s9e\renderer( $container->get('cache.driver'), @@ -462,6 +446,16 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case $container->get('text_formatter.s9e.factory'), $dispatcher ); + + $dispatcher + ->expects($this->exactly(2)) + ->method('trigger_event') + ->withConsecutive( + ['core.text_formatter_s9e_render_before', $this->callback(array($this, 'render_before_event_callback'))], + ['core.text_formatter_s9e_render_after', $this->callback(array($this, 'render_after_event_callback'))] + ) + ->will($this->returnArgument(1)); + $renderer->render('...'); }