aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/RUNNING_TESTS.md19
-rw-r--r--tests/acp_board/select_auth_method_test.php2
-rw-r--r--tests/attachment/delete_test.php11
-rw-r--r--tests/attachment/manager_test.php2
-rw-r--r--tests/attachment/resync_test.php2
-rw-r--r--tests/attachment/upload_test.php15
-rw-r--r--tests/auth/fixtures/user.xml12
-rw-r--r--tests/auth/fixtures/user_533.xml39
-rw-r--r--tests/auth/provider_apache_test.php122
-rw-r--r--tests/auth/provider_db_test.php37
-rw-r--r--tests/auth/provider_ldap_test.php94
-rw-r--r--tests/auth/provider_oauth_token_storage_test.php12
-rw-r--r--tests/avatar/manager_test.php35
-rw-r--r--tests/bbcode/parser_test.php1
-rw-r--r--tests/bootstrap.php2
-rw-r--r--tests/cache/apc_driver_test.php57
-rw-r--r--tests/cache/apcu_driver_test.php5
-rw-r--r--tests/cache/cache_memory_test.php2
-rw-r--r--tests/cache/common_test_case.php3
-rw-r--r--tests/cache/dummy_driver_test.php4
-rw-r--r--tests/cache/file_driver_test.php12
-rw-r--r--tests/cache/memcached_test.php65
-rw-r--r--tests/cache/redis_driver_test.php11
-rw-r--r--tests/captcha/qa_test.php2
-rw-r--r--tests/class_loader/class_loader_test.php4
-rw-r--r--tests/compress/compress_test.php4
-rw-r--r--tests/config/db_test.php2
-rw-r--r--tests/config/db_text_test.php2
-rw-r--r--tests/console/cache/purge_test.php15
-rw-r--r--tests/console/config/config_test.php4
-rw-r--r--tests/console/cron/cron_list_test.php34
-rw-r--r--tests/console/cron/run_test.php98
-rw-r--r--tests/console/thumbnail_test.php8
-rw-r--r--tests/console/update/check_test.php2
-rw-r--r--tests/console/user/activate_test.php2
-rw-r--r--tests/console/user/add_test.php5
-rw-r--r--tests/console/user/base.php11
-rw-r--r--tests/console/user/delete_test.php6
-rw-r--r--tests/content_visibility/delete_post_test.php4
-rw-r--r--tests/content_visibility/fixtures/get_visibility_sql.xml23
-rw-r--r--tests/content_visibility/get_forums_visibility_sql_test.php2
-rw-r--r--tests/content_visibility/get_global_visibility_sql_test.php2
-rw-r--r--tests/content_visibility/get_visibility_sql_test.php76
-rw-r--r--tests/content_visibility/set_post_visibility_test.php4
-rw-r--r--tests/content_visibility/set_topic_visibility_test.php2
-rw-r--r--tests/controller/common_helper_route.php8
-rw-r--r--tests/controller/controller_test.php7
-rw-r--r--tests/cron/manager_test.php31
-rw-r--r--tests/dbal/auto_increment_test.php4
-rw-r--r--tests/dbal/db_tools_test.php20
-rw-r--r--tests/dbal/migration/if.php4
-rw-r--r--tests/dbal/migration/if_params.php44
-rw-r--r--tests/dbal/migration/recall.php2
-rw-r--r--tests/dbal/migration/recall_params.php42
-rw-r--r--tests/dbal/migrator_test.php52
-rw-r--r--tests/dbal/migrator_tool_config_test.php2
-rw-r--r--tests/dbal/migrator_tool_config_text_test.php2
-rw-r--r--tests/dbal/migrator_tool_module_test.php4
-rw-r--r--tests/dbal/migrator_tool_permission_test.php2
-rw-r--r--tests/dbal/sql_affected_rows_test.php2
-rw-r--r--tests/dbal/sql_insert_buffer_test.php2
-rw-r--r--tests/di/create_container_test.php14
-rw-r--r--tests/di/fixtures/config/production/container/environment.yml3
-rw-r--r--tests/di/fixtures/config/test/container/environment.yml3
-rw-r--r--tests/di/fixtures/ext/vendor/enabled_4/environment.yml2
-rw-r--r--tests/di/ordered_service_collection_test.php2
-rw-r--r--tests/di/service_collection_test.php27
-rw-r--r--tests/email/email_parsing_test.php16
-rw-r--r--tests/error_collector_test.php2
-rw-r--r--tests/event/exception_listener_test.php2
-rw-r--r--tests/event/export_php_test.php2
-rw-r--r--tests/event/php_exporter_test.php22
-rw-r--r--tests/extension/ext/vendor5/foo/composer.json23
-rw-r--r--tests/extension/ext/vendor5/foo/ext.php19
-rw-r--r--tests/extension/extension_base_test.php2
-rw-r--r--tests/extension/finder_test.php4
-rw-r--r--tests/extension/manager_test.php4
-rw-r--r--tests/extension/metadata_manager_test.php6
-rw-r--r--tests/extension/modules_test.php4
-rw-r--r--tests/feed/attachments_base_test.php6
-rw-r--r--tests/files/types_base_test.php8
-rw-r--r--tests/files/types_form_test.php6
-rw-r--r--tests/files/types_local_test.php4
-rw-r--r--tests/files/types_remote_test.php6
-rw-r--r--tests/files/upload_test.php4
-rw-r--r--tests/filesystem/clean_path_test.php2
-rw-r--r--tests/filesystem/is_absolute_test.php2
-rw-r--r--tests/filesystem/realpath_test.php2
-rw-r--r--tests/functional/acp_bbcodes_test.php40
-rw-r--r--tests/functional/acp_permissions_test.php2
-rw-r--r--tests/functional/acp_profile_field_test.php2
-rw-r--r--tests/functional/acp_users_test.php2
-rw-r--r--tests/functional/common_avatar_test_case.php2
-rw-r--r--tests/functional/controllers_compatibility_test.php8
-rw-r--r--tests/functional/extension_acp_test.php24
-rw-r--r--tests/functional/extension_controller_test.php11
-rw-r--r--tests/functional/extension_global_lang_test.php6
-rw-r--r--tests/functional/extension_module_test.php2
-rw-r--r--tests/functional/extension_permission_lang_test.php6
-rw-r--r--tests/functional/feed_test.php2
-rw-r--r--tests/functional/fileupload_form_test.php4
-rw-r--r--tests/functional/fileupload_remote_test.php6
-rw-r--r--tests/functional/forgot_password_test.php8
-rw-r--r--tests/functional/metadata_manager_test.php4
-rw-r--r--tests/functional/plupload_test.php4
-rw-r--r--tests/functional/prune_shadow_topic_test.php11
-rw-r--r--tests/functional/subforum_test.php113
-rw-r--r--tests/functional/ucp_pm_test.php2
-rw-r--r--tests/functional/user_password_reset_test.php93
-rw-r--r--tests/functional/visibility_unapproved_posts_test.php356
-rw-r--r--tests/functions/build_url_test.php4
-rw-r--r--tests/functions/convert_30_dbms_to_31_test.php1
-rw-r--r--tests/functions/fixtures/validate_email.xml4
-rw-r--r--tests/functions/generate_string_list.php2
-rw-r--r--tests/functions/get_remote_file_test.php2
-rw-r--r--tests/functions/make_clickable_email_test.php2
-rw-r--r--tests/functions/make_clickable_test.php2
-rw-r--r--tests/functions/obtain_online_test.php5
-rw-r--r--tests/functions/phpbb_get_banned_user_ids.php4
-rw-r--r--tests/functions/user_delete_test.php38
-rw-r--r--tests/functions/validate_date_test.php2
-rw-r--r--tests/functions/validate_email_test.php2
-rw-r--r--tests/functions/validate_jabber_test.php4
-rw-r--r--tests/functions/validate_lang_iso_test.php2
-rw-r--r--tests/functions/validate_match_test.php2
-rw-r--r--tests/functions/validate_num_test.php2
-rw-r--r--tests/functions/validate_password_test.php2
-rw-r--r--tests/functions/validate_string_test.php2
-rw-r--r--tests/functions/validate_user_email_test.php2
-rw-r--r--tests/functions/validate_username_test.php6
-rw-r--r--tests/functions/validate_with_method_test.php2
-rw-r--r--tests/functions_acp/build_select_test.php2
-rw-r--r--tests/functions_acp/h_radio_test.php2
-rw-r--r--tests/functions_acp/validate_config_vars_test.php2
-rw-r--r--tests/functions_acp/validate_range_test.php2
-rw-r--r--tests/functions_content/get_username_string_test.php2
-rw-r--r--tests/functions_content/phpbb_format_quote_test.php2
-rw-r--r--tests/functions_privmsgs/get_max_setting_from_group_test.php2
-rw-r--r--tests/functions_user/delete_user_test.php25
-rw-r--r--tests/functions_user/group_user_attributes_test.php5
-rw-r--r--tests/group/helper_test_case.php2
-rw-r--r--tests/groupposition/legend_test.php2
-rw-r--r--tests/groupposition/teampage_test.php2
-rw-r--r--tests/help/manager_test.php2
-rw-r--r--tests/installer/database_helper_test.php2
-rw-r--r--tests/installer/installer_config_test.php5
-rw-r--r--tests/installer/module_base_test.php4
-rw-r--r--tests/language/language_test.php2
-rw-r--r--tests/lint_test.php5
-rw-r--r--tests/lock/db_test.php2
-rw-r--r--tests/log/add_test.php4
-rw-r--r--tests/log/delete_test.php6
-rw-r--r--tests/log/function_add_log_test.php4
-rw-r--r--tests/log/function_view_log_test.php6
-rw-r--r--tests/mcp/post_ip_test.php2
-rw-r--r--tests/migrator/convert_timezones_test.php2
-rw-r--r--tests/migrator/get_callable_from_step_test.php5
-rw-r--r--tests/migrator/get_schema_steps_test.php2
-rw-r--r--tests/migrator/reverse_update_data_test.php2
-rw-r--r--tests/migrator/schema_generator_test.php6
-rw-r--r--tests/mimetype/guesser_test.php4
-rw-r--r--tests/mock/cache.php8
-rw-r--r--tests/mock/container_builder.php15
-rw-r--r--tests/mock/session_testable.php6
-rw-r--r--tests/network/checkdnsrr_test.php67
-rw-r--r--tests/network/inet_ntop_pton_test.php56
-rw-r--r--tests/notification/base.php2
-rw-r--r--tests/notification/convert_test.php2
-rw-r--r--tests/notification/fixtures/services_notification.yml2
-rw-r--r--tests/notification/group_request_test.php4
-rw-r--r--tests/notification/submit_post_base.php10
-rw-r--r--tests/notification/submit_post_type_bookmark_test.php2
-rw-r--r--tests/notification/submit_post_type_post_in_queue_test.php2
-rw-r--r--tests/notification/submit_post_type_post_test.php2
-rw-r--r--tests/notification/submit_post_type_quote_test.php2
-rw-r--r--tests/notification/submit_post_type_topic_test.php4
-rw-r--r--tests/notification/user_list_trim_test.php4
-rw-r--r--tests/pagination/pagination_test.php6
-rw-r--r--tests/passwords/drivers_test.php57
-rw-r--r--tests/passwords/manager_test.php160
-rw-r--r--tests/path_helper/path_helper_test.php8
-rw-r--r--tests/profilefields/type_bool_test.php18
-rw-r--r--tests/profilefields/type_date_test.php8
-rw-r--r--tests/profilefields/type_dropdown_test.php18
-rw-r--r--tests/profilefields/type_googleplus_test.php6
-rw-r--r--tests/profilefields/type_int_test.php8
-rw-r--r--tests/profilefields/type_string_test.php8
-rw-r--r--tests/profilefields/type_url_test.php8
-rw-r--r--tests/random/gen_rand_string_test.php2
-rw-r--r--tests/regex/email_test.php6
-rw-r--r--tests/regex/ipv4_test.php2
-rw-r--r--tests/regex/ipv6_test.php2
-rw-r--r--tests/request/deactivated_super_global_test.php2
-rw-r--r--tests/request/request_test.php6
-rw-r--r--tests/request/request_var_test.php2
-rw-r--r--tests/request/type_cast_helper_test.php2
-rw-r--r--tests/search/mysql_test.php2
-rw-r--r--tests/search/native_test.php2
-rw-r--r--tests/search/postgres_test.php2
-rw-r--r--tests/security/base.php4
-rw-r--r--tests/security/hash_test.php4
-rw-r--r--tests/security/redirect_test.php4
-rw-r--r--tests/session/check_ban_test.php7
-rw-r--r--tests/session/fixtures/sessions_garbage.xml45
-rw-r--r--tests/session/garbage_collection_test.php88
-rw-r--r--tests/session/testable_factory.php4
-rw-r--r--tests/template/context_test.php4
-rw-r--r--tests/template/extension_test.php258
-rw-r--r--tests/template/template_allfolder_test.php4
-rw-r--r--tests/template/template_events_test.php4
-rw-r--r--tests/template/template_includecss_test.php4
-rw-r--r--tests/template/template_test.php4
-rw-r--r--tests/template/template_test_case.php8
-rw-r--r--tests/template/template_test_case_with_tree.php4
-rw-r--r--tests/template/templates/avatar_user.html1
-rw-r--r--tests/template/templates/expressions.html2
-rw-r--r--tests/template/templates/extension_config_test.html1
-rw-r--r--tests/template/templates/extension_username_test.html1
-rw-r--r--tests/test_framework/phpbb_database_test_case.php26
-rw-r--r--tests/test_framework/phpbb_database_test_connection_manager.php16
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php90
-rw-r--r--tests/test_framework/phpbb_session_test_case.php28
-rw-r--r--tests/test_framework/phpbb_test_case.php12
-rw-r--r--tests/test_framework/phpbb_test_case_helpers.php45
-rw-r--r--tests/test_framework/phpbb_ui_test_case.php96
-rw-r--r--tests/text_formatter/s9e/acp_utils_test.php79
-rw-r--r--tests/text_formatter/s9e/factory_test.php4
-rw-r--r--tests/text_formatter/s9e/parser_test.php6
-rw-r--r--tests/text_formatter/s9e/renderer_test.php10
-rw-r--r--tests/text_processing/decode_message_test.php2
-rw-r--r--tests/text_processing/generate_text_for_display_test.php4
-rw-r--r--tests/text_processing/generate_text_for_storage_test.php2
-rw-r--r--tests/text_reparser/base_test.php2
-rw-r--r--tests/text_reparser/manager_test.php2
-rw-r--r--tests/text_reparser/plugins/contact_admin_info_test.php2
-rw-r--r--tests/text_reparser/plugins/poll_option_test.php2
-rw-r--r--tests/text_reparser/plugins/test_row_based_plugin.php2
-rw-r--r--tests/tree/nestedset_forum_base.php2
-rw-r--r--tests/upload/filespec_test.php8
-rw-r--r--tests/upload/fileupload_test.php10
-rw-r--r--tests/upload/imagesize_test.php2
-rw-r--r--tests/user/user_loader_test.php2
-rw-r--r--tests/version/version_fetch_test.php4
-rw-r--r--tests/version/version_helper_remote_test.php8
-rw-r--r--tests/version/version_test.php2
-rw-r--r--tests/viewonline/helper_test.php2
-rw-r--r--tests/wrapper/phpbb_php_ini_test.php2
247 files changed, 2668 insertions, 994 deletions
diff --git a/tests/RUNNING_TESTS.md b/tests/RUNNING_TESTS.md
index 12ae7fa687..54db823b4a 100644
--- a/tests/RUNNING_TESTS.md
+++ b/tests/RUNNING_TESTS.md
@@ -30,11 +30,9 @@ Some of the functionality in phpBB and/or the test suite uses additional
PHP extensions. If these extensions are not loaded, respective tests
will be skipped:
-- apc (APC cache driver, php5 only)
- apcu (APCu cache driver - native API, php7+)
- apcu_bc, apcu (APCu cache driver - APC API, php7+)
- bz2 (compress tests)
-- mysql, pdo_mysql (MySQL database driver)
- mysqli, pdo_mysql (MySQLi database driver)
- pcntl (flock class)
- pdo (any database tests)
@@ -52,7 +50,7 @@ By default all tests requiring a database connection will use sqlite. If you
do not have sqlite installed the tests will be skipped. If you wish to run the
tests on a different database you have to create a test_config.php file within
your tests directory following the same format as phpBB's config.php. Testing
-makes use of a seperate database defined in this config file and before running
+makes use of a separate database defined in this config file and before running
the tests each time this database is deleted. An example for mysqli can be
found below. More information on configuration options can be found on the
wiki (see below).
@@ -111,6 +109,21 @@ Or via environment variables as follows:
$ PHPBB_TEST_REDIS_HOST=localhost PHPBB_TEST_REDIS_PORT=6379 phpunit
+Memcached
+---------
+
+In order to run tests for the memcached cache driver, at least one of memcached
+host or port must be specified in the test configuration. This can be done via
+test_config.php as follows:
+
+ <?php
+ $phpbb_memcached_host = 'localhost';
+ $phpbb_memcached_port = '11211';
+
+Or via environment variables as follows:
+
+ $ PHPBB_TEST_MEMCACHED_HOST=localhost PHPBB_TEST_MEMCACHED_PORT=11211 phpunit
+
Running
=======
diff --git a/tests/acp_board/select_auth_method_test.php b/tests/acp_board/select_auth_method_test.php
index 16e5954c64..3cb8ea7cd6 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()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/attachment/delete_test.php b/tests/attachment/delete_test.php
index f1835dd37a..59669c87e9 100644
--- a/tests/attachment/delete_test.php
+++ b/tests/attachment/delete_test.php
@@ -24,6 +24,9 @@ class phpbb_attachment_delete_test extends \phpbb_database_test_case
/** @var \phpbb\filesystem\filesystem */
protected $filesystem;
+ /** @var \phpbb\event\dispatcher_interface */
+ protected $dispatcher;
+
/** @var \phpbb\attachment\resync */
protected $resync;
@@ -37,9 +40,9 @@ class phpbb_attachment_delete_test extends \phpbb_database_test_case
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/resync.xml');
}
- public function setUp()
+ public function setUp(): void
{
- global $db, $phpbb_root_path;
+ global $phpbb_root_path;
parent::setUp();
@@ -47,7 +50,7 @@ class phpbb_attachment_delete_test extends \phpbb_database_test_case
$this->db = $this->new_dbal();
$db = $this->db;
$this->resync = new \phpbb\attachment\resync($this->db);
- $this->filesystem = $this->getMock('\phpbb\filesystem\filesystem', array('remove', 'exists'));
+ $this->filesystem = $this->createMock('\phpbb\filesystem\filesystem', array('remove', 'exists'));
$this->filesystem->expects($this->any())
->method('remove')
->willReturn(false);
@@ -103,7 +106,7 @@ class phpbb_attachment_delete_test extends \phpbb_database_test_case
*/
public function test_attachment_delete_success($remove_success, $exists_success, $expected, $throw_exception = false)
{
- $this->filesystem = $this->getMock('\phpbb\filesystem\filesystem', array('remove', 'exists'));
+ $this->filesystem = $this->createMock('\phpbb\filesystem\filesystem', array('remove', 'exists'));
if ($throw_exception)
{
$this->filesystem->expects($this->any())
diff --git a/tests/attachment/manager_test.php b/tests/attachment/manager_test.php
index 47d7f38b1d..c440dcf101 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()
+ public 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 f882af9ae5..de5ead5bff 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()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/attachment/upload_test.php b/tests/attachment/upload_test.php
index 235ecd082a..a3f51dd34e 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()
+ public function setUp(): void
{
global $config, $phpbb_root_path, $phpEx;
@@ -81,7 +81,7 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
$config = $this->config;
$this->db = $this->new_dbal();
$this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\dummy(), $this->config, $this->db, $phpbb_root_path, $phpEx);
- $this->request = $this->getMock('\phpbb\request\request');
+ $this->request = $this->createMock('\phpbb\request\request');
$this->filesystem = new \phpbb\filesystem\filesystem();
$this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
@@ -336,14 +336,14 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
*/
public function test_image_upload($is_image, $plupload_active, $config_data, $expected)
{
- $filespec = $this->getMock('\phpbb\files\filespec',
- array(
+ $filespec = $this->getMockBuilder('\phpbb\files\filespec')
+ ->setMethods(array(
'init_error',
'is_image',
'move_file',
'is_uploaded',
- ),
- array(
+ ))
+ ->setConstructorArgs(array(
$this->filesystem,
$this->language,
$this->php_ini,
@@ -351,7 +351,8 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
$this->phpbb_root_path,
$this->mimetype_guesser,
$this->plupload
- ));
+ ))
+ ->getMock();
foreach ($config_data as $key => $value)
{
$this->config[$key] = $value;
diff --git a/tests/auth/fixtures/user.xml b/tests/auth/fixtures/user.xml
index 1e0eb6ee49..33f69a9067 100644
--- a/tests/auth/fixtures/user.xml
+++ b/tests/auth/fixtures/user.xml
@@ -1,5 +1,17 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dataset>
+ <table name="phpbb_groups">
+ <column>group_id</column>
+ <column>group_name</column>
+ <column>group_type</column>
+ <column>group_desc</column>
+ <row>
+ <value>1</value>
+ <value>REGISTERED</value>
+ <value>3</value>
+ <value>foobar</value>
+ </row>
+ </table>
<table name="phpbb_users">
<column>user_id</column>
<column>username</column>
diff --git a/tests/auth/fixtures/user_533.xml b/tests/auth/fixtures/user_533.xml
deleted file mode 100644
index 9731e4db4a..0000000000
--- a/tests/auth/fixtures/user_533.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" ?>
-<dataset>
- <table name="phpbb_users">
- <column>user_id</column>
- <column>username</column>
- <column>username_clean</column>
- <column>user_password</column>
- <column>user_passchg</column>
- <column>user_email</column>
- <column>user_type</column>
- <column>user_login_attempts</column>
- <column>user_permissions</column>
- <column>user_sig</column>
- <row>
- <value>1</value>
- <value>foobar</value>
- <value>foobar</value>
- <value>$2a$10$e01Syh9PbJjUkio66eFuUu4FhCE2nRgG7QPc1JACalsPXcIuG2bbi</value>
- <value>0</value>
- <value>example@example.com</value>
- <value>0</value>
- <value>0</value>
- <value></value>
- <value></value>
- </row>
- <row>
- <value>2</value>
- <value>foobar2</value>
- <value>foobar2</value>
- <value>$H$9E45lK6J8nLTSm9oJE5aNCSTFK9wqa/</value>
- <value>0</value>
- <value>example@example.com</value>
- <value>0</value>
- <value>0</value>
- <value></value>
- <value></value>
- </row>
- </table>
-</dataset>
diff --git a/tests/auth/provider_apache_test.php b/tests/auth/provider_apache_test.php
index 7d77d763fb..0f9169ff8b 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()
+ protected function setup(): void
{
parent::setUp();
@@ -27,42 +27,15 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case
$config = new \phpbb\config\config(array());
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$lang = new \phpbb\language\language($lang_loader);
- $this->request = $this->getMock('\phpbb\request\request');
- $this->user = new \phpbb\user($lang, '\phpbb\datetime');
- $driver_helper = new \phpbb\passwords\driver\helper($config);
- $passwords_drivers = array(
- 'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($config, $driver_helper),
- 'passwords.driver.bcrypt' => new \phpbb\passwords\driver\bcrypt($config, $driver_helper),
- 'passwords.driver.salted_md5' => new \phpbb\passwords\driver\salted_md5($config, $driver_helper),
- 'passwords.driver.phpass' => new \phpbb\passwords\driver\phpass($config, $driver_helper),
- );
-
- $passwords_helper = new \phpbb\passwords\helper;
- // Set up passwords manager
- $passwords_manager = new \phpbb\passwords\manager($config, $passwords_drivers, $passwords_helper, array_keys($passwords_drivers));
-
- if (version_compare(PHP_VERSION, '5.3.7', '<'))
- {
- $this->password_hash = '$2a$10$e01Syh9PbJjUkio66eFuUu4FhCE2nRgG7QPc1JACalsPXcIuG2bbi';
- }
- else
- {
- $this->password_hash = '$2y$10$4RmpyVu2y8Yf/lP3.yQBquKvE54TCUuEDEBJYY6FDDFN3LcbCGz9i';
- }
+ $this->request = $this->createMock('\phpbb\request\request');
+ $this->user = new \phpbb\user($lang, '\phpbb\datetime');;
- $this->provider = new \phpbb\auth\provider\apache($db, $config, $passwords_manager, $this->request, $this->user, $phpbb_root_path, $phpEx);
+ $this->provider = new \phpbb\auth\provider\apache($config, $db, $lang, $this->request, $this->user, $phpbb_root_path, $phpEx);
}
public function getDataSet()
{
- if ((version_compare(PHP_VERSION, '5.3.7', '<')))
- {
- return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/user_533.xml');
- }
- else
- {
- return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/user.xml');
- }
+ return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/user.xml');
}
/**
@@ -109,7 +82,7 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case
'user_row' => array(
'user_id' => '1',
'username' => 'foobar',
- 'user_password' => $this->password_hash,
+ 'user_password' => '$2y$10$4RmpyVu2y8Yf/lP3.yQBquKvE54TCUuEDEBJYY6FDDFN3LcbCGz9i',
'user_passchg' => '0',
'user_email' => 'example@example.com',
'user_type' => '0',
@@ -136,62 +109,61 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case
->will($this->returnValue('example'));
$expected = array(
- 'user_id' => '1',
- 'user_type' => '0',
- 'group_id' => '3',
+ 'user_id' => 1,
+ 'user_type' => 0,
+ 'group_id' => 3,
'user_permissions' => '',
- 'user_perm_from' => '0',
+ 'user_perm_from' => 0,
'user_ip' => '',
- 'user_regdate' => '0',
+ 'user_regdate' => 0,
'username' => 'foobar',
'username_clean' => 'foobar',
- 'user_password' => $this->password_hash,
- 'user_passchg' => '0',
+ 'user_password' => '$2y$10$4RmpyVu2y8Yf/lP3.yQBquKvE54TCUuEDEBJYY6FDDFN3LcbCGz9i',
+ 'user_passchg' => 0,
'user_email' => 'example@example.com',
- 'user_email_hash' => '0',
'user_birthday' => '',
- 'user_lastvisit' => '0',
- 'user_lastmark' => '0',
- 'user_lastpost_time' => '0',
+ 'user_lastvisit' => 0,
+ 'user_lastmark' => 0,
+ 'user_lastpost_time' => 0,
'user_lastpage' => '',
'user_last_confirm_key' => '',
- 'user_last_search' => '0',
- 'user_warnings' => '0',
- 'user_last_warning' => '0',
- 'user_login_attempts' => '0',
- 'user_inactive_reason' => '0',
- 'user_inactive_time' => '0',
- 'user_posts' => '0',
+ 'user_last_search' => 0,
+ 'user_warnings' => 0,
+ 'user_last_warning' => 0,
+ 'user_login_attempts' => 0,
+ 'user_inactive_reason' => 0,
+ 'user_inactive_time' => 0,
+ 'user_posts' => 0,
'user_lang' => '',
'user_timezone' => '',
'user_dateformat' => 'd M Y H:i',
- 'user_style' => '0',
- 'user_rank' => '0',
+ 'user_style' => 0,
+ 'user_rank' => 0,
'user_colour' => '',
- 'user_new_privmsg' => '0',
- 'user_unread_privmsg' => '0',
- 'user_last_privmsg' => '0',
- 'user_message_rules' => '0',
- 'user_full_folder' => '-3',
- 'user_emailtime' => '0',
- 'user_topic_show_days' => '0',
+ 'user_new_privmsg' => 0,
+ 'user_unread_privmsg' => 0,
+ 'user_last_privmsg' => 0,
+ 'user_message_rules' => 0,
+ 'user_full_folder' => -3,
+ 'user_emailtime' => 0,
+ 'user_topic_show_days' => 0,
'user_topic_sortby_type' => 't',
'user_topic_sortby_dir' => 'd',
- 'user_post_show_days' => '0',
+ 'user_post_show_days' => 0,
'user_post_sortby_type' => 't',
'user_post_sortby_dir' => 'a',
- 'user_notify' => '0',
- 'user_notify_pm' => '1',
- 'user_notify_type' => '0',
- 'user_allow_pm' => '1',
- 'user_allow_viewonline' => '1',
- 'user_allow_viewemail' => '1',
- 'user_allow_massemail' => '1',
- 'user_options' => '230271',
+ 'user_notify' => 0,
+ 'user_notify_pm' => 1,
+ 'user_notify_type' => 0,
+ 'user_allow_pm' => 1,
+ 'user_allow_viewonline' => 1,
+ 'user_allow_viewemail' => 1,
+ 'user_allow_massemail' => 1,
+ 'user_options' => 230271,
'user_avatar' => '',
'user_avatar_type' => '',
- 'user_avatar_width' => '0',
- 'user_avatar_height' => '0',
+ 'user_avatar_width' => 0,
+ 'user_avatar_height' => 0,
'user_sig' => '',
'user_sig_bbcode_uid' => '',
'user_sig_bbcode_bitfield' => '',
@@ -199,9 +171,11 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case
'user_actkey' => '',
'user_newpasswd' => '',
'user_form_salt' => '',
- 'user_new' => '1',
- 'user_reminded' => '0',
- 'user_reminded_time' => '0',
+ 'user_new' => 1,
+ 'user_reminded' => 0,
+ 'user_reminded_time' => 0,
+ 'reset_token' => '',
+ 'reset_token_expiration' => 0,
);
$this->assertEquals($expected, $this->provider->autologin());
diff --git a/tests/auth/provider_db_test.php b/tests/auth/provider_db_test.php
index 6ff77da564..8305e7caa4 100644
--- a/tests/auth/provider_db_test.php
+++ b/tests/auth/provider_db_test.php
@@ -15,14 +15,7 @@ class phpbb_auth_provider_db_test extends phpbb_database_test_case
{
public function getDataSet()
{
- if ((version_compare(PHP_VERSION, '5.3.7', '<')))
- {
- return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/user_533.xml');
- }
- else
- {
- return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/user.xml');
- }
+ return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/user.xml');
}
public function test_login()
@@ -37,7 +30,7 @@ class phpbb_auth_provider_db_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);
- $request = $this->getMock('\phpbb\request\request');
+ $request = $this->createMock('\phpbb\request\request');
$user = new \phpbb\user($lang, '\phpbb\datetime');
$driver_helper = new \phpbb\passwords\driver\helper($config);
$passwords_drivers = array(
@@ -52,16 +45,21 @@ class phpbb_auth_provider_db_test extends phpbb_database_test_case
$passwords_manager = new \phpbb\passwords\manager($config, $passwords_drivers, $passwords_helper, array_keys($passwords_drivers));
$phpbb_container = new phpbb_mock_container_builder();
+ $plugins = new \phpbb\di\service_collection($phpbb_container);
+ $plugins->add('core.captcha.plugins.nogd');
+ $phpbb_container->set(
+ 'captcha.factory',
+ new \phpbb\captcha\factory($phpbb_container, $plugins)
+ );
+ $phpbb_container->set(
+ 'core.captcha.plugins.nogd',
+ new \phpbb\captcha\plugins\nogd()
+ );
+ /** @var \phpbb\captcha\factory $captcha_factory */
+ $captcha_factory = $phpbb_container->get('captcha.factory');
- $provider = new \phpbb\auth\provider\db($db, $config, $passwords_manager, $request, $user, $phpbb_container, $phpbb_root_path, $phpEx);
- if (version_compare(PHP_VERSION, '5.3.7', '<'))
- {
- $password_hash = '$2a$10$e01Syh9PbJjUkio66eFuUu4FhCE2nRgG7QPc1JACalsPXcIuG2bbi';
- }
- else
- {
- $password_hash = '$2y$10$4RmpyVu2y8Yf/lP3.yQBquKvE54TCUuEDEBJYY6FDDFN3LcbCGz9i';
- }
+ $provider = new \phpbb\auth\provider\db($captcha_factory, $config, $db, $passwords_manager, $request, $user, $phpbb_root_path, $phpEx);
+ $password_hash = '$2y$10$4RmpyVu2y8Yf/lP3.yQBquKvE54TCUuEDEBJYY6FDDFN3LcbCGz9i';
$expected = array(
'status' => LOGIN_SUCCESS,
@@ -88,7 +86,6 @@ class phpbb_auth_provider_db_test extends phpbb_database_test_case
// Check if convert works
$login_return = $provider->login('foobar2', 'example');
- $password_start = (version_compare(PHP_VERSION, '5.3.7', '<')) ? '$2a$10$' : '$2y$10$';
- $this->assertStringStartsWith($password_start, $login_return['user_row']['user_password']);
+ $this->assertStringStartsWith('$2y$10$', $login_return['user_row']['user_password']);
}
}
diff --git a/tests/auth/provider_ldap_test.php b/tests/auth/provider_ldap_test.php
new file mode 100644
index 0000000000..0bc9961f52
--- /dev/null
+++ b/tests/auth/provider_ldap_test.php
@@ -0,0 +1,94 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+/**
+ * @group slow
+ */
+class phpbb_auth_provider_ldap_test extends phpbb_database_test_case
+{
+ /** @var \phpbb\auth\provider\ldap */
+ protected $provider;
+
+ protected $user;
+
+ protected function setup() : void
+ {
+ parent::setUp();
+
+ global $phpbb_root_path, $phpEx;
+
+ $db = $this->new_dbal();
+ $config = new \phpbb\config\config([
+ 'ldap_server' => 'localhost',
+ 'ldap_port' => 3389,
+ 'ldap_base_dn' => 'dc=example,dc=com',
+ 'ldap_uid' => 'uid',
+ 'ldap_email' => 'mail',
+ ]);
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $this->user = new \phpbb\user($lang, '\phpbb\datetime');
+ $this->user->data['username'] = 'admin';
+
+ $this->provider = new \phpbb\auth\provider\ldap($config, $db, $lang, $this->user);
+ }
+
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/user.xml');
+ }
+
+ /**
+ * Test to see if a user is identified to Apache. Expects false if they are.
+ */
+ public function test_init()
+ {
+ $this->assertFalse($this->provider->init());
+ }
+
+ public function test_login()
+ {
+ $username = 'admin';
+ $password = 'adminadmin';
+
+ $expected = array(
+ 'status' => LOGIN_SUCCESS_CREATE_PROFILE, // successful login and user created
+ 'error_msg' => false,
+ 'user_row' => array(
+ 'username' => 'admin',
+ 'user_password' => '',
+ 'user_email' => 'admin@example.com',
+ 'user_type' => 0,
+ 'group_id' => 1,
+ 'user_new' => 0,
+ 'user_ip' => '',
+ ),
+ );
+
+ $this->assertEquals($expected, $this->provider->login($username, $password));
+ }
+
+ public function test_autologin()
+ {
+ $this->assertNull($this->provider->autologin());
+ }
+
+ public function test_validate_session()
+ {
+ $user = array(
+ 'username' => 'admin',
+ );
+
+ $this->assertNull($this->provider->validate_session($user));
+ }
+}
diff --git a/tests/auth/provider_oauth_token_storage_test.php b/tests/auth/provider_oauth_token_storage_test.php
index ae5de6aa7e..0c0e55dec6 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()
+ protected function setup(): void
{
parent::setUp();
@@ -73,7 +73,10 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c
$token = $cache_token;
}
- $this->setExpectedException($exception);
+ if (!empty($exception))
+ {
+ $this->expectException($exception);
+ }
$stored_token = $this->token_storage->retrieveAccessToken($this->service_name);
$this->assertEquals($token, $stored_token);
@@ -120,7 +123,10 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c
$token = $cache_token;
}
- $this->setExpectedException($exception);
+ if (!empty($exception))
+ {
+ $this->expectException($exception);
+ }
$stored_token = $this->token_storage->retrieve_access_token_by_session($this->service_name);
$this->assertEquals($token, $stored_token);
diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php
index d1e907b53d..81a0655e02 100644
--- a/tests/avatar/manager_test.php
+++ b/tests/avatar/manager_test.php
@@ -25,12 +25,12 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/users.xml');
}
- public function setUp()
+ public function setUp(): void
{
global $phpbb_root_path, $phpEx;
// Mock phpbb_container
- $phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $phpbb_container = $this->createMock('Symfony\Component\DependencyInjection\ContainerInterface');
$phpbb_container->expects($this->any())
->method('get')
->will($this->returnArgument(0));
@@ -39,13 +39,13 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
// Prepare dependencies for avatar manager and driver
$this->config = new \phpbb\config\config(array());
- $cache = $this->getMock('\phpbb\cache\driver\driver_interface');
+ $cache = $this->createMock('\phpbb\cache\driver\driver_interface');
$path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
new phpbb_mock_request()
),
$filesystem,
- $this->getMock('\phpbb\request\request'),
+ $this->createMock('\phpbb\request\request'),
$phpbb_root_path,
$phpEx
);
@@ -62,12 +62,17 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
$dispatcher = new phpbb_mock_event_dispatcher();
// $this->avatar_foobar will be needed later on
- $this->avatar_foobar = $this->getMock('\phpbb\avatar\driver\foobar', array('get_name'), array($this->config, $imagesize, $phpbb_root_path, $phpEx, $path_helper, $cache));
+ $this->avatar_foobar = $this->getMockBuilder('\phpbb\avatar\driver\foobar')
+ ->setMethods(array('get_name'))
+ ->setConstructorArgs(array($this->config, $imagesize, $phpbb_root_path, $phpEx, $path_helper, $cache))
+ ->getMock();
$this->avatar_foobar->expects($this->any())
->method('get_name')
->will($this->returnValue('avatar.driver.foobar'));
// barfoo driver can't be mocked with constructor arguments
- $this->avatar_barfoo = $this->getMock('\phpbb\avatar\driver\barfoo', array('get_name', 'get_config_name'));
+ $this->avatar_barfoo = $this->getMockBuilder('\phpbb\avatar\driver\barfoo')
+ ->setMethods(array('get_name', 'get_config_name'))
+ ->getMock();
$this->avatar_barfoo->expects($this->any())
->method('get_name')
->will($this->returnValue('avatar.driver.barfoo'));
@@ -82,11 +87,17 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
{
if ($driver !== 'upload')
{
- $cur_avatar = $this->getMock('\phpbb\avatar\driver\\' . $driver, array('get_name'), array($this->config, $imagesize, $phpbb_root_path, $phpEx, $path_helper, $cache));
+ $cur_avatar = $this->getMockBuilder('\phpbb\avatar\driver\\' . $driver)
+ ->setMethods(array('get_name'))
+ ->setConstructorArgs(array($this->config, $imagesize, $phpbb_root_path, $phpEx, $path_helper, $cache))
+ ->getMock();
}
else
{
- $cur_avatar = $this->getMock('\phpbb\avatar\driver\\' . $driver, array('get_name'), array($this->config, $phpbb_root_path, $phpEx, $filesystem, $path_helper, $dispatcher, $files_factory, $cache));
+ $cur_avatar = $this->getMockBuilder('\phpbb\avatar\driver\\' . $driver)
+ ->setMethods(array('get_name'))
+ ->setConstructorArgs(array($this->config, $phpbb_root_path, $phpEx, $filesystem, $path_helper, $dispatcher, $files_factory, $cache))
+ ->getMock();
}
$cur_avatar->expects($this->any())
->method('get_name')
@@ -288,10 +299,10 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
{
global $phpbb_root_path, $phpEx;
- $user = $this->getMock('\phpbb\user', array(), array(
- new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
- '\phpbb\datetime')
- );
+ $user = $this->getMockBuilder('\phpbb\user')
+ ->setMethods(array())
+ ->setConstructorArgs(array(new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), '\phpbb\datetime'))
+ ->getMock();
$lang_array = array(
array('FOOBAR_OFF', 'foobar_off'),
array('FOOBAR_EXPLAIN', 'FOOBAR_EXPLAIN %s'),
diff --git a/tests/bbcode/parser_test.php b/tests/bbcode/parser_test.php
index b569d371f1..6e1fad9ad1 100644
--- a/tests/bbcode/parser_test.php
+++ b/tests/bbcode/parser_test.php
@@ -255,6 +255,7 @@ class phpbb_bbcode_parser_test extends \phpbb_test_case
$symfony_request = new \phpbb\symfony_request($request);
$bbcode = new bbcode_firstpass();
+ $bbcode->mode = 'post';
$bbcode->message = $message;
$bbcode->bbcode_init(false);
$bbcode->parse_bbcode();
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 18977bac88..62f91e346e 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -42,7 +42,7 @@ require_once 'test_framework/phpbb_database_test_connection_manager.php';
require_once 'test_framework/phpbb_functional_test_case.php';
require_once 'test_framework/phpbb_ui_test_case.php';
-if (version_compare(PHP_VERSION, '5.3.19', ">=") && file_exists(__DIR__ . '/vendor/autoload.php'))
+if (file_exists(__DIR__ . '/vendor/autoload.php'))
{
require_once __DIR__ . '/vendor/autoload.php';
}
diff --git a/tests/cache/apc_driver_test.php b/tests/cache/apc_driver_test.php
deleted file mode 100644
index 706f274448..0000000000
--- a/tests/cache/apc_driver_test.php
+++ /dev/null
@@ -1,57 +0,0 @@
-<?php
-/**
-*
-* This file is part of the phpBB Forum Software package.
-*
-* @copyright (c) phpBB Limited <https://www.phpbb.com>
-* @license GNU General Public License, version 2 (GPL-2.0)
-*
-* For full copyright and license information, please see
-* the docs/CREDITS.txt file.
-*
-*/
-
-// Important: apc.enable_cli=1 must be in php.ini.
-// http://forums.devshed.com/php-development-5/apc-problem-561290.html
-// http://php.net/manual/en/apc.configuration.php
-
-require_once dirname(__FILE__) . '/common_test_case.php';
-
-class phpbb_cache_apc_driver_test extends phpbb_cache_common_test_case
-{
- protected static $config;
- protected $driver;
-
- public function getDataSet()
- {
- return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
- }
-
- static public function setUpBeforeClass()
- {
- if (!extension_loaded('apc'))
- {
- self::markTestSkipped('APC extension is not loaded');
- }
-
- $php_ini = new \bantu\IniGetWrapper\IniGetWrapper;
-
- if (!$php_ini->getBool('apc.enabled'))
- {
- self::markTestSkipped('APC is not enabled. Make sure apc.enabled=1 in php.ini');
- }
-
- if (PHP_SAPI == 'cli' && !$php_ini->getBool('apc.enable_cli'))
- {
- self::markTestSkipped('APC is not enabled for CLI. Set apc.enable_cli=1 in php.ini');
- }
- }
-
- protected function setUp()
- {
- parent::setUp();
-
- $this->driver = new \phpbb\cache\driver\apc;
- $this->driver->purge();
- }
-}
diff --git a/tests/cache/apcu_driver_test.php b/tests/cache/apcu_driver_test.php
index 57f640c313..34bcf8f844 100644
--- a/tests/cache/apcu_driver_test.php
+++ b/tests/cache/apcu_driver_test.php
@@ -20,7 +20,6 @@ require_once dirname(__FILE__) . '/common_test_case.php';
class phpbb_cache_apcu_driver_test extends phpbb_cache_common_test_case
{
protected static $config;
- protected $driver;
public function getDataSet()
{
@@ -45,9 +44,11 @@ class phpbb_cache_apcu_driver_test extends phpbb_cache_common_test_case
{
self::markTestSkipped('APCu is not enabled for CLI. Set apc.enable_cli=1 in php.ini');
}
+
+ parent::setUpBeforeClass();
}
- protected function setUp()
+ protected function setUp(): void
{
global $phpbb_container, $phpbb_root_path;
diff --git a/tests/cache/cache_memory_test.php b/tests/cache/cache_memory_test.php
index ba1010bcf3..b3d19f1782 100644
--- a/tests/cache/cache_memory_test.php
+++ b/tests/cache/cache_memory_test.php
@@ -23,7 +23,7 @@ class phpbb_cache_memory_test extends phpbb_database_test_case
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/cache_memory.xml');
}
- protected function setUp()
+ protected function setUp(): void
{
global $db;
parent::setUp();
diff --git a/tests/cache/common_test_case.php b/tests/cache/common_test_case.php
index ee0649a755..64273c250a 100644
--- a/tests/cache/common_test_case.php
+++ b/tests/cache/common_test_case.php
@@ -13,6 +13,9 @@
abstract class phpbb_cache_common_test_case extends phpbb_database_test_case
{
+ /** @var \phpbb\cache\driver\driver_interface */
+ protected $driver;
+
public function test_get_put_exists()
{
$this->assertFalse($this->driver->_exists('test_key'));
diff --git a/tests/cache/dummy_driver_test.php b/tests/cache/dummy_driver_test.php
index 6cb6b73729..6802e120ab 100644
--- a/tests/cache/dummy_driver_test.php
+++ b/tests/cache/dummy_driver_test.php
@@ -13,14 +13,12 @@
class phpbb_cache_dummy_driver_test extends phpbb_database_test_case
{
- protected $driver;
-
public function getDataSet()
{
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
}
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/tests/cache/file_driver_test.php b/tests/cache/file_driver_test.php
index 471316847d..37973edba3 100644
--- a/tests/cache/file_driver_test.php
+++ b/tests/cache/file_driver_test.php
@@ -16,22 +16,18 @@ require_once dirname(__FILE__) . '/common_test_case.php';
class phpbb_cache_file_driver_test extends phpbb_cache_common_test_case
{
private $cache_dir;
- protected $driver;
-
- public function __construct()
- {
- $this->cache_dir = dirname(__FILE__) . '/../tmp/cache/';
- }
public function getDataSet()
{
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
}
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
+ $this->cache_dir = dirname(__FILE__) . '/../tmp/cache/';
+
if (file_exists($this->cache_dir))
{
// cache directory possibly left after aborted
@@ -43,7 +39,7 @@ class phpbb_cache_file_driver_test extends phpbb_cache_common_test_case
$this->driver = new \phpbb\cache\driver\file($this->cache_dir);
}
- protected function tearDown()
+ protected function tearDown(): void
{
if (file_exists($this->cache_dir))
{
diff --git a/tests/cache/memcached_test.php b/tests/cache/memcached_test.php
new file mode 100644
index 0000000000..650b72ea18
--- /dev/null
+++ b/tests/cache/memcached_test.php
@@ -0,0 +1,65 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+require_once dirname(__FILE__) . '/common_test_case.php';
+
+class phpbb_cache_memcached_driver_test extends \phpbb_cache_common_test_case
+{
+ protected static $config;
+
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
+ }
+
+ static public function setUpBeforeClass()
+ {
+ if (!extension_loaded('memcached'))
+ {
+ self::markTestSkipped('memcached extension is not loaded');
+ }
+
+ $config = phpbb_test_case_helpers::get_test_config();
+ if (isset($config['memcached_host']) || isset($config['memcached_port']))
+ {
+ $host = isset($config['memcached_host']) ? $config['memcached_host'] : 'localhost';
+ $port = isset($config['memcached_port']) ? $config['memcached_port'] : 11211;
+ self::$config = array('host' => $host, 'port' => $port);
+ }
+ else
+ {
+ self::markTestSkipped('Test memcached host/port is not specified');
+ }
+
+ $memcached = new \Memcached();
+ $memcached->addServer(self::$config['host'], self::$config['port']);
+ if (empty($memcached->getStats()))
+ {
+ self::markTestSkipped('Test memcached server is not available');
+ }
+
+ parent::setUpBeforeClass();
+ }
+
+ protected function setUp(): void
+ {
+ global $phpbb_root_path, $phpbb_container;
+
+ parent::setUp();
+
+ $phpbb_container = new phpbb_mock_container_builder();
+ $phpbb_container->setParameter('core.cache_dir', $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/');
+ $this->driver = new \phpbb\cache\driver\memcached(self::$config['host'] . '/' . self::$config['port']);
+ $this->driver->purge();
+ }
+}
diff --git a/tests/cache/redis_driver_test.php b/tests/cache/redis_driver_test.php
index 387e6ca855..a2288cf9a8 100644
--- a/tests/cache/redis_driver_test.php
+++ b/tests/cache/redis_driver_test.php
@@ -13,10 +13,9 @@
require_once dirname(__FILE__) . '/common_test_case.php';
-class phpbb_cache_redis_driver_test extends phpbb_cache_common_test_case
+class phpbb_cache_redis_driver_test extends \phpbb_cache_common_test_case
{
protected static $config;
- protected $driver;
public function getDataSet()
{
@@ -41,12 +40,18 @@ class phpbb_cache_redis_driver_test extends phpbb_cache_common_test_case
{
self::markTestSkipped('Test redis host/port is not specified');
}
+
+ parent::setUpBeforeClass();
}
- protected function setUp()
+ protected function setUp(): void
{
+ global $phpbb_root_path, $phpbb_container;
+
parent::setUp();
+ $phpbb_container = new phpbb_mock_container_builder();
+ $phpbb_container->setParameter('core.cache_dir', $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/');
$this->driver = new \phpbb\cache\driver\redis(self::$config['host'], self::$config['port']);
$this->driver->purge();
}
diff --git a/tests/captcha/qa_test.php b/tests/captcha/qa_test.php
index 7ec4be69f5..0856bbd3c3 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()
+ public 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 ffb14b0720..60d8d26b13 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()
+ public 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()
+ public function tearDown(): void
{
global $phpbb_class_loader_ext;
$phpbb_class_loader_ext->register();
diff --git a/tests/compress/compress_test.php b/tests/compress/compress_test.php
index c071a049a8..f67726c205 100644
--- a/tests/compress/compress_test.php
+++ b/tests/compress/compress_test.php
@@ -34,7 +34,7 @@ class phpbb_compress_test extends phpbb_test_case
'dir/2_1.txt',
);
- protected function setUp()
+ protected function setUp(): void
{
// Required for compress::add_file
global $phpbb_root_path;
@@ -54,7 +54,7 @@ class phpbb_compress_test extends phpbb_test_case
}
}
- protected function tearDown()
+ protected function tearDown(): void
{
foreach (array(dirname(__FILE__) . self::EXTRACT_DIR, dirname(__FILE__) . self::ARCHIVE_DIR) as $dir)
{
diff --git a/tests/config/db_test.php b/tests/config/db_test.php
index 713e6cb6d9..46addc9d38 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()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/config/db_text_test.php b/tests/config/db_text_test.php
index a91abf990f..0683abc1a9 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()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/console/cache/purge_test.php b/tests/console/cache/purge_test.php
index 6c92660580..2bb4252c41 100644
--- a/tests/console/cache/purge_test.php
+++ b/tests/console/cache/purge_test.php
@@ -25,15 +25,12 @@ class phpbb_console_command_cache_purge_test extends phpbb_test_case
protected $db;
protected $config;
- public function __construct()
- {
- $this->cache_dir = dirname(__FILE__) . '/tmp/cache/';
- }
-
- protected function setUp()
+ protected function setUp(): void
{
global $phpbb_root_path, $phpEx;
+ $this->cache_dir = dirname(__FILE__) . '/tmp/cache/';
+
if (file_exists($this->cache_dir))
{
// cache directory possibly left after aborted
@@ -44,10 +41,10 @@ class phpbb_console_command_cache_purge_test extends phpbb_test_case
$this->cache = new \phpbb\cache\driver\file($this->cache_dir);
- $this->db = $this->getMock('\phpbb\db\driver\driver_interface');
+ $this->db = $this->createMock('\phpbb\db\driver\driver_interface');
$this->config = new \phpbb\config\config(array('assets_version' => 1));
- $this->user = $this->getMock('\phpbb\user', array(), array(
+ $this->user = $this->createMock('\phpbb\user', array(), array(
new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
'\phpbb\datetime')
);
@@ -91,7 +88,7 @@ class phpbb_console_command_cache_purge_test extends phpbb_test_case
public function get_command_tester()
{
$application = new Application();
- $application->add(new purge($this->user, $this->cache, $this->db, $this->getMock('\phpbb\auth\auth'), new \phpbb\log\dummy(), $this->config));
+ $application->add(new purge($this->user, $this->cache, $this->db, $this->createMock('\phpbb\auth\auth'), new \phpbb\log\dummy(), $this->config));
$command = $application->find('cache:purge');
$this->command_name = $command->getName();
diff --git a/tests/console/config/config_test.php b/tests/console/config/config_test.php
index 076316217d..65bfad4757 100644
--- a/tests/console/config/config_test.php
+++ b/tests/console/config/config_test.php
@@ -20,13 +20,13 @@ class phpbb_console_command_config_test extends phpbb_test_case
protected $command_name;
protected $user;
- public function setUp()
+ public function setUp(): void
{
global $phpbb_root_path, $phpEx;
$this->config = new \phpbb\config\config(array());
- $this->user = $this->getMock('\phpbb\user', array(), array(
+ $this->user = $this->createMock('\phpbb\user', array(), array(
new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
'\phpbb\datetime')
);
diff --git a/tests/console/cron/cron_list_test.php b/tests/console/cron/cron_list_test.php
index fdc9a05cb2..8c7424c50d 100644
--- a/tests/console/cron/cron_list_test.php
+++ b/tests/console/cron/cron_list_test.php
@@ -30,11 +30,11 @@ class phpbb_console_command_cron_list_test extends phpbb_test_case
protected $command_tester;
- protected function setUp()
+ protected function setUp(): void
{
global $phpbb_root_path, $phpEx;
- $this->user = $this->getMock('\phpbb\user', array(), array(
+ $this->user = $this->createMock('\phpbb\user', array(), array(
new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
'\phpbb\datetime'
));
@@ -74,7 +74,35 @@ class phpbb_console_command_cron_list_test extends phpbb_test_case
$task->set_name('command' . $i);
$i++;
}
- $this->cron_manager = new \phpbb\cron\manager($tasks, $phpbb_root_path, $pathEx);
+
+ $mock_config = new \phpbb\config\config(array(
+ 'force_server_vars' => false,
+ 'enable_mod_rewrite' => '',
+ ));
+
+ $mock_router = $this->getMockBuilder('\phpbb\routing\router')
+ ->setMethods(array('setContext', 'generate'))
+ ->disableOriginalConstructor()
+ ->getMock();
+ $mock_router->method('setContext')
+ ->willReturn(true);
+ $mock_router->method('generate')
+ ->willReturn('foobar');
+
+ $request = new \phpbb\request\request();
+ $request->enable_super_globals();
+
+ $routing_helper = new \phpbb\routing\helper(
+ $mock_config,
+ $mock_router,
+ new \phpbb\symfony_request($request),
+ $request,
+ new \phpbb\filesystem\filesystem(),
+ $phpbb_root_path,
+ $pathEx
+ );
+
+ $this->cron_manager = new \phpbb\cron\manager($tasks, $routing_helper, $phpbb_root_path, $pathEx);
}
public function get_command_tester()
diff --git a/tests/console/cron/run_test.php b/tests/console/cron/run_test.php
index b4a0203325..8402f9dd3e 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()
+ public function setUp(): void
{
global $db, $config, $phpbb_root_path, $phpEx;
@@ -40,7 +40,7 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
$config = $this->config = new \phpbb\config\config(array('cron_lock' => '0'));
$this->lock = new \phpbb\lock\db('cron_lock', $this->config, $this->db);
- $this->user = $this->getMock('\phpbb\user', array(), array(
+ $this->user = $this->createMock('\phpbb\user', array(), array(
new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
'\phpbb\datetime'
));
@@ -50,7 +50,35 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
$tasks = array(
$this->task,
);
- $this->cron_manager = new \phpbb\cron\manager($tasks, $phpbb_root_path, $phbEx);
+
+ $mock_config = new \phpbb\config\config(array(
+ 'force_server_vars' => false,
+ 'enable_mod_rewrite' => '',
+ ));
+
+ $mock_router = $this->getMockBuilder('\phpbb\routing\router')
+ ->setMethods(array('setContext', 'generate'))
+ ->disableOriginalConstructor()
+ ->getMock();
+ $mock_router->method('setContext')
+ ->willReturn(true);
+ $mock_router->method('generate')
+ ->willReturn('foobar');
+
+ $request = new \phpbb\request\request();
+ $request->enable_super_globals();
+
+ $routing_helper = new \phpbb\routing\helper(
+ $mock_config,
+ $mock_router,
+ new \phpbb\symfony_request($request),
+ $request,
+ new \phpbb\filesystem\filesystem(),
+ $phpbb_root_path,
+ $phpEx
+ );
+
+ $this->cron_manager = new \phpbb\cron\manager($tasks, $routing_helper, $phpbb_root_path, $phpEx);
$this->assertSame('0', $config['cron_lock']);
}
@@ -94,9 +122,39 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
public function test_no_task()
{
+ global $phpbb_root_path, $phpEx;
+
$tasks = array(
);
- $this->cron_manager = new \phpbb\cron\manager($tasks, $phpbb_root_path, $phpEx);
+
+ $mock_config = new \phpbb\config\config(array(
+ 'force_server_vars' => false,
+ 'enable_mod_rewrite' => '',
+ ));
+
+ $mock_router = $this->getMockBuilder('\phpbb\routing\router')
+ ->setMethods(array('setContext', 'generate'))
+ ->disableOriginalConstructor()
+ ->getMock();
+ $mock_router->method('setContext')
+ ->willReturn(true);
+ $mock_router->method('generate')
+ ->willReturn('foobar');
+
+ $request = new \phpbb\request\request();
+ $request->enable_super_globals();
+
+ $routing_helper = new \phpbb\routing\helper(
+ $mock_config,
+ $mock_router,
+ new \phpbb\symfony_request($request),
+ $request,
+ new \phpbb\filesystem\filesystem(),
+ $phpbb_root_path,
+ $phpEx
+ );
+
+ $this->cron_manager = new \phpbb\cron\manager($tasks, $routing_helper, $phpbb_root_path, $phpEx);
$command_tester = $this->get_command_tester();
$exit_status = $command_tester->execute(array('command' => $this->command_name));
@@ -107,9 +165,39 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
public function test_no_task_verbose()
{
+ global $phpbb_root_path, $phpEx;
+
$tasks = array(
);
- $this->cron_manager = new \phpbb\cron\manager($tasks, $phpbb_root_path, $phpEx);
+
+ $mock_config = new \phpbb\config\config(array(
+ 'force_server_vars' => false,
+ 'enable_mod_rewrite' => '',
+ ));
+
+ $mock_router = $this->getMockBuilder('\phpbb\routing\router')
+ ->setMethods(array('setContext', 'generate'))
+ ->disableOriginalConstructor()
+ ->getMock();
+ $mock_router->method('setContext')
+ ->willReturn(true);
+ $mock_router->method('generate')
+ ->willReturn('foobar');
+
+ $request = new \phpbb\request\request();
+ $request->enable_super_globals();
+
+ $routing_helper = new \phpbb\routing\helper(
+ $mock_config,
+ $mock_router,
+ new \phpbb\symfony_request($request),
+ $request,
+ new \phpbb\filesystem\filesystem(),
+ $phpbb_root_path,
+ $phpEx
+ );
+
+ $this->cron_manager = new \phpbb\cron\manager($tasks, $routing_helper, $phpbb_root_path, $phpEx);
$command_tester = $this->get_command_tester();
$exit_status = $command_tester->execute(array('command' => $this->command_name, '--verbose' => true));
diff --git a/tests/console/thumbnail_test.php b/tests/console/thumbnail_test.php
index e425d998a2..8f4da5a414 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()
+ public function setUp(): void
{
global $config, $phpbb_root_path, $phpEx, $phpbb_filesystem;
@@ -50,14 +50,14 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case
));
$this->db = $this->db = $this->new_dbal();
- $this->user = $this->getMock('\phpbb\user', array(), array(
+ $this->user = $this->createMock('\phpbb\user', array(), array(
new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
'\phpbb\datetime')
);
$this->phpbb_root_path = $phpbb_root_path;
$this->phpEx = $phpEx;
- $this->cache = $this->getMock('\phpbb\cache\service', array(), array(new phpbb_mock_cache(), $this->config, $this->db, $this->phpbb_root_path, $this->phpEx));
+ $this->cache = $this->createMock('\phpbb\cache\service', array(), array(new phpbb_mock_cache(), $this->config, $this->db, $this->phpbb_root_path, $this->phpEx));
$this->cache->expects(self::any())->method('obtain_attach_extensions')->will(self::returnValue(array(
'png' => array('display_cat' => ATTACHMENT_CATEGORY_IMAGE),
'txt' => array('display_cat' => ATTACHMENT_CATEGORY_NONE),
@@ -76,7 +76,7 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case
copy(dirname(__FILE__) . '/fixtures/txt.txt', $this->phpbb_root_path . 'files/test_txt');
}
- protected function tearDown()
+ protected function tearDown(): void
{
parent::tearDown();
diff --git a/tests/console/update/check_test.php b/tests/console/update/check_test.php
index 5cadc5cc97..6812ea61b8 100644
--- a/tests/console/update/check_test.php
+++ b/tests/console/update/check_test.php
@@ -84,7 +84,7 @@ class phpbb_console_command_check_test extends phpbb_test_case
$this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
- $user = $this->getMock('\phpbb\user', array(), array(
+ $user = $this->createMock('\phpbb\user', array(), array(
$this->language,
'\phpbb\datetime'
));
diff --git a/tests/console/user/activate_test.php b/tests/console/user/activate_test.php
index 1588a76e47..51e9754b59 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()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/console/user/add_test.php b/tests/console/user/add_test.php
index bdfb8a8d2a..cc86cb27d3 100644
--- a/tests/console/user/add_test.php
+++ b/tests/console/user/add_test.php
@@ -61,7 +61,10 @@ class phpbb_console_user_add_test extends phpbb_console_user_base
$output->writeln(print_r($response, true));
return $response;
};
- $helper = $this->getMock('\Symfony\Component\Console\Helper\QuestionHelper', array('ask'));
+ $helper = $this->getMockBuilder('\Symfony\Component\Console\Helper\QuestionHelper')
+ ->setMethods(['ask'])
+ ->disableOriginalConstructor()
+ ->getMock();
$helper->expects($this->any())
->method('ask')
->will($this->returnCallback($ask));
diff --git a/tests/console/user/base.php b/tests/console/user/base.php
index ad328ac893..74f04cf686 100644
--- a/tests/console/user/base.php
+++ b/tests/console/user/base.php
@@ -20,6 +20,7 @@ abstract class phpbb_console_user_base extends phpbb_database_test_case
protected $log;
protected $passwords_manager;
protected $command_name;
+ /** @var Symfony\Component\Console\Helper\QuestionHelper */
protected $question;
protected $user_loader;
protected $phpbb_root_path;
@@ -30,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()
+ public function setUp(): void
{
global $auth, $db, $cache, $config, $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpEx;
@@ -39,7 +40,7 @@ abstract class phpbb_console_user_base extends phpbb_database_test_case
$phpbb_container->set('cache.driver', new phpbb_mock_cache());
$phpbb_container->set('notification_manager', new phpbb_mock_notification_manager());
- $auth = $this->getMock('\phpbb\auth\auth');
+ $auth = $this->createMock('\phpbb\auth\auth');
$cache = $phpbb_container->get('cache.driver');
@@ -50,7 +51,6 @@ abstract class phpbb_console_user_base extends phpbb_database_test_case
'min_name_chars' => 3,
'max_name_chars' => 10,
'min_pass_chars' => 3,
- 'max_pass_chars' => 10,
'pass_complex' => 'PASS_TYPE_ANY',
));
@@ -62,7 +62,7 @@ abstract class phpbb_console_user_base extends phpbb_database_test_case
$this->language->expects($this->any())
->method('lang')
->will($this->returnArgument(0));
- $user = $this->user = $this->getMock('\phpbb\user', array(), array(
+ $user = $this->user = $this->createMock('\phpbb\user', array(), array(
$this->language,
'\phpbb\datetime'
));
@@ -112,7 +112,8 @@ abstract class phpbb_console_user_base extends phpbb_database_test_case
$row = $this->db->sql_fetchrow($result);
$this->db->sql_freeresult($result);
- return $row['user_id'];
+ $user_id = $row ? $row['user_id'] : null;
+ return $user_id;
}
public function getInputStream($input)
diff --git a/tests/console/user/delete_test.php b/tests/console/user/delete_test.php
index 88f91afab1..926e496e1e 100644
--- a/tests/console/user/delete_test.php
+++ b/tests/console/user/delete_test.php
@@ -45,7 +45,7 @@ class phpbb_console_user_delete_test extends phpbb_console_user_base
$this->assertEquals(3, $this->get_user_id('Test'));
- $this->question->setInputStream($this->getInputStream("yes\n"));
+ $command_tester->setInputs(['yes', '']);
$command_tester->execute(array(
'command' => $this->command_name,
@@ -63,7 +63,7 @@ class phpbb_console_user_delete_test extends phpbb_console_user_base
$this->assertNull($this->get_user_id('Foo'));
- $this->question->setInputStream($this->getInputStream("yes\n"));
+ $command_tester->setInputs(['yes', '']);
$command_tester->execute(array(
'command' => $this->command_name,
@@ -80,7 +80,7 @@ class phpbb_console_user_delete_test extends phpbb_console_user_base
$this->assertEquals(3, $this->get_user_id('Test'));
- $this->question->setInputStream($this->getInputStream("no\n"));
+ $command_tester->setInputs(['no', '']);
$command_tester->execute(array(
'command' => $this->command_name,
diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php
index 4ea95b0a96..1c1796a1fc 100644
--- a/tests/content_visibility/delete_post_test.php
+++ b/tests/content_visibility/delete_post_test.php
@@ -287,7 +287,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
*/
public function test_delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason, $expected_posts, $expected_topic, $expected_forum, $expected_user)
{
- global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx;
+ global $auth, $cache, $config, $db, $user, $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx;
$config = new \phpbb\config\config(array(
'num_posts' => 3,
@@ -299,7 +299,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
// Create auth mock
- $auth = $this->getMock('\phpbb\auth\auth');
+ $auth = $this->createMock('\phpbb\auth\auth');
$auth->expects($this->any())
->method('acl_get')
->with($this->stringContains('_'), $this->anything())
diff --git a/tests/content_visibility/fixtures/get_visibility_sql.xml b/tests/content_visibility/fixtures/get_visibility_sql.xml
index 146244263e..2128064986 100644
--- a/tests/content_visibility/fixtures/get_visibility_sql.xml
+++ b/tests/content_visibility/fixtures/get_visibility_sql.xml
@@ -3,17 +3,20 @@
<table name="phpbb_topics">
<column>topic_id</column>
<column>forum_id</column>
+ <column>topic_poster</column>
<column>topic_visibility</column>
<column>topic_title</column>
<row>
<value>1</value>
<value>1</value>
<value>0</value>
+ <value>0</value>
<value>Unapproved</value>
</row>
<row>
<value>2</value>
<value>1</value>
+ <value>0</value>
<value>1</value>
<value>Approved</value>
</row>
@@ -21,13 +24,22 @@
<value>3</value>
<value>1</value>
<value>2</value>
+ <value>0</value>
<value>Softdeleted</value>
</row>
+ <row>
+ <value>4</value>
+ <value>1</value>
+ <value>1</value>
+ <value>0</value>
+ <value>Unapproved</value>
+ </row>
</table>
<table name="phpbb_posts">
<column>post_id</column>
<column>topic_id</column>
<column>forum_id</column>
+ <column>poster_id</column>
<column>post_visibility</column>
<column>post_text</column>
<row>
@@ -35,12 +47,14 @@
<value>1</value>
<value>1</value>
<value>0</value>
+ <value>0</value>
<value>Unapproved</value>
</row>
<row>
<value>2</value>
<value>2</value>
<value>1</value>
+ <value>0</value>
<value>1</value>
<value>Approved</value>
</row>
@@ -48,8 +62,17 @@
<value>3</value>
<value>3</value>
<value>1</value>
+ <value>0</value>
<value>2</value>
<value>Softdeleted</value>
</row>
+ <row>
+ <value>4</value>
+ <value>4</value>
+ <value>1</value>
+ <value>1</value>
+ <value>0</value>
+ <value>Unapproved</value>
+ </row>
</table>
</dataset>
diff --git a/tests/content_visibility/get_forums_visibility_sql_test.php b/tests/content_visibility/get_forums_visibility_sql_test.php
index 6c5066119e..fde2b62131 100644
--- a/tests/content_visibility/get_forums_visibility_sql_test.php
+++ b/tests/content_visibility/get_forums_visibility_sql_test.php
@@ -129,7 +129,7 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data
$db = $this->new_dbal();
// Create auth mock
- $auth = $this->getMock('\phpbb\auth\auth');
+ $auth = $this->createMock('\phpbb\auth\auth');
$auth->expects($this->any())
->method('acl_getf')
->with($this->stringContains('_'), $this->anything())
diff --git a/tests/content_visibility/get_global_visibility_sql_test.php b/tests/content_visibility/get_global_visibility_sql_test.php
index 9ae4182673..eced3aa680 100644
--- a/tests/content_visibility/get_global_visibility_sql_test.php
+++ b/tests/content_visibility/get_global_visibility_sql_test.php
@@ -129,7 +129,7 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data
$db = $this->new_dbal();
// Create auth mock
- $auth = $this->getMock('\phpbb\auth\auth');
+ $auth = $this->createMock('\phpbb\auth\auth');
$auth->expects($this->any())
->method('acl_getf')
->with($this->stringContains('_'), $this->anything())
diff --git a/tests/content_visibility/get_visibility_sql_test.php b/tests/content_visibility/get_visibility_sql_test.php
index aaaf64330e..6026778487 100644
--- a/tests/content_visibility/get_visibility_sql_test.php
+++ b/tests/content_visibility/get_visibility_sql_test.php
@@ -21,8 +21,11 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te
public function get_visibility_sql_data()
{
return array(
+ // data set 0: display_unapproved_posts=false, moderator, can see all posts
array(
'phpbb_posts',
+ 0,
+ false,
'post', 1, '',
array(
array('m_approve', 1, true),
@@ -31,10 +34,14 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te
array('post_id' => 1),
array('post_id' => 2),
array('post_id' => 3),
+ array('post_id' => 4),
),
),
+ // data set 1: display_unapproved_posts=false, normal user, cannot see any unapproved posts
array(
'phpbb_posts',
+ 0,
+ false,
'post', 1, '',
array(
),
@@ -42,8 +49,11 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te
array('post_id' => 2),
),
),
+ // data set 2: display_unapproved_posts=false, moderator, can see all topics
array(
'phpbb_topics',
+ 0,
+ false,
'topic', 1, '',
array(
array('m_approve', 1, true),
@@ -52,23 +62,74 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te
array('topic_id' => 1),
array('topic_id' => 2),
array('topic_id' => 3),
+ array('topic_id' => 4),
),
),
+ // data set 3: display_unapproved_posts=false, normal user, cannot see unapproved posts topic
array(
'phpbb_topics',
+ 0,
+ false,
'topic', 1, '',
array(),
array(
array('topic_id' => 2),
),
),
+ // data set 4: display_unapproved_posts=true, guest user, cannot see unapproved posts
+ array(
+ 'phpbb_posts',
+ 1,
+ true,
+ 'post', 1, '',
+ array(
+ ),
+ array(
+ array('post_id' => 2),
+ ),
+ ),
+ // data set 5: display_unapproved_posts=true, guest user, cannot see unapproved posts topic
+ array(
+ 'phpbb_topics',
+ 1,
+ true,
+ 'topic', 1, '',
+ array(),
+ array(
+ array('topic_id' => 2),
+ ),
+ ),
+ // data set 6: display_unapproved_posts=true, normal user, can see own unapproved posts
+ array(
+ 'phpbb_posts',
+ 0,
+ true,
+ 'post', 1, '',
+ array(),
+ array(
+ array('post_id' => 1),
+ array('post_id' => 2),
+ ),
+ ),
+ // data set 7: display_unapproved_posts=true, normal user, can see own unapproved posts topic
+ array(
+ 'phpbb_topics',
+ 0,
+ true,
+ 'topic', 1, '',
+ array(),
+ array(
+ array('topic_id' => 1),
+ array('topic_id' => 2),
+ ),
+ ),
);
}
/**
* @dataProvider get_visibility_sql_data
*/
- public function test_get_visibility_sql($table, $mode, $forum_id, $table_alias, $permissions, $expected)
+ public function test_get_visibility_sql($table, $user_id, $display_unapproved, $mode, $forum_id, $table_alias, $permissions, $expected)
{
global $cache, $db, $auth, $phpbb_root_path, $phpEx;
@@ -76,7 +137,7 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te
$db = $this->new_dbal();
// Create auth mock
- $auth = $this->getMock('\phpbb\auth\auth');
+ $auth = $this->createMock('\phpbb\auth\auth');
$auth->expects($this->any())
->method('acl_get')
->with($this->stringContains('_'), $this->anything())
@@ -84,15 +145,20 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$lang = new \phpbb\language\language($lang_loader);
$user = new \phpbb\user($lang, '\phpbb\datetime');
- $config = new phpbb\config\config(array());
+ $user->data['user_id'] = $user_id;
+ $config = $this->config = new \phpbb\config\config(array(
+ 'display_unapproved_posts' => $display_unapproved,
+ ));
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$content_visibility = new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE);
- $result = $db->sql_query('SELECT ' . $mode . '_id
+ $sql = 'SELECT ' . $mode . '_id
FROM ' . $table . '
WHERE ' . $content_visibility->get_visibility_sql($mode, $forum_id, $table_alias) . '
- ORDER BY ' . $mode . '_id ASC');
+ ORDER BY ' . $mode . '_id ASC';
+ $result = $db->sql_query($sql);
$this->assertEquals($expected, $db->sql_fetchrowset($result));
+ $db->sql_freeresult($result);
}
}
diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php
index e33a1f30d5..8f629dca62 100644
--- a/tests/content_visibility/set_post_visibility_test.php
+++ b/tests/content_visibility/set_post_visibility_test.php
@@ -120,7 +120,7 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $auth = $this->getMock('\phpbb\auth\auth');
+ $auth = $this->createMock('\phpbb\auth\auth');
$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');
@@ -173,7 +173,7 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $auth = $this->getMock('\phpbb\auth\auth');
+ $auth = $this->createMock('\phpbb\auth\auth');
$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');
diff --git a/tests/content_visibility/set_topic_visibility_test.php b/tests/content_visibility/set_topic_visibility_test.php
index 78431396c3..3db79c0fe0 100644
--- a/tests/content_visibility/set_topic_visibility_test.php
+++ b/tests/content_visibility/set_topic_visibility_test.php
@@ -84,7 +84,7 @@ class phpbb_content_visibility_set_topic_visibility_test extends phpbb_database_
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $auth = $this->getMock('\phpbb\auth\auth');
+ $auth = $this->createMock('\phpbb\auth\auth');
$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');
diff --git a/tests/controller/common_helper_route.php b/tests/controller/common_helper_route.php
index ea2bc042b1..bdaf8ee682 100644
--- a/tests/controller/common_helper_route.php
+++ b/tests/controller/common_helper_route.php
@@ -29,7 +29,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
private $router;
private $routing_helper;
- public function setUp()
+ public function setUp(): void
{
global $phpbb_dispatcher, $phpbb_root_path, $phpEx;
@@ -74,7 +74,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
protected function generate_route_objects()
{
- global $request;
+ global $request, $phpbb_root_path, $phpEx;
$this->request = new phpbb_mock_request();
$this->request->overwrite('SCRIPT_NAME', $this->get_uri(), \phpbb\request\request_interface::SERVER);
@@ -122,7 +122,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
'autoescape' => false,
)
);
- $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $this->config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user)));
+ $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $this->config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $twig, $this->user)));
$twig->setLexer(new \phpbb\template\twig\lexer($twig));
$this->extension_manager = new phpbb_mock_extension_manager(
@@ -140,7 +140,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
new \phpbb\routing\file_locator($this->filesystem, dirname(__FILE__) . '/')
);
$resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager);
- $this->router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php');
+ $this->router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php', false);
// Set correct current phpBB root path
$this->root_path = $this->get_phpbb_root_path();
diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php
index d921d0eade..ddc1921b0e 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()
+ public function setUp(): void
{
$this->extension_manager = new phpbb_mock_extension_manager(
dirname(__FILE__) . '/',
@@ -48,7 +48,7 @@ class phpbb_controller_controller_test extends phpbb_test_case
new \phpbb\routing\file_locator(new \phpbb\filesystem\filesystem(), dirname(__FILE__) . '/')
);
$resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $this->extension_manager);
- $router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php');
+ $router = new phpbb_mock_router($container, $resources_locator, $loader, dirname(__FILE__) . '/', 'php', false);
$routes = $router->get_routes();
// This will need to be updated if any new routes are defined
@@ -128,7 +128,8 @@ class phpbb_controller_controller_test extends phpbb_test_case
if (!empty($exception))
{
- $this->setExpectedException($exception, $exception_message);
+ $this->expectException($exception);
+ $this->expectExceptionMessage($exception_message);
}
$this->assertEquals($expected, $resolver->getArguments($symfony_request, $input));
diff --git a/tests/cron/manager_test.php b/tests/cron/manager_test.php
index 76f8c753bf..f025e38cd5 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()
+ public function setUp(): void
{
$this->manager = $this->create_cron_manager(array(
new phpbb_cron_task_core_dummy_task(),
@@ -75,6 +75,33 @@ class phpbb_cron_manager_test extends \phpbb_test_case
{
global $phpbb_root_path, $phpEx;
- return new \phpbb\cron\manager($tasks, $phpbb_root_path, $phpEx);
+ $mock_config = new \phpbb\config\config(array(
+ 'force_server_vars' => false,
+ 'enable_mod_rewrite' => '',
+ ));
+
+ $mock_router = $this->getMockBuilder('\phpbb\routing\router')
+ ->setMethods(array('setContext', 'generate'))
+ ->disableOriginalConstructor()
+ ->getMock();
+ $mock_router->method('setContext')
+ ->willReturn(true);
+ $mock_router->method('generate')
+ ->willReturn('foobar');
+
+ $request = new \phpbb\request\request();
+ $request->enable_super_globals();
+
+ $routing_helper = new \phpbb\routing\helper(
+ $mock_config,
+ $mock_router,
+ new \phpbb\symfony_request($request),
+ $request,
+ new \phpbb\filesystem\filesystem(),
+ $phpbb_root_path,
+ $phpEx
+ );
+
+ return new \phpbb\cron\manager($tasks, $routing_helper, $phpbb_root_path, $phpEx);
}
}
diff --git a/tests/dbal/auto_increment_test.php b/tests/dbal/auto_increment_test.php
index 950a4fc8f7..27d10d2843 100644
--- a/tests/dbal/auto_increment_test.php
+++ b/tests/dbal/auto_increment_test.php
@@ -23,7 +23,7 @@ class phpbb_dbal_auto_increment_test extends phpbb_database_test_case
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
}
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
@@ -42,7 +42,7 @@ class phpbb_dbal_auto_increment_test extends phpbb_database_test_case
$this->table_exists = true;
}
- protected function tearDown()
+ protected function tearDown(): void
{
if ($this->table_exists)
{
diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php
index 0365463a48..20ea2b3729 100644
--- a/tests/dbal/db_tools_test.php
+++ b/tests/dbal/db_tools_test.php
@@ -25,7 +25,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/config.xml');
}
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
@@ -77,7 +77,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
$this->table_exists = true;
}
- protected function tearDown()
+ protected function tearDown(): void
{
if ($this->table_exists)
{
@@ -346,10 +346,10 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
public function test_perform_schema_changes_drop_tables()
{
- $db_tools = $this->getMock('\phpbb\db\tools\tools', array(
- 'sql_table_exists',
- 'sql_table_drop',
- ), array(&$this->db));
+ $db_tools = $this->getMockBuilder('\phpbb\db\tools\tools')
+ ->setMethods(array('sql_table_exists', 'sql_table_drop'))
+ ->setConstructorArgs(array(&$this->db))
+ ->getMock();
// pretend all tables exist
$db_tools->expects($this->any())->method('sql_table_exists')
@@ -372,10 +372,10 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
public function test_perform_schema_changes_drop_columns()
{
- $db_tools = $this->getMock('\phpbb\db\tools\tools', array(
- 'sql_column_exists',
- 'sql_column_remove',
- ), array(&$this->db));
+ $db_tools = $this->getMockBuilder('\phpbb\db\tools\tools')
+ ->setMethods(array('sql_column_exists', 'sql_column_remove'))
+ ->setConstructorArgs(array(&$this->db))
+ ->getMock();
// pretend all columns exist
$db_tools->expects($this->any())->method('sql_column_exists')
diff --git a/tests/dbal/migration/if.php b/tests/dbal/migration/if.php
index 481250ea77..83fba1cbd4 100644
--- a/tests/dbal/migration/if.php
+++ b/tests/dbal/migration/if.php
@@ -23,11 +23,11 @@ class phpbb_dbal_migration_if extends \phpbb\db\migration\migration
return array(
array('if', array(
true,
- array('custom', array(array(&$this, 'test_true'))),
+ array('custom', array(array($this, 'test_true'))),
)),
array('if', array(
false,
- array('custom', array(array(&$this, 'test_false'))),
+ array('custom', array(array($this, 'test_false'))),
)),
);
}
diff --git a/tests/dbal/migration/if_params.php b/tests/dbal/migration/if_params.php
new file mode 100644
index 0000000000..7280088ddc
--- /dev/null
+++ b/tests/dbal/migration/if_params.php
@@ -0,0 +1,44 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+class phpbb_dbal_migration_if_params extends \phpbb\db\migration\migration
+{
+ function update_schema()
+ {
+ return array();
+ }
+
+ function update_data()
+ {
+ return array(
+ array('if', array(
+ true,
+ array('custom', array(array($this, 'test'), array('true'))),
+ )),
+ array('if', array(
+ false,
+ array('custom', array(array($this, 'test'), array('false'))),
+ )),
+ );
+ }
+
+ function test($param)
+ {
+ global $migrator_test_if_true_failed, $migrator_test_if_false_failed;
+
+ $var = 'migrator_test_if_' . $param . '_failed';
+
+ ${$var} = !${$var};
+ }
+
+}
diff --git a/tests/dbal/migration/recall.php b/tests/dbal/migration/recall.php
index c0333b084d..e065b5c4d8 100644
--- a/tests/dbal/migration/recall.php
+++ b/tests/dbal/migration/recall.php
@@ -21,7 +21,7 @@ class phpbb_dbal_migration_recall extends \phpbb\db\migration\migration
function update_data()
{
return array(
- array('custom', array(array(&$this, 'test_call'))),
+ array('custom', array(array($this, 'test_call'))),
);
}
diff --git a/tests/dbal/migration/recall_params.php b/tests/dbal/migration/recall_params.php
new file mode 100644
index 0000000000..ee0f04c09d
--- /dev/null
+++ b/tests/dbal/migration/recall_params.php
@@ -0,0 +1,42 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+class phpbb_dbal_migration_recall_params extends \phpbb\db\migration\migration
+{
+ function update_schema()
+ {
+ return array();
+ }
+
+ function update_data()
+ {
+ return array(
+ array('custom', array(array($this, 'test_call'), array(5))),
+ );
+ }
+
+ // This function should be called 5 times
+ function test_call($times, $input)
+ {
+ global $migrator_test_call_input;
+
+ $migrator_test_call_input = (int) $input;
+
+ if ($migrator_test_call_input < $times)
+ {
+ return ($migrator_test_call_input + 1);
+ }
+
+ return;
+ }
+}
diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php
index 372b2dbe1e..7d6b100449 100644
--- a/tests/dbal/migrator_test.php
+++ b/tests/dbal/migrator_test.php
@@ -15,6 +15,8 @@ require_once dirname(__FILE__) . '/migration/dummy.php';
require_once dirname(__FILE__) . '/migration/unfulfillable.php';
require_once dirname(__FILE__) . '/migration/if.php';
require_once dirname(__FILE__) . '/migration/recall.php';
+require_once dirname(__FILE__) . '/migration/if_params.php';
+require_once dirname(__FILE__) . '/migration/recall_params.php';
require_once dirname(__FILE__) . '/migration/revert.php';
require_once dirname(__FILE__) . '/migration/revert_with_dependency.php';
require_once dirname(__FILE__) . '/migration/revert_table.php';
@@ -42,7 +44,7 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/migrator.xml');
}
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -196,6 +198,54 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
$this->assertSame(10, $migrator_test_call_input);
}
+ public function test_if_params()
+ {
+ $this->migrator->set_migrations(array('phpbb_dbal_migration_if_params'));
+
+ // Don't like this, but I'm not sure there is any other way to do this
+ global $migrator_test_if_true_failed, $migrator_test_if_false_failed;
+ $migrator_test_if_true_failed = true;
+ $migrator_test_if_false_failed = false;
+
+ while (!$this->migrator->finished())
+ {
+ $this->migrator->update();
+ }
+
+ $this->assertFalse($migrator_test_if_true_failed, 'True test failed');
+ $this->assertFalse($migrator_test_if_false_failed, 'False test failed');
+
+ while ($this->migrator->migration_state('phpbb_dbal_migration_if_params') !== false)
+ {
+ $this->migrator->revert('phpbb_dbal_migration_if_params');
+ }
+
+ $this->assertFalse($migrator_test_if_true_failed, 'True test after revert failed');
+ $this->assertFalse($migrator_test_if_false_failed, 'False test after revert failed');
+ }
+
+ public function test_recall_params()
+ {
+ $this->migrator->set_migrations(array('phpbb_dbal_migration_recall_params'));
+
+ global $migrator_test_call_input;
+
+ // Run the schema first
+ $this->migrator->update();
+
+ $i = 0;
+ while (!$this->migrator->finished())
+ {
+ $this->migrator->update();
+
+ $this->assertSame($i, $migrator_test_call_input);
+
+ $i++;
+ }
+
+ $this->assertSame(5, $migrator_test_call_input);
+ }
+
public function test_revert()
{
global $migrator_test_revert_counter;
diff --git a/tests/dbal/migrator_tool_config_test.php b/tests/dbal/migrator_tool_config_test.php
index 13e0c13e3c..74d816dbcd 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()
+ public 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 b271c2d62e..051e0a7556 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()
+ public function setUp(): void
{
parent::setup();
diff --git a/tests/dbal/migrator_tool_module_test.php b/tests/dbal/migrator_tool_module_test.php
index e34ee7b59c..ecc7b384e7 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()
+ public 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;
@@ -39,7 +39,7 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
$cache = new phpbb_mock_cache;
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
- $auth = $this->getMock('\phpbb\auth\auth');
+ $auth = $this->createMock('\phpbb\auth\auth');
$phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
// Correctly set the root path for this test to this directory, so the classes can be found
diff --git a/tests/dbal/migrator_tool_permission_test.php b/tests/dbal/migrator_tool_permission_test.php
index ccad6a1387..a48c367896 100644
--- a/tests/dbal/migrator_tool_permission_test.php
+++ b/tests/dbal/migrator_tool_permission_test.php
@@ -24,7 +24,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()
+ public 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 07d7318358..e9fb1f2724 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()
+ public 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 eae0abceba..b0e678b9da 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()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php
index 1fd2cbd7ee..16b49d1f17 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()
+ public function setUp(): void
{
$this->phpbb_root_path = dirname(__FILE__) . '/';
$this->config_php = new \phpbb\config_php_file($this->phpbb_root_path . 'fixtures/', 'php');
@@ -77,6 +77,18 @@ namespace
$this->assertTrue($container->isFrozen());
}
+ public function test_tables_mapping()
+ {
+ $this->builder->without_cache();
+ $container = $this->builder->get_container();
+ $this->assertTrue($container->hasParameter('tables'));
+ $tables = $container->getParameter('tables');
+ $this->assertGreaterThan(0, count($tables));
+ $this->assertTrue($container->hasParameter('tables.foo_bar'));
+ $this->assertTrue(isset($tables['foo_bar']));
+ $this->assertEquals($tables['acl_groups'], 'phpbb_some_other');
+ }
+
public function test_without_cache()
{
$this->builder->without_cache();
diff --git a/tests/di/fixtures/config/production/container/environment.yml b/tests/di/fixtures/config/production/container/environment.yml
index 8281d9e941..0af08f0849 100644
--- a/tests/di/fixtures/config/production/container/environment.yml
+++ b/tests/di/fixtures/config/production/container/environment.yml
@@ -1,5 +1,8 @@
parameters:
core: true
+ tables.acl_groups: '%core.table_prefix%acl_groups'
+ tables.acl_options: '%core.table_prefix%acl_options'
+ tables.acl_roles: '%core.table_prefix%acl_roles'
services:
config.php:
diff --git a/tests/di/fixtures/config/test/container/environment.yml b/tests/di/fixtures/config/test/container/environment.yml
index 252117dd32..0a9e4b5e77 100644
--- a/tests/di/fixtures/config/test/container/environment.yml
+++ b/tests/di/fixtures/config/test/container/environment.yml
@@ -1,5 +1,8 @@
parameters:
core: true
+ tables.acl_groups: '%core.table_prefix%acl_groups'
+ tables.acl_options: '%core.table_prefix%acl_options'
+ tables.acl_roles: '%core.table_prefix%acl_roles'
services:
config.php:
diff --git a/tests/di/fixtures/ext/vendor/enabled_4/environment.yml b/tests/di/fixtures/ext/vendor/enabled_4/environment.yml
index d0affe4fd6..d4ed5cbf24 100644
--- a/tests/di/fixtures/ext/vendor/enabled_4/environment.yml
+++ b/tests/di/fixtures/ext/vendor/enabled_4/environment.yml
@@ -1,2 +1,4 @@
parameters:
enabled_4: true
+ tables.foo_bar: '%core.table_prefix%foo_bar'
+ tables.acl_groups: '%core.table_prefix%some_other'
diff --git a/tests/di/ordered_service_collection_test.php b/tests/di/ordered_service_collection_test.php
index 47e6d23744..baa9776573 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()
+ public 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 5b51254a4a..97c13ab163 100644
--- a/tests/di/service_collection_test.php
+++ b/tests/di/service_collection_test.php
@@ -18,15 +18,19 @@ class phpbb_service_collection_test extends \phpbb_test_case
*/
protected $service_collection;
- public function setUp()
+ public function setUp(): void
{
$container = new phpbb_mock_container_builder();
$container->set('foo', new StdClass);
$container->set('bar', new StdClass);
+ $container->set('baz', new StdClass);
$this->service_collection = new \phpbb\di\service_collection($container);
$this->service_collection->add('foo');
$this->service_collection->add('bar');
+ $this->service_collection->add_service_class('foo', 'foo_class');
+ $this->service_collection->add_service_class('bar', 'bar_class');
+ $this->service_collection->add_service_class('baz', 'bar_class');
parent::setUp();
}
@@ -44,4 +48,25 @@ class phpbb_service_collection_test extends \phpbb_test_case
$this->assertSame(array('foo', 'bar'), $service_names);
}
+
+ public function test_get_by_class()
+ {
+ $this->assertSame($this->service_collection['foo'], $this->service_collection->get_by_class('foo_class'));
+ }
+
+ public function test_get_by_class_many_services_exception()
+ {
+ $this->expectException('RuntimeException');
+ $this->expectExceptionMessage('More than one service definitions found for class "bar_class" in collection.');
+
+ $this->service_collection->get_by_class('bar_class');
+ }
+
+ public function test_get_by_class_no_service_exception()
+ {
+ $this->expectException('RuntimeException');
+ $this->expectExceptionMessage('No service found for class "baz_class" in collection.');
+
+ $this->service_collection->get_by_class('baz_class');
+ }
}
diff --git a/tests/email/email_parsing_test.php b/tests/email/email_parsing_test.php
index 8fdfe3035e..629df9abb6 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()
+ public function setUp(): void
{
global $phpbb_container, $config, $phpbb_root_path, $phpEx, $request, $user;
@@ -67,13 +67,6 @@ class phpbb_email_parsing_test extends phpbb_test_case
$phpbb_container->set('ext.manager', $extension_manager);
$context = new \phpbb\template\context();
- $twig_extension = new \phpbb\template\twig\extension($context, $lang);
- $phpbb_container->set('template.twig.extensions.phpbb', $twig_extension);
-
- $twig_extensions_collection = new \phpbb\di\service_collection($phpbb_container);
- $twig_extensions_collection->add('template.twig.extensions.phpbb');
- $phpbb_container->set('template.twig.extensions.collection', $twig_extensions_collection);
-
$twig = new \phpbb\template\twig\environment(
$config,
$filesystem,
@@ -89,6 +82,13 @@ class phpbb_email_parsing_test extends phpbb_test_case
'autoescape' => false,
)
);
+ $twig_extension = new \phpbb\template\twig\extension($context, $twig, $lang);
+ $phpbb_container->set('template.twig.extensions.phpbb', $twig_extension);
+
+ $twig_extensions_collection = new \phpbb\di\service_collection($phpbb_container);
+ $twig_extensions_collection->add('template.twig.extensions.phpbb');
+ $phpbb_container->set('template.twig.extensions.collection', $twig_extensions_collection);
+
$twig->addExtension($twig_extension);
$phpbb_container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig));
diff --git a/tests/error_collector_test.php b/tests/error_collector_test.php
index 8ed89bbe52..c7701cfad0 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()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/event/exception_listener_test.php b/tests/event/exception_listener_test.php
index 08679a3ed8..fbae9e25b7 100644
--- a/tests/event/exception_listener_test.php
+++ b/tests/event/exception_listener_test.php
@@ -84,7 +84,7 @@ class exception_listener extends phpbb_test_case
$exception_listener = new \phpbb\event\kernel_exception_subscriber($template, $lang);
- $event = new \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent($this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), $request, \Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST, $exception);
+ $event = new \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent($this->createMock('Symfony\Component\HttpKernel\HttpKernelInterface'), $request, \Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST, $exception);
$exception_listener->on_kernel_exception($event);
$response = $event->getResponse();
diff --git a/tests/event/export_php_test.php b/tests/event/export_php_test.php
index 21bbb0620a..92280b6f4f 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()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/event/php_exporter_test.php b/tests/event/php_exporter_test.php
index c6670e1340..5c9e20aa7d 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()
+ public function setUp(): void
{
parent::setUp();
$this->exporter = new \phpbb\event\php_exporter(dirname(__FILE__) . '/fixtures/');
@@ -122,7 +122,7 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
static public function crawl_php_file_throws_data()
{
return array(
- array('missing_var.test', null),
+ array('missing_var.test', 2),
array('duplicate_event.test', 10),
);
}
@@ -132,7 +132,8 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
*/
public function test_crawl_php_file_throws($file, $exception_code)
{
- $this->setExpectedException('LogicException', '', $exception_code);
+ $this->expectException('LogicException');
+ $this->expectExceptionCode($exception_code);
$this->exporter->crawl_php_file($file);
}
@@ -206,7 +207,8 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
*/
public function test_validate_event_throws($event_name, $event, $exception_code)
{
- $this->setExpectedException('LogicException', '', $exception_code);
+ $this->expectException('LogicException');
+ $this->expectExceptionCode($exception_code);
$this->exporter->validate_event($event_name, $event);
}
@@ -461,7 +463,8 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
*/
public function test_get_vars_from_array_throws($lines, $event_line, $exception_code)
{
- $this->setExpectedException('LogicException', '', $exception_code);
+ $this->expectException('LogicException');
+ $this->expectExceptionCode($exception_code);
$this->exporter->set_current_event('', $event_line);
$this->exporter->set_content($lines);
@@ -546,7 +549,8 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
*/
public function test_get_vars_from_docblock_throws($lines, $event_line, $exception_code)
{
- $this->setExpectedException('LogicException', '', $exception_code);
+ $this->expectException('LogicException');
+ $this->expectExceptionCode($exception_code);
$this->exporter->set_current_event('', $event_line);
$this->exporter->set_content($lines);
@@ -649,7 +653,8 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
*/
public function test_find_since_throws($lines, $event_line, $exception_code)
{
- $this->setExpectedException('LogicException', '', $exception_code);
+ $this->expectException('LogicException');
+ $this->expectExceptionCode($exception_code);
$this->exporter->set_current_event('', $event_line);
$this->exporter->set_content($lines);
@@ -750,7 +755,8 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
*/
public function test_find_description_throws($lines, $event_line, $exception_code)
{
- $this->setExpectedException('LogicException', '', $exception_code);
+ $this->expectException('LogicException');
+ $this->expectExceptionCode($exception_code);
$this->exporter->set_current_event('', $event_line);
$this->exporter->set_content($lines);
diff --git a/tests/extension/ext/vendor5/foo/composer.json b/tests/extension/ext/vendor5/foo/composer.json
new file mode 100644
index 0000000000..0fa052e188
--- /dev/null
+++ b/tests/extension/ext/vendor5/foo/composer.json
@@ -0,0 +1,23 @@
+{
+ "name": "vendor5/foo",
+ "type": "phpbb-extension",
+ "description": "An example/sample extension to be used for testing purposes in phpBB Development.",
+ "version": "1.0.0",
+ "time": "2012-02-15 01:01:01",
+ "license": "GPL-2.0",
+ "authors": [{
+ "name": "John Smith",
+ "email": "email@phpbb.com",
+ "homepage": "http://phpbb.com",
+ "role": "N/A"
+ }],
+ "require": {
+ "php": ">=5.3"
+ },
+ "extra": {
+ "display-name": "phpBB Bar Extension",
+ "soft-require": {
+ "phpbb/phpbb": "3.3.*@dev"
+ }
+ }
+}
diff --git a/tests/extension/ext/vendor5/foo/ext.php b/tests/extension/ext/vendor5/foo/ext.php
new file mode 100644
index 0000000000..6bf03f001c
--- /dev/null
+++ b/tests/extension/ext/vendor5/foo/ext.php
@@ -0,0 +1,19 @@
+<?php
+
+namespace vendor5\foo;
+
+class ext extends \phpbb\extension\base
+{
+ static public $enabled;
+
+ public function is_enableable()
+ {
+ return array('Reason 1', 'Reason 2');
+ }
+
+ public function enable_step($old_state)
+ {
+ self::$enabled = true;
+ return self::$enabled;
+ }
+}
diff --git a/tests/extension/extension_base_test.php b/tests/extension/extension_base_test.php
index e0c2e6d549..1f44fdb234 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()
+ public 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 71de2c2fc5..7649b4f19a 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()
+ public function setUp(): void
{
$this->extension_manager = new phpbb_mock_extension_manager(
dirname(__FILE__) . '/',
@@ -239,7 +239,7 @@ class phpbb_extension_finder_test extends phpbb_test_case
/**
* These do not work because of changes with PHPBB3-11386
- * They do not seem neccessary to me, so I am commenting them out for now
+ * They do not seem necessary to me, so I am commenting them out for now
public function test_get_classes_create_cache()
{
$cache = new phpbb_mock_cache;
diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php
index f619d4c19d..3ab0f608d1 100644
--- a/tests/extension/manager_test.php
+++ b/tests/extension/manager_test.php
@@ -26,7 +26,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/extensions.xml');
}
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
@@ -36,7 +36,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
public function test_all_available()
{
// barfoo and vendor3/bar should not listed due to missing composer.json. barfoo also has incorrect dir structure.
- $this->assertEquals(array('vendor/moo', 'vendor2/bar', 'vendor2/foo', 'vendor3/foo', 'vendor4/bar'), array_keys($this->extension_manager->all_available()));
+ $this->assertEquals(array('vendor/moo', 'vendor2/bar', 'vendor2/foo', 'vendor3/foo', 'vendor4/bar', 'vendor5/foo'), array_keys($this->extension_manager->all_available()));
}
public function test_all_enabled()
diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php
index 533da68c57..a2f0542979 100644
--- a/tests/extension/metadata_manager_test.php
+++ b/tests/extension/metadata_manager_test.php
@@ -32,7 +32,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/extensions.xml');
}
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
@@ -59,7 +59,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
new phpbb_mock_request()
),
$filesystem,
- $this->getMock('\phpbb\request\request'),
+ $this->createMock('\phpbb\request\request'),
$this->phpbb_root_path,
$this->phpEx
);
@@ -111,7 +111,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$lang = new \phpbb\language\language($lang_loader);
$this->user = new \phpbb\user($lang, '\phpbb\datetime');
- $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user)));
+ $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $twig, $this->user)));
$twig->setLexer(new \phpbb\template\twig\lexer($twig));
}
diff --git a/tests/extension/modules_test.php b/tests/extension/modules_test.php
index 88634bc6ba..f8c65bc147 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()
+ public function setUp(): void
{
global $phpbb_extension_manager;
@@ -46,7 +46,7 @@ class phpbb_extension_modules_test extends phpbb_test_case
$this->module_manager = new \phpbb\module\module_manager(
new \phpbb\cache\driver\dummy(),
- $this->getMock('\phpbb\db\driver\driver_interface'),
+ $this->createMock('\phpbb\db\driver\driver_interface'),
$this->extension_manager,
MODULES_TABLE,
dirname(__FILE__) . '/',
diff --git a/tests/feed/attachments_base_test.php b/tests/feed/attachments_base_test.php
index 573218be42..3798056f10 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()
+ public function setUp(): void
{
global $phpbb_root_path, $phpEx;
@@ -36,7 +36,7 @@ class phpbb_feed_attachments_base_test extends phpbb_database_test_case
new phpbb_mock_request()
),
$this->filesystem,
- $this->getMock('\phpbb\request\request'),
+ $this->createMock('\phpbb\request\request'),
$phpbb_root_path,
'php'
);
@@ -99,7 +99,7 @@ class phpbb_feed_attachments_base_test extends phpbb_database_test_case
if ($expected_exception !== false)
{
- $this->setExpectedException($expected_exception);
+ $this->expectException($expected_exception);
$this->attachments_mocks_feed->get_sql();
}
diff --git a/tests/files/types_base_test.php b/tests/files/types_base_test.php
index e630bf8c48..28c5a12c3d 100644
--- a/tests/files/types_base_test.php
+++ b/tests/files/types_base_test.php
@@ -35,11 +35,11 @@ class phpbb_files_types_base_test extends phpbb_test_case
/** @var string phpBB root path */
protected $phpbb_root_path;
- protected function setUp()
+ protected function setUp(): void
{
global $phpbb_root_path, $phpEx;
- $this->request = $this->getMock('\phpbb\request\request');
+ $this->request = $this->createMock('\phpbb\request\request');
$this->filesystem = new \phpbb\filesystem\filesystem();
$this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
@@ -75,10 +75,11 @@ class phpbb_files_types_base_test extends phpbb_test_case
*/
public function test_check_upload_size($filename, $max_filesize, $expected)
{
- $php_ini = $this->getMock('\bantu\IniGetWrapper\IniGetWrapper');
+ $php_ini = $this->createMock('\bantu\IniGetWrapper\IniGetWrapper');
$php_ini->expects($this->any())
->method('getString')
->willReturn($max_filesize);
+ $upload = new \phpbb\files\upload($this->filesystem, $this->factory, $this->language, $php_ini, $this->request);
$type_form = new \phpbb\files\types\local($this->factory, $this->language, $php_ini, $this->request);
$file = $this->getMockBuilder('\phpbb\files\filespec')
->disableOriginalConstructor()
@@ -86,6 +87,7 @@ class phpbb_files_types_base_test extends phpbb_test_case
$file->expects($this->any())
->method('get')
->willReturn($filename);
+ $type_form->set_upload($upload);
$type_form->check_upload_size($file);
$this->assertSame($expected, $file->error);
diff --git a/tests/files/types_form_test.php b/tests/files/types_form_test.php
index 925babb47f..ffebcf603f 100644
--- a/tests/files/types_form_test.php
+++ b/tests/files/types_form_test.php
@@ -38,11 +38,11 @@ class phpbb_files_types_form_test extends phpbb_test_case
/** @var string phpBB root path */
protected $phpbb_root_path;
- protected function setUp()
+ protected function setUp(): void
{
global $phpbb_root_path, $phpEx;
- $this->request = $this->getMock('\phpbb\request\request');
+ $this->request = $this->createMock('\phpbb\request\request');
$this->request->expects($this->any())
->method('file')
->willReturn(array());
@@ -137,7 +137,7 @@ class phpbb_files_types_form_test extends phpbb_test_case
*/
public function test_upload_form($upload, $expected, $plupload = array())
{
- $this->request = $this->getMock('\phpbb\request\request');
+ $this->request = $this->createMock('\phpbb\request\request');
$this->request->expects($this->any())
->method('file')
->willReturn($upload);
diff --git a/tests/files/types_local_test.php b/tests/files/types_local_test.php
index 31070de107..7468e9c4a7 100644
--- a/tests/files/types_local_test.php
+++ b/tests/files/types_local_test.php
@@ -38,11 +38,11 @@ class phpbb_files_types_local_test extends phpbb_test_case
/** @var string phpBB root path */
protected $phpbb_root_path;
- protected function setUp()
+ protected function setUp(): void
{
global $phpbb_root_path, $phpEx;
- $this->request = $this->getMock('\phpbb\request\request');
+ $this->request = $this->createMock('\phpbb\request\request');
$this->request->expects($this->any())
->method('file')
->willReturn(array());
diff --git a/tests/files/types_remote_test.php b/tests/files/types_remote_test.php
index 1a7d63d790..d42a609fbb 100644
--- a/tests/files/types_remote_test.php
+++ b/tests/files/types_remote_test.php
@@ -40,14 +40,14 @@ class phpbb_files_types_remote_test extends phpbb_test_case
/** @var string phpBB root path */
protected $phpbb_root_path;
- protected function setUp()
+ protected function setUp(): void
{
global $config, $phpbb_root_path, $phpEx;
$config = new \phpbb\config\config(array());
$this->config = $config;
$this->config->set('remote_upload_verify', 0);
- $this->request = $this->getMock('\phpbb\request\request');
+ $this->request = $this->createMock('\phpbb\request\request');
$this->filesystem = new \phpbb\filesystem\filesystem();
$this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
@@ -102,7 +102,7 @@ class phpbb_files_types_remote_test extends phpbb_test_case
*/
public function test_get_max_file_size($max_file_size, $link, $expected = array('URL_NOT_FOUND'))
{
- $php_ini = $this->getMock('\bantu\IniGetWrapper\IniGetWrapper', array('getString'));
+ $php_ini = $this->createMock('\bantu\IniGetWrapper\IniGetWrapper', array('getString'));
$php_ini->expects($this->any())
->method('getString')
->willReturn($max_file_size);
diff --git a/tests/files/upload_test.php b/tests/files/upload_test.php
index c41204a0d5..c8857f863d 100644
--- a/tests/files/upload_test.php
+++ b/tests/files/upload_test.php
@@ -35,7 +35,7 @@ class phpbb_files_upload_test extends phpbb_test_case
/** @var string phpBB root path */
protected $phpbb_root_path;
- protected function setUp()
+ protected function setUp(): void
{
// Global $config required by unique_id
global $config, $phpbb_root_path, $phpEx;
@@ -48,7 +48,7 @@ class phpbb_files_upload_test extends phpbb_test_case
$config['rand_seed'] = '';
$config['rand_seed_last_update'] = time() + 600;
- $this->request = $this->getMock('\phpbb\request\request');
+ $this->request = $this->createMock('\phpbb\request\request');
$this->filesystem = new \phpbb\filesystem\filesystem();
$this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
diff --git a/tests/filesystem/clean_path_test.php b/tests/filesystem/clean_path_test.php
index d2dec424b4..dbb06e5e74 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()
+ public 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 7a50989b74..55e729feb7 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()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/filesystem/realpath_test.php b/tests/filesystem/realpath_test.php
index d994935f94..3d05cd7ff2 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()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/functional/acp_bbcodes_test.php b/tests/functional/acp_bbcodes_test.php
index 58681dfa07..cc6397fdfd 100644
--- a/tests/functional/acp_bbcodes_test.php
+++ b/tests/functional/acp_bbcodes_test.php
@@ -43,4 +43,44 @@ class phpbb_functional_acp_bbcodes_test extends phpbb_functional_test_case
$this->assertContains('<div>c</div>', $html);
$this->assertContains('<div>d</div>', $html);
}
+
+ /**
+ * @dataProvider get_bbcode_error_tests
+ */
+ public function test_bbcode_error($match, $tpl, $error)
+ {
+ $this->login();
+ $this->admin_login();
+
+ $crawler = self::request('GET', 'adm/index.php?i=acp_bbcodes&sid=' . $this->sid . '&mode=bbcodes&action=add');
+ $form = $crawler->selectButton('Submit')->form([
+ 'bbcode_match' => $match,
+ 'bbcode_tpl' => $tpl
+ ]);
+ $crawler = self::submit($form);
+
+ $text = $crawler->filter('.errorbox')->text();
+ $this->assertStringContainsString($error, $text);
+ }
+
+ public function get_bbcode_error_tests()
+ {
+ return [
+ [
+ 'XXX',
+ '',
+ 'BBCode is constructed in an invalid form'
+ ],
+ [
+ '[x]{TEXT}[/x]',
+ '<xsl:invalid',
+ 'template is invalid'
+ ],
+ [
+ '[x]{TEXT}[/x]',
+ '<script>{TEXT}</script>',
+ 'unsafe'
+ ],
+ ];
+ }
}
diff --git a/tests/functional/acp_permissions_test.php b/tests/functional/acp_permissions_test.php
index 0a40e76057..ccaa4aab29 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()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/functional/acp_profile_field_test.php b/tests/functional/acp_profile_field_test.php
index 7a0a6ca941..4c0414f03a 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()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/functional/acp_users_test.php b/tests/functional/acp_users_test.php
index 78028aacb8..c8d0072c28 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()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/functional/common_avatar_test_case.php b/tests/functional/common_avatar_test_case.php
index 924eb1273c..155f6e0c09 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()
+ public function setUp(): void
{
parent::setUp();
$this->path = __DIR__ . '/fixtures/files/';
diff --git a/tests/functional/controllers_compatibility_test.php b/tests/functional/controllers_compatibility_test.php
index 9499888a1a..36a34aa7c8 100644
--- a/tests/functional/controllers_compatibility_test.php
+++ b/tests/functional/controllers_compatibility_test.php
@@ -37,6 +37,13 @@ class phpbb_functional_controllers_compatibility_test extends phpbb_functional_t
$this->assert301('feed.php?t=1', 'app.php/feed/topic/1');
}
+ public function test_cron_compatibility()
+ {
+ $this->assert301('cron.php?cron_type=foo', 'app.php/cron/foo');
+ $this->assert301('cron.php?cron_type=foo&bar=foobar', 'app.php/cron/foo?bar=foobar');
+ $this->assert301('cron.php?cron_type=foo&bar=foobar&who=me', 'app.php/cron/foo?bar=foobar&who=me');
+ }
+
protected function assert301($from, $to)
{
self::$client->followRedirects(false);
@@ -44,6 +51,7 @@ class phpbb_functional_controllers_compatibility_test extends phpbb_functional_t
// Fix sid issues
$location = self::$client->getResponse()->getHeader('Location');
+ $location = str_replace('&amp;', '&', $location);
$location = preg_replace('#sid=[^&]+(&(amp;)?)?#', '', $location);
if (substr($location, -1) === '?')
{
diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php
index ce0f4911e3..9a326dba68 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()
+ public function setUp(): void
{
parent::setUp();
@@ -86,7 +86,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid);
$this->assertCount(1, $crawler->filter('.ext_enabled'));
- $this->assertCount(6, $crawler->filter('.ext_disabled'));
+ $this->assertCount(7, $crawler->filter('.ext_disabled'));
$this->assertContains('phpBB Foo Extension', $crawler->filter('.ext_enabled')->eq(0)->text());
$this->assertContainsLang('EXTENSION_DISABLE', $crawler->filter('.ext_enabled')->eq(0)->text());
@@ -165,9 +165,14 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
$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());
- // Correctly submit the enable form
+ // 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);
$this->assertContainsLang('EXTENSION_NOT_ENABLEABLE', $crawler->filter('.errorbox')->text());
+
+ // 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());
}
public function test_disable_pre()
@@ -195,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->assertContains('Are you sure that you wish to delete the data associated with “phpBB Moo Extension”?', $crawler->filter('#main')->text());
}
public function test_actions()
@@ -206,7 +211,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
// Correctly submit the enable form
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid);
- $form = $crawler->selectButton('enable')->form();
+ $form = $crawler->selectButton('confirm')->form();
$crawler = self::submit($form);
$this->assertContainsLang('EXTENSION_ENABLE_SUCCESS', $crawler->filter('.successbox')->text());
@@ -216,7 +221,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
// Correctly submit the disable form
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid);
- $form = $crawler->selectButton('disable')->form();
+ $form = $crawler->selectButton('confirm')->form();
$crawler = self::submit($form);
$this->assertContainsLang('EXTENSION_DISABLE_SUCCESS', $crawler->filter('.successbox')->text());
@@ -226,12 +231,17 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
// Correctly submit the delete data form
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid);
- $form = $crawler->selectButton('delete_data')->form();
+ $form = $crawler->selectButton('confirm')->form();
$crawler = self::submit($form);
$this->assertContainsLang('EXTENSION_DELETE_DATA_SUCCESS', $crawler->filter('.successbox')->text());
// Attempt to enable invalid extension
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=barfoo&sid=' . $this->sid);
$this->assertContainsLang('EXTENSION_DIR_INVALID', $crawler->filter('.errorbox')->text());
+
+ // Test installing/uninstalling extension altogether
+ $this->logout();
+ $this->install_ext('vendor/moo');
+ $this->uninstall_ext('vendor/moo');
}
}
diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php
index 58c3878b8b..c5ebf761c9 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()
+ public function setUp(): void
{
parent::setUp();
@@ -90,6 +90,15 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
}
/**
+ * Check includejs/includecss when the request_uri is a subdirectory
+ */
+ 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());
+ }
+
+ /**
* Check the error produced by calling a controller without a required
* argument.
*/
diff --git a/tests/functional/extension_global_lang_test.php b/tests/functional/extension_global_lang_test.php
index a1e2547745..94c80a6d9a 100644
--- a/tests/functional/extension_global_lang_test.php
+++ b/tests/functional/extension_global_lang_test.php
@@ -41,10 +41,10 @@ class phpbb_functional_extension_global_lang_test extends phpbb_functional_test_
self::$helper->restore_original_ext_dir();
}
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
-
+
$this->get_db();
$this->phpbb_extension_manager = $this->get_extension_manager();
@@ -52,7 +52,7 @@ class phpbb_functional_extension_global_lang_test extends phpbb_functional_test_
$this->purge_cache();
}
- public function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
diff --git a/tests/functional/extension_module_test.php b/tests/functional/extension_module_test.php
index d3a66b9b35..09d0124990 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()
+ public function setUp(): void
{
global $db;
diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php
index f570d45215..e0721ad1ec 100644
--- a/tests/functional/extension_permission_lang_test.php
+++ b/tests/functional/extension_permission_lang_test.php
@@ -41,12 +41,12 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t
self::$helper->restore_original_ext_dir();
}
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
-
+
$this->get_db();
-
+
$acl_ary = array(
'auth_option' => 'u_foo',
'is_global' => 1,
diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php
index 725a44ae5e..24ddca9c64 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()
+ public 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 ff9450be0d..b2f230b66f 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()
+ public function setUp(): void
{
parent::setUp();
$this->path = __DIR__ . '/fixtures/files/';
$this->add_lang('posting');
}
- public function tearDown()
+ public 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 426ebcee53..25fc9f0508 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()
+ public function setUp(): void
{
parent::setUp();
// Only doing this within the functional framework because we need a
@@ -54,7 +54,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case
$this->filesystem = new \phpbb\filesystem\filesystem();
$this->language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
- $this->request = $this->getMock('\phpbb\request\request');
+ $this->request = $this->createMock('\phpbb\request\request');
$this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper;
$container = new phpbb_mock_container_builder();
@@ -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()
+ public 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 64fa19557f..10946fe5a9 100644
--- a/tests/functional/forgot_password_test.php
+++ b/tests/functional/forgot_password_test.php
@@ -20,8 +20,8 @@ class phpbb_functional_forgot_password_test extends phpbb_functional_test_case
{
global $config;
$this->add_lang('ucp');
- $crawler = self::request('GET', 'ucp.php?mode=sendpassword');
- $this->assertEquals($this->lang('SEND_PASSWORD'), $crawler->filter('h2')->text());
+ $crawler = self::request('GET', 'app.php/user/forgot_password');
+ $this->assertEquals($this->lang('RESET_PASSWORD'), $crawler->filter('h2')->text());
}
public function test_forgot_password_disabled()
@@ -40,12 +40,12 @@ class phpbb_functional_forgot_password_test extends phpbb_functional_test_case
$this->logout();
- $crawler = self::request('GET', 'ucp.php?mode=sendpassword');
+ $crawler = self::request('GET', 'app.php/user/forgot_password');
$this->assertContains($this->lang('UCP_PASSWORD_RESET_DISABLED', '', ''), $crawler->text());
}
- public function tearDown()
+ public 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 8456c40f00..4f4fad4434 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()
+ public 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()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/functional/plupload_test.php b/tests/functional/plupload_test.php
index 4ab1c8e9e5..b7b5b08360 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()
+ public 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()
+ public function tearDown(): void
{
$this->set_extension_group_permission(0);
$iterator = new DirectoryIterator(__DIR__ . '/../../phpBB/files/');
diff --git a/tests/functional/prune_shadow_topic_test.php b/tests/functional/prune_shadow_topic_test.php
index 2bf0280d62..1d4bb02a95 100644
--- a/tests/functional/prune_shadow_topic_test.php
+++ b/tests/functional/prune_shadow_topic_test.php
@@ -130,7 +130,16 @@ class phpbb_functional_prune_shadow_topic_test extends phpbb_functional_test_cas
$crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Prune Shadow']}&sid={$this->sid}");
$this->assertNotEmpty($crawler->filter('img')->last()->attr('src'));
- self::request('GET', "cron.php?cron_type=cron.task.core.prune_shadow_topics&f={$this->data['forums']['Prune Shadow']}&sid={$this->sid}", array(), false);
+ self::request('GET', "app.php/cron/cron.task.core.prune_shadow_topics?f={$this->data['forums']['Prune Shadow']}&sid={$this->sid}", array(), false);
+
+ // Try to ensure that the cron can actually run before we start to wait for it
+ sleep(1);
+ $cron_lock = new \phpbb\lock\db('cron_lock', new \phpbb\config\db($this->db, new \phpbb\cache\driver\dummy(), 'phpbb_config'), $this->db);
+ while (!$cron_lock->acquire())
+ {
+ // do nothing
+ }
+ $cron_lock->release();
$this->assert_forum_details($this->data['forums']['Prune Shadow'], array(
'forum_posts_approved' => 0,
diff --git a/tests/functional/subforum_test.php b/tests/functional/subforum_test.php
new file mode 100644
index 0000000000..6ce4f53c20
--- /dev/null
+++ b/tests/functional/subforum_test.php
@@ -0,0 +1,113 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+/**
+ * @group functional
+ */
+class phpbb_functional_subforum_test extends phpbb_functional_test_case
+{
+ public function test_setup_forums()
+ {
+ $this->login();
+ $this->admin_login();
+
+ $forum_name = 'Subforum Test #1';
+ $crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}");
+ $form = $crawler->selectButton('addforum')->form([
+ 'forum_name' => $forum_name,
+ ]);
+ $crawler = self::submit($form);
+ $form = $crawler->selectButton('update')->form([
+ 'forum_perm_from' => 2,
+ ]);
+ self::submit($form);
+ $forum_id = self::get_forum_id($forum_name);
+
+ // 'Feeds #1.1' is a sub-forum of 'Feeds #1'
+ $forum_name = 'Subforum Test #1.1';
+ $crawler = self::request('GET', "adm/index.php?i=acp_forums&sid={$this->sid}&icat=6&mode=manage&parent_id={$forum_id}");
+ $form = $crawler->selectButton('addforum')->form([
+ 'forum_name' => $forum_name,
+ ]);
+ $crawler = self::submit($form);
+ $form = $crawler->selectButton('update')->form([
+ 'forum_perm_from' => 2,
+ ]);
+ self::submit($form);
+ $forum_id = self::get_forum_id('Subforum Test #1.1');
+
+ // 'Feeds #news' will be used for feed.php?mode=news
+ $crawler = self::request('GET', "adm/index.php?i=acp_forums&sid={$this->sid}&icat=6&mode=manage&parent_id={$forum_id}");
+ $form = $crawler->selectButton('addforum')->form([
+ 'forum_name' => 'Subforum Test #1.1.1',
+ ]);
+ $crawler = self::submit($form);
+ $form = $crawler->selectButton('update')->form([
+ 'forum_perm_from' => 2,
+ ]);
+ self::submit($form);
+ }
+
+ /**
+ * @depends test_setup_forums
+ */
+ 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());
+ }
+
+ /**
+ * @depends test_display_subforums
+ */
+ public function test_display_subforums_limit()
+ {
+ $this->login();
+ $this->admin_login();
+
+ // Disable listing subforums
+ $forum_id = $this->get_forum_id('Subforum Test #1');
+ $crawler = self::request('GET', "adm/index.php?i=acp_forums&sid={$this->sid}&icat=7&mode=manage&parent_id=0&f={$forum_id}&action=edit");
+ $form = $crawler->selectButton('submit')->form([
+ 'display_subforum_limit' => 1,
+ ]);
+ 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());
+ }
+
+ protected function get_forum_id($forum_name)
+ {
+ $this->db = $this->get_db();
+ $forum_id = 0;
+
+ $sql = 'SELECT *
+ FROM ' . FORUMS_TABLE . '
+ WHERE ' . $this->db->sql_in_set('forum_name', $forum_name);
+ $result = $this->db->sql_query($sql);
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ if ($row['forum_name'] == $forum_name)
+ {
+ $forum_id = (int) $row['forum_id'];
+ break;
+ }
+ }
+ $this->db->sql_freeresult($result);
+
+ return $forum_id;
+ }
+}
diff --git a/tests/functional/ucp_pm_test.php b/tests/functional/ucp_pm_test.php
index ddd5c8d791..53de247202 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()
+ public function setUp(): void
{
parent::setUp();
$this->login();
diff --git a/tests/functional/user_password_reset_test.php b/tests/functional/user_password_reset_test.php
index 2361eed066..a97300b9ee 100644
--- a/tests/functional/user_password_reset_test.php
+++ b/tests/functional/user_password_reset_test.php
@@ -25,36 +25,53 @@ 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());
$form = $crawler->selectButton('submit')->form();
$crawler = self::submit($form);
$this->assertContainsLang('NO_EMAIL_USER', $crawler->text());
// test with non-existent email
- $crawler = self::request('GET', "ucp.php?mode=sendpassword&sid={$this->sid}");
+ $crawler = self::request('GET', "app.php/user/forgot_password?sid={$this->sid}");
$form = $crawler->selectButton('submit')->form(array(
'email' => 'non-existent@email.com',
));
$crawler = self::submit($form);
- $this->assertContainsLang('PASSWORD_UPDATED_IF_EXISTED', $crawler->text());
+ $this->assertContainsLang('PASSWORD_RESET_LINK_SENT', $crawler->text());
// test with correct email
- $crawler = self::request('GET', "ucp.php?mode=sendpassword&sid={$this->sid}");
+ $crawler = self::request('GET', "app.php/user/forgot_password?sid={$this->sid}");
$form = $crawler->selectButton('submit')->form(array(
'email' => 'reset-password-test-user@test.com',
));
$crawler = self::submit($form);
- $this->assertContainsLang('PASSWORD_UPDATED_IF_EXISTED', $crawler->text());
+ $this->assertContainsLang('PASSWORD_RESET_LINK_SENT', $crawler->text());
// Check if columns in database were updated for password reset
$this->get_user_data('reset-password-test-user');
- $this->assertNotNull($this->user_data['user_actkey']);
- $this->assertNotNull($this->user_data['user_newpasswd']);
+ $this->assertNotEmpty($this->user_data['reset_token']);
+ $this->assertNotEmpty($this->user_data['reset_token_expiration']);
+ $reset_token = $this->user_data['reset_token'];
+ $reset_token_expiration = $this->user_data['reset_token_expiration'];
+
+ // Check that reset token is only created once per day
+ $crawler = self::request('GET', "app.php/user/forgot_password?sid={$this->sid}");
+ $form = $crawler->selectButton('submit')->form(array(
+ 'email' => 'reset-password-test-user@test.com',
+ ));
+ $crawler = self::submit($form);
+ $this->assertContainsLang('PASSWORD_RESET_LINK_SENT', $crawler->text());
+
+ $this->get_user_data('reset-password-test-user');
+ $this->assertNotEmpty($this->user_data['reset_token']);
+ $this->assertNotEmpty($this->user_data['reset_token_expiration']);
+ $this->assertEquals($reset_token, $this->user_data['reset_token']);
+ $this->assertEquals($reset_token_expiration, $this->user_data['reset_token_expiration']);
// Create another user with the same email
$this->create_user('reset-password-test-user1', 'reset-password-test-user@test.com');
// Test that username is now also required
- $crawler = self::request('GET', "ucp.php?mode=sendpassword&sid={$this->sid}");
+ $crawler = self::request('GET', "app.php/user/forgot_password?sid={$this->sid}");
$form = $crawler->selectButton('submit')->form(array(
'email' => 'reset-password-test-user@test.com',
));
@@ -67,20 +84,13 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca
'username' => 'reset-password-test-user1',
));
$crawler = self::submit($form);
- $this->assertContainsLang('PASSWORD_UPDATED_IF_EXISTED', $crawler->text());
+ $this->assertContainsLang('PASSWORD_RESET_LINK_SENT', $crawler->text());
// Check if columns in database were updated for password reset
$this->get_user_data('reset-password-test-user1');
- $this->assertNotNull($this->user_data['user_actkey']);
- $this->assertNotNull($this->user_data['user_newpasswd']);
-
- // Make sure we know the password
- $db = $this->get_db();
- $this->passwords_manager = $this->get_passwords_manager();
- $sql = 'UPDATE ' . USERS_TABLE . "
- SET user_newpasswd = '" . $db->sql_escape($this->passwords_manager->hash('reset-password-test-user')) . "'
- WHERE user_id = " . $user_id;
- $db->sql_query($sql);
+ $this->assertNotEmpty($this->user_data['reset_token']);
+ $this->assertNotEmpty($this->user_data['reset_token_expiration']);
+ $this->assertGreaterThan(time(), $this->user_data['reset_token_expiration']);
}
public function test_login_after_reset()
@@ -88,28 +98,45 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca
$this->login('reset-password-test-user');
}
- public function data_activate_new_password()
+ public function data_reset_user_password()
{
- return array(
- array('WRONG_ACTIVATION', false, 'FOOBAR'),
- array('ALREADY_ACTIVATED', 2, 'FOOBAR'),
- array('PASSWORD_ACTIVATED', false, false),
- array('ALREADY_ACTIVATED', false, false),
- );
+ return [
+ ['RESET_TOKEN_EXPIRED_OR_INVALID', 0, 'abcdef'],
+ ['NO_USER', ' ', 'abcdef'],
+ ['NO_RESET_TOKEN', 0, ' '],
+ ['RESET_TOKEN_EXPIRED_OR_INVALID', 2, ''],
+ ['RESET_TOKEN_EXPIRED_OR_INVALID', 1e7, ''],
+ ['', 0, ''],
+ ['NO_RESET_TOKEN', 0, ''], // already reset
+ ];
}
/**
- * @dataProvider data_activate_new_password
- */
- public function test_activate_new_password($expected, $user_id, $act_key)
+ * @dataProvider data_reset_user_password
+ */
+ public function test_reset_user_password($expected, $user_id, $token)
{
$this->add_lang('ucp');
$this->get_user_data('reset-password-test-user');
- $user_id = (!$user_id) ? $this->user_data['user_id'] : $user_id;
- $act_key = (!$act_key) ? $this->user_data['user_actkey'] : $act_key;
+ $user_id = !$user_id ? $this->user_data['user_id'] : $user_id;
+ $token = !$token ? $this->user_data['reset_token'] : $token;
+
+ $crawler = self::request('GET', "app.php/user/reset_password?u=$user_id&token=$token");
- $crawler = self::request('GET', "ucp.php?mode=activate&u=$user_id&k=$act_key&sid={$this->sid}");
- $this->assertContainsLang($expected, $crawler->text());
+ if ($expected)
+ {
+ $this->assertContainsLang($expected, $crawler->text());
+ }
+ else
+ {
+ $form = $crawler->filter('input[type=submit]')->form();
+ $values = array_merge($form->getValues(), [
+ 'new_password' => 'reset-password-test-user',
+ 'new_password_confirm' => 'reset-password-test-user',
+ ]);
+ $crawler = self::submit($form, $values);
+ $this->assertContainsLang('PASSWORD_RESET', $crawler->text());
+ }
}
public function test_login()
@@ -190,7 +217,7 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca
protected function get_user_data($username)
{
$db = $this->get_db();
- $sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_notify_type, user_actkey, user_inactive_reason
+ $sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_notify_type, user_actkey, user_inactive_reason, reset_token, reset_token_expiration
FROM ' . USERS_TABLE . "
WHERE username = '" . $db->sql_escape($username) . "'";
$result = $db->sql_query($sql);
diff --git a/tests/functional/visibility_unapproved_posts_test.php b/tests/functional/visibility_unapproved_posts_test.php
new file mode 100644
index 0000000000..9f6491d1d8
--- /dev/null
+++ b/tests/functional/visibility_unapproved_posts_test.php
@@ -0,0 +1,356 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+/**
+* @group functional
+*/
+class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_case
+{
+ protected $data = [];
+
+ public function test_setup_forums()
+ {
+ $this->login();
+ $this->admin_login();
+
+ $crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}");
+ $form = $crawler->selectButton('addforum')->form([
+ 'forum_name' => 'Unapproved Posts Test #1',
+ ]);
+ $crawler = self::submit($form);
+ $form = $crawler->selectButton('update')->form([
+ 'forum_perm_from' => 2,
+ ]);
+ $crawler = self::submit($form);
+
+ // Set flood interval to 0
+ $this->set_flood_interval(0);
+ }
+
+ public function test_create_posts()
+ {
+ $this->login();
+ $this->load_ids([
+ 'forums' => [
+ 'Unapproved Posts Test #1',
+ ],
+ ]);
+
+ $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], [
+ 'forum_posts_approved' => 0,
+ 'forum_posts_unapproved' => 0,
+ 'forum_posts_softdeleted' => 0,
+ 'forum_topics_approved' => 0,
+ 'forum_topics_unapproved' => 0,
+ 'forum_topics_softdeleted' => 0,
+ 'forum_last_post_id' => 0,
+ ], 'initial comparison');
+
+ // Test creating topic #1
+ $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->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');
+
+ $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], [
+ 'forum_posts_approved' => 1,
+ 'forum_posts_unapproved' => 0,
+ 'forum_posts_softdeleted' => 0,
+ 'forum_topics_approved' => 1,
+ 'forum_topics_unapproved' => 0,
+ 'forum_topics_softdeleted' => 0,
+ 'forum_last_post_id' => $this->data['posts']['Unapproved Posts Test Topic #1'],
+ ], 'after creating topic #1');
+
+ $this->logout();
+ $this->create_user('unapproved_posts_test_user#1');
+ $this->add_user_group('NEWLY_REGISTERED', ['unapproved_posts_test_user#1']);
+ $this->login('unapproved_posts_test_user#1');
+
+ // Test creating a reply
+ $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->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], [
+ 'forum_posts_approved' => 1,
+ 'forum_posts_unapproved' => 1,
+ 'forum_posts_softdeleted' => 0,
+ 'forum_topics_approved' => 1,
+ 'forum_topics_unapproved' => 0,
+ 'forum_topics_softdeleted' => 0,
+ 'forum_last_post_id' => $this->data['posts']['Unapproved Posts Test Topic #1'],
+ ], 'after replying');
+
+ // Test creating topic #2
+ $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->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], [
+ 'forum_posts_approved' => 1,
+ 'forum_posts_unapproved' => 2,
+ 'forum_posts_softdeleted' => 0,
+ 'forum_topics_approved' => 1,
+ 'forum_topics_unapproved' => 1,
+ 'forum_topics_softdeleted' => 0,
+ 'forum_last_post_id' => $this->data['posts']['Unapproved Posts Test Topic #1'],
+ ], 'after creating topic #2');
+
+ $this->logout();
+ }
+
+ public function test_view_unapproved_post_disabled()
+ {
+ // user who created post
+ $this->login('unapproved_posts_test_user#1');
+ $this->load_ids([
+ 'forums' => [
+ 'Unapproved Posts Test #1',
+ ],
+ 'topics' => [
+ 'Unapproved Posts Test Topic #1',
+ 'Unapproved Posts Test Topic #2',
+ ],
+ 'posts' => [
+ 'Unapproved Posts Test Topic #1',
+ 'Re: Unapproved Posts Test Topic #1-#2',
+ 'Unapproved Posts Test Topic #2',
+ ],
+ ]);
+
+ $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], [
+ 'forum_posts_approved' => 1,
+ 'forum_posts_unapproved' => 2,
+ 'forum_posts_softdeleted' => 0,
+ 'forum_topics_approved' => 1,
+ 'forum_topics_unapproved' => 1,
+ 'forum_topics_softdeleted' => 0,
+ 'forum_last_post_id' => $this->data['posts']['Unapproved Posts Test Topic #1'],
+ ], 'before approving post');
+
+ $this->add_lang('posting');
+ $this->add_lang('viewtopic');
+ $this->add_lang('mcp');
+
+ // 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());
+
+ // 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->logout();
+
+ // another user
+ $this->create_user('unapproved_posts_test_user#2');
+ $this->login('unapproved_posts_test_user#2');
+
+ $this->add_lang('posting', 'viewtopic', 'mcp');
+
+ // 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());
+
+ // 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());
+ }
+
+ public function test_view_unapproved_post_enabled()
+ {
+ $this->config_display_unapproved_posts_state(true);
+
+ // user who created post
+ $this->login('unapproved_posts_test_user#1');
+ $this->load_ids([
+ 'forums' => [
+ 'Unapproved Posts Test #1',
+ ],
+ 'topics' => [
+ 'Unapproved Posts Test Topic #1',
+ 'Unapproved Posts Test Topic #2',
+ ],
+ 'posts' => [
+ 'Unapproved Posts Test Topic #1',
+ 'Re: Unapproved Posts Test Topic #1-#2',
+ 'Unapproved Posts Test Topic #2',
+ ],
+ ]);
+
+ $this->assert_forum_details($this->data['forums']['Unapproved Posts Test #1'], [
+ 'forum_posts_approved' => 1,
+ 'forum_posts_unapproved' => 2,
+ 'forum_posts_softdeleted' => 0,
+ 'forum_topics_approved' => 1,
+ 'forum_topics_unapproved' => 1,
+ 'forum_topics_softdeleted' => 0,
+ 'forum_last_post_id' => $this->data['posts']['Unapproved Posts Test Topic #1'],
+ ], 'before approving post');
+
+ $this->add_lang('posting');
+ $this->add_lang('viewtopic');
+ $this->add_lang('mcp');
+
+ // 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());
+
+ // 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());
+
+ // 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->logout();
+
+ // another user
+ $this->login('unapproved_posts_test_user#2');
+
+ $this->add_lang('posting');
+ $this->add_lang('viewtopic');
+ $this->add_lang('mcp');
+
+ // 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());
+
+ // 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->logout();
+ }
+
+ public function test_reset_flood_interval()
+ {
+ $this->login();
+ $this->admin_login();
+
+ // Set flood interval back to 15
+ $this->set_flood_interval(15);
+ }
+
+ protected function assert_forum_details($forum_id, $details, $additional_error_message = '')
+ {
+ $this->db = $this->get_db();
+
+ $sql = 'SELECT ' . implode(', ', array_keys($details)) . '
+ FROM phpbb_forums
+ WHERE forum_id = ' . (int) $forum_id;
+ $result = $this->db->sql_query($sql);
+ $data = $this->db->sql_fetchrow($result);
+ $this->db->sql_freeresult($result);
+
+ $this->assertEquals($details, $data, "Forum {$forum_id} does not match expected {$additional_error_message}");
+ }
+
+ protected function set_flood_interval($flood_interval)
+ {
+ $crawler = self::request('GET', "adm/index.php?sid={$this->sid}&i=acp_board&mode=post");
+
+ $form = $crawler->selectButton('Submit')->form();
+ $values = $form->getValues();
+
+ $values['config[flood_interval]'] = $flood_interval;
+ $form->setValues($values);
+ $crawler = self::submit($form);
+ $this->assertGreaterThan(0, $crawler->filter('.successbox')->count());
+ }
+
+ protected function load_ids($data)
+ {
+ $this->db = $this->get_db();
+
+ if (!empty($data['forums']))
+ {
+ $sql = 'SELECT forum_id, forum_name
+ FROM phpbb_forums
+ WHERE ' . $this->db->sql_in_set('forum_name', $data['forums']);
+ $result = $this->db->sql_query($sql);
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ if (in_array($row['forum_name'], $data['forums']))
+ {
+ $this->data['forums'][$row['forum_name']] = (int) $row['forum_id'];
+ }
+ }
+ $this->db->sql_freeresult($result);
+ }
+
+ if (!empty($data['topics']))
+ {
+ $sql = 'SELECT *
+ FROM phpbb_topics
+ WHERE ' . $this->db->sql_in_set('topic_title', $data['topics']);
+ $result = $this->db->sql_query($sql);
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ if (in_array($row['topic_title'], $data['topics']))
+ {
+ $this->data['topics'][$row['topic_title']] = (int) $row['topic_id'];
+ }
+ }
+ $this->db->sql_freeresult($result);
+ }
+
+ if (!empty($data['posts']))
+ {
+ $sql = 'SELECT *
+ FROM phpbb_posts
+ WHERE ' . $this->db->sql_in_set('post_subject', $data['posts']);
+ $result = $this->db->sql_query($sql);
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ if (in_array($row['post_subject'], $data['posts']))
+ {
+ $this->data['posts'][$row['post_subject']] = (int) $row['post_id'];
+ }
+ }
+ $this->db->sql_freeresult($result);
+ }
+ }
+
+ protected function config_display_unapproved_posts_state($state)
+ {
+ $this->login();
+ $this->admin_login();
+
+ $crawler = self::request('GET', "adm/index.php?sid={$this->sid}&i=acp_board&mode=features");
+
+ $form = $crawler->selectButton('Submit')->form();
+ $values = $form->getValues();
+
+ // Enable display of unapproved posts to posters
+ $values['config[display_unapproved_posts]'] = $state;
+
+ $form->setValues($values);
+
+ $crawler = self::submit($form);
+ self::assertContainsLang('CONFIG_UPDATED', $crawler->filter('.successbox')->text());
+ $this->logout();
+ }
+}
diff --git a/tests/functions/build_url_test.php b/tests/functions/build_url_test.php
index 91a4a9ec66..1519549d3e 100644
--- a/tests/functions/build_url_test.php
+++ b/tests/functions/build_url_test.php
@@ -13,7 +13,7 @@
class phpbb_build_url_test extends phpbb_test_case
{
- protected function setUp()
+ protected function setUp(): void
{
global $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpbb_path_helper;
@@ -28,7 +28,7 @@ class phpbb_build_url_test extends phpbb_test_case
new phpbb_mock_request()
),
new \phpbb\filesystem\filesystem(),
- $this->getMock('\phpbb\request\request'),
+ $this->createMock('\phpbb\request\request'),
$phpbb_root_path,
'php'
);
diff --git a/tests/functions/convert_30_dbms_to_31_test.php b/tests/functions/convert_30_dbms_to_31_test.php
index 456eb64461..05c42610bb 100644
--- a/tests/functions/convert_30_dbms_to_31_test.php
+++ b/tests/functions/convert_30_dbms_to_31_test.php
@@ -18,7 +18,6 @@ class phpbb_convert_30_dbms_to_31_test extends phpbb_test_case
return array(
array('mssql_odbc'),
array('mssqlnative'),
- array('mysql'),
array('mysqli'),
array('oracle'),
array('postgres'),
diff --git a/tests/functions/fixtures/validate_email.xml b/tests/functions/fixtures/validate_email.xml
index fa139f6f18..985050cedc 100644
--- a/tests/functions/fixtures/validate_email.xml
+++ b/tests/functions/fixtures/validate_email.xml
@@ -30,14 +30,14 @@
<column>username_clean</column>
<column>user_permissions</column>
<column>user_sig</column>
- <column>user_email_hash</column>
+ <column>user_email</column>
<row>
<value>1</value>
<value>admin</value>
<value>admin</value>
<value></value>
<value></value>
- <value>143317126117</value>
+ <value>admin@example.com</value>
</row>
</table>
</dataset>
diff --git a/tests/functions/generate_string_list.php b/tests/functions/generate_string_list.php
index 6eddb1395e..0f9975bcac 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()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/functions/get_remote_file_test.php b/tests/functions/get_remote_file_test.php
index 75e5a6dc61..b783e3c297 100644
--- a/tests/functions/get_remote_file_test.php
+++ b/tests/functions/get_remote_file_test.php
@@ -24,7 +24,7 @@ class phpbb_functions_get_remote_file extends phpbb_test_case
$hostname = 'version.phpbb.com';
- if (!phpbb_checkdnsrr($hostname, 'A'))
+ if (!checkdnsrr($hostname, 'A'))
{
$this->markTestSkipped(sprintf(
'Could not find a DNS record for hostname %s. ' .
diff --git a/tests/functions/make_clickable_email_test.php b/tests/functions/make_clickable_email_test.php
index d481bde80d..18ad789705 100644
--- a/tests/functions/make_clickable_email_test.php
+++ b/tests/functions/make_clickable_email_test.php
@@ -13,7 +13,7 @@
class phpbb_functions_make_clickable_email_test extends phpbb_test_case
{
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/tests/functions/make_clickable_test.php b/tests/functions/make_clickable_test.php
index a6af12b624..d8d5eb5e0e 100644
--- a/tests/functions/make_clickable_test.php
+++ b/tests/functions/make_clickable_test.php
@@ -154,7 +154,7 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case
);
}
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/tests/functions/obtain_online_test.php b/tests/functions/obtain_online_test.php
index 778753e5d2..e6929b1549 100644
--- a/tests/functions/obtain_online_test.php
+++ b/tests/functions/obtain_online_test.php
@@ -18,7 +18,7 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/obtain_online.xml');
}
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
@@ -161,8 +161,9 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case
global $config, $user, $auth, $phpbb_dispatcher;
$config['load_online_guests'] = $display_guests;
$user = new phpbb_mock_lang();
+ $user->data['user_id'] = 100;
$user->lang = $this->load_language();
- $auth = $this->getMock('\phpbb\auth\auth');
+ $auth = $this->createMock('\phpbb\auth\auth');
$acl_get_map = array(
array('u_viewonline', true),
array('u_viewprofile', true),
diff --git a/tests/functions/phpbb_get_banned_user_ids.php b/tests/functions/phpbb_get_banned_user_ids.php
index 6f7607132e..e1cb7a4636 100644
--- a/tests/functions/phpbb_get_banned_user_ids.php
+++ b/tests/functions/phpbb_get_banned_user_ids.php
@@ -43,13 +43,13 @@ class phpbb_get_banned_user_ids_test extends phpbb_database_test_case
);
}
- public function setUp()
+ public function setUp(): void
{
global $db;
$db = $this->new_dbal();
- return parent::setUp();
+ parent::setUp();
}
/**
diff --git a/tests/functions/user_delete_test.php b/tests/functions/user_delete_test.php
index f419c90e9e..f4ea5696b9 100644
--- a/tests/functions/user_delete_test.php
+++ b/tests/functions/user_delete_test.php
@@ -23,7 +23,7 @@ class phpbb_functions_user_delete_test extends phpbb_database_test_case
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/user_delete.xml');
}
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
@@ -60,21 +60,43 @@ class phpbb_functions_user_delete_test extends phpbb_database_test_case
// Set up passwords manager
$passwords_manager = new \phpbb\passwords\manager($config, $passwords_drivers, $passwords_helper, array_keys($passwords_drivers));
- $oauth_provider = new \phpbb\auth\provider\oauth\oauth(
- $db,
+ $plugins = new \phpbb\di\service_collection($phpbb_container);
+ $plugins->add('core.captcha.plugins.nogd');
+ $phpbb_container->set(
+ 'captcha.factory',
+ new \phpbb\captcha\factory($phpbb_container, $plugins)
+ );
+ $phpbb_container->set(
+ 'core.captcha.plugins.nogd',
+ new \phpbb\captcha\plugins\nogd()
+ );
+ // Set up passwords manager
+ $db_auth_provider = new \phpbb\auth\provider\db(
+ new \phpbb\captcha\factory($phpbb_container, $plugins),
$config,
+ $db,
$passwords_manager,
$request,
$user,
+ $phpbb_root_path,
+ $phpEx
+ );
+
+ $oauth_provider = new \phpbb\auth\provider\oauth\oauth(
+ $config,
+ $db,
+ $db_auth_provider,
+ $phpbb_dispatcher,
+ $lang,
+ $request,
+ $oauth_provider_collection,
+ $user,
'phpbb_oauth_tokens',
'phpbb_oauth_states',
'phpbb_oauth_accounts',
- $oauth_provider_collection,
'phpbb_users',
- $phpbb_container,
- $phpbb_dispatcher,
- $this->phpbb_root_path,
- $this->php_ext
+ $phpbb_root_path,
+ $phpEx
);
$provider_collection->offsetSet('auth.provider.oauth', $oauth_provider);
diff --git a/tests/functions/validate_date_test.php b/tests/functions/validate_date_test.php
index 9dc0db46d6..cd4e7430f3 100644
--- a/tests/functions/validate_date_test.php
+++ b/tests/functions/validate_date_test.php
@@ -18,7 +18,7 @@ class phpbb_functions_validate_date_test extends phpbb_test_case
{
protected $helper;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/tests/functions/validate_email_test.php b/tests/functions/validate_email_test.php
index 7f8b2679d4..e163d01412 100644
--- a/tests/functions/validate_email_test.php
+++ b/tests/functions/validate_email_test.php
@@ -22,7 +22,7 @@ class phpbb_functions_validate_email_test extends phpbb_database_test_case
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/validate_email.xml');
}
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/tests/functions/validate_jabber_test.php b/tests/functions/validate_jabber_test.php
index 23811a94c0..dbdf10cb4a 100644
--- a/tests/functions/validate_jabber_test.php
+++ b/tests/functions/validate_jabber_test.php
@@ -18,7 +18,7 @@ class phpbb_functions_validate_jabber_test extends phpbb_test_case
{
protected $helper;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
@@ -32,7 +32,7 @@ class phpbb_functions_validate_jabber_test extends phpbb_test_case
array(),
'',
array('jabber'),
- ),
+ ),
'no_seperator' => array(
array('WRONG_DATA'),
'testjabber.ccc',
diff --git a/tests/functions/validate_lang_iso_test.php b/tests/functions/validate_lang_iso_test.php
index 81b56055e6..cbe5339ea5 100644
--- a/tests/functions/validate_lang_iso_test.php
+++ b/tests/functions/validate_lang_iso_test.php
@@ -24,7 +24,7 @@ class phpbb_functions_validate_lang_iso_test extends phpbb_database_test_case
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/language_select.xml');
}
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/tests/functions/validate_match_test.php b/tests/functions/validate_match_test.php
index 811bed3e33..7159686066 100644
--- a/tests/functions/validate_match_test.php
+++ b/tests/functions/validate_match_test.php
@@ -18,7 +18,7 @@ class phpbb_functions_validate_match_test extends phpbb_test_case
{
protected $helper;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/tests/functions/validate_num_test.php b/tests/functions/validate_num_test.php
index 798468759c..acbdc49614 100644
--- a/tests/functions/validate_num_test.php
+++ b/tests/functions/validate_num_test.php
@@ -18,7 +18,7 @@ class phpbb_functions_validate_num_test extends phpbb_test_case
{
protected $helper;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/tests/functions/validate_password_test.php b/tests/functions/validate_password_test.php
index 5e34c8baba..6e4ccea3ab 100644
--- a/tests/functions/validate_password_test.php
+++ b/tests/functions/validate_password_test.php
@@ -18,7 +18,7 @@ class phpbb_functions_validate_password_test extends phpbb_test_case
{
protected $helper;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/tests/functions/validate_string_test.php b/tests/functions/validate_string_test.php
index 7aca14c334..83ba546152 100644
--- a/tests/functions/validate_string_test.php
+++ b/tests/functions/validate_string_test.php
@@ -18,7 +18,7 @@ class phpbb_functions_validate_string_test extends phpbb_test_case
{
protected $helper;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/tests/functions/validate_user_email_test.php b/tests/functions/validate_user_email_test.php
index d23ffc0503..eeb5bfc2a9 100644
--- a/tests/functions/validate_user_email_test.php
+++ b/tests/functions/validate_user_email_test.php
@@ -26,7 +26,7 @@ class phpbb_functions_validate_user_email_test extends phpbb_database_test_case
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/validate_email.xml');
}
- protected function setUp()
+ protected function setUp(): void
{
global $cache, $phpbb_dispatcher, $phpbb_root_path, $phpEx;
diff --git a/tests/functions/validate_username_test.php b/tests/functions/validate_username_test.php
index cee5d38400..31837f015b 100644
--- a/tests/functions/validate_username_test.php
+++ b/tests/functions/validate_username_test.php
@@ -26,7 +26,7 @@ class phpbb_functions_validate_data_test extends phpbb_database_test_case
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/validate_username.xml');
}
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
@@ -130,11 +130,13 @@ class phpbb_functions_validate_data_test extends phpbb_database_test_case
*/
public function test_validate_username($allow_name_chars, $expected)
{
- global $cache, $config, $db;
+ global $cache, $config, $db, $user;
$db = $this->db;
$cache = $this->cache;
$cache->put('_disallowed_usernames', array('barfoo'));
+ $user = new phpbb_mock_user();
+ $user->data['username_clean'] = 'username';
$config['allow_name_chars'] = $allow_name_chars;
diff --git a/tests/functions/validate_with_method_test.php b/tests/functions/validate_with_method_test.php
index 37e05d412a..1cd610fd2f 100644
--- a/tests/functions/validate_with_method_test.php
+++ b/tests/functions/validate_with_method_test.php
@@ -18,7 +18,7 @@ class phpbb_functions_validate_with_method_test extends phpbb_test_case
{
protected $helper;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/tests/functions_acp/build_select_test.php b/tests/functions_acp/build_select_test.php
index ebdc58fd64..9a295762c3 100644
--- a/tests/functions_acp/build_select_test.php
+++ b/tests/functions_acp/build_select_test.php
@@ -15,7 +15,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php';
class phpbb_functions_acp_built_select_test extends phpbb_test_case
{
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/tests/functions_acp/h_radio_test.php b/tests/functions_acp/h_radio_test.php
index 5ae4e91ea2..cc9d837357 100644
--- a/tests/functions_acp/h_radio_test.php
+++ b/tests/functions_acp/h_radio_test.php
@@ -15,7 +15,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php';
class phpbb_functions_acp_h_radio_test extends phpbb_test_case
{
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/tests/functions_acp/validate_config_vars_test.php b/tests/functions_acp/validate_config_vars_test.php
index 3bd2204de9..0198f28a39 100644
--- a/tests/functions_acp/validate_config_vars_test.php
+++ b/tests/functions_acp/validate_config_vars_test.php
@@ -15,7 +15,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php';
class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case
{
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/tests/functions_acp/validate_range_test.php b/tests/functions_acp/validate_range_test.php
index 9e9154a43c..085787105f 100644
--- a/tests/functions_acp/validate_range_test.php
+++ b/tests/functions_acp/validate_range_test.php
@@ -15,7 +15,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php';
class phpbb_functions_acp_validate_range_test extends phpbb_test_case
{
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/tests/functions_content/get_username_string_test.php b/tests/functions_content/get_username_string_test.php
index e79342d05d..ac36e37e93 100644
--- a/tests/functions_content/get_username_string_test.php
+++ b/tests/functions_content/get_username_string_test.php
@@ -18,7 +18,7 @@ class phpbb_functions_content_get_username_string_test extends phpbb_test_case
parent::setUp();
global $auth, $phpbb_dispatcher, $user;
- $auth = $this->getMock('\phpbb\auth\auth');
+ $auth = $this->createMock('\phpbb\auth\auth');
$auth->expects($this->any())
->method('acl_get')
->with($this->stringContains('_'), $this->anything())
diff --git a/tests/functions_content/phpbb_format_quote_test.php b/tests/functions_content/phpbb_format_quote_test.php
index cbbd46d0a9..52a792517a 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()
+ public function setUp(): void
{
global $cache, $user, $phpbb_root_path, $phpEx;
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 fbabf1222a..b96f490c88 100644
--- a/tests/functions_privmsgs/get_max_setting_from_group_test.php
+++ b/tests/functions_privmsgs/get_max_setting_from_group_test.php
@@ -23,7 +23,7 @@ class phpbb_functions_privmsgs_get_max_setting_from_group_test extends phpbb_dat
/** @var \phpbb\db\driver\driver_interface */
protected $db;
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/tests/functions_user/delete_user_test.php b/tests/functions_user/delete_user_test.php
index 09ed51890c..4a82a0eeb7 100644
--- a/tests/functions_user/delete_user_test.php
+++ b/tests/functions_user/delete_user_test.php
@@ -19,13 +19,18 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/delete_user.xml');
}
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
- global $cache, $config, $db, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path;
+ global $cache, $config, $db, $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpEx;
$db = $this->db = $this->new_dbal();
+
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $lang = new \phpbb\language\language($lang_loader);
+ $user = new \phpbb\user($lang, '\phpbb\datetime');
+
$config = new \phpbb\config\config(array(
'load_online_time' => 5,
'search_type' => '\phpbb\search\fulltext_mysql',
@@ -59,16 +64,16 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case
array(
'retain', false,
array(
- array('post_id' => 1, 'poster_id' => ANONYMOUS, 'post_username' => ''),
+ array('post_id' => 1, 'poster_id' => ANONYMOUS, 'post_username' => 'Guest'),
array('post_id' => 2, 'poster_id' => ANONYMOUS, 'post_username' => 'Other'),
- array('post_id' => 3, 'poster_id' => ANONYMOUS, 'post_username' => ''),
+ array('post_id' => 3, 'poster_id' => ANONYMOUS, 'post_username' => 'Guest'),
array('post_id' => 4, 'poster_id' => ANONYMOUS, 'post_username' => 'Other'),
),
array(
array(
'topic_id' => 1,
- 'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => '', 'topic_first_poster_colour' => '',
- 'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => '', 'topic_last_poster_colour' => '',
+ 'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => 'Guest', 'topic_first_poster_colour' => '',
+ 'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => 'Guest', 'topic_last_poster_colour' => '',
),
array(
'topic_id' => 2,
@@ -77,8 +82,8 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case
),
array(
'topic_id' => 3,
- 'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => '', 'topic_first_poster_colour' => '',
- 'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => '', 'topic_last_poster_colour' => '',
+ 'topic_poster' => ANONYMOUS, 'topic_first_poster_name' => 'Guest', 'topic_first_poster_colour' => '',
+ 'topic_last_poster_id' => ANONYMOUS, 'topic_last_poster_name' => 'Guest', 'topic_last_poster_colour' => '',
),
array(
'topic_id' => 4,
@@ -87,9 +92,9 @@ class phpbb_functions_user_delete_user_test extends phpbb_database_test_case
),
),
array(
- array('forum_id' => 1, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => '', 'forum_last_poster_colour' => ''),
+ array('forum_id' => 1, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Guest', 'forum_last_poster_colour' => ''),
array('forum_id' => 2, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Other', 'forum_last_poster_colour' => ''),
- array('forum_id' => 3, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => '', 'forum_last_poster_colour' => ''),
+ array('forum_id' => 3, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Guest', 'forum_last_poster_colour' => ''),
array('forum_id' => 4, 'forum_last_poster_id' => ANONYMOUS, 'forum_last_poster_name' => 'Other', 'forum_last_poster_colour' => ''),
),
),
diff --git a/tests/functions_user/group_user_attributes_test.php b/tests/functions_user/group_user_attributes_test.php
index 3124d57ba0..dd86d23b34 100644
--- a/tests/functions_user/group_user_attributes_test.php
+++ b/tests/functions_user/group_user_attributes_test.php
@@ -131,14 +131,15 @@ class phpbb_functions_user_group_user_attributes_test extends phpbb_database_tes
$user = new phpbb_mock_user;
$user->ip = '';
+ $user->data['user_id'] = $user_id;
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
- $auth = $this->getMock('\phpbb\auth\auth');
+ $auth = $this->createMock('\phpbb\auth\auth');
$auth->expects($this->any())
->method('acl_clear_prefetch');
$cache_driver = new \phpbb\cache\driver\dummy();
- $phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $phpbb_container = $this->createMock('Symfony\Component\DependencyInjection\ContainerInterface');
$phpbb_container
->expects($this->any())
->method('get')
diff --git a/tests/group/helper_test_case.php b/tests/group/helper_test_case.php
index e298770331..099887bcb0 100644
--- a/tests/group/helper_test_case.php
+++ b/tests/group/helper_test_case.php
@@ -59,7 +59,7 @@ class phpbb_group_helper_test_case extends phpbb_test_case
global $phpbb_dispatcher, $phpbb_root_path, $phpEx;
// Set up authentication data for testing
- $auth = $this->getMock('\phpbb\auth\auth');
+ $auth = $this->getMockBuilder('\phpbb\auth\auth')->disableOriginalConstructor()->getMock();
$auth->expects($this->any())
->method('acl_get')
->with($this->stringContains('_'), $this->anything())
diff --git a/tests/groupposition/legend_test.php b/tests/groupposition/legend_test.php
index 02ddb7cbce..66fc909770 100644
--- a/tests/groupposition/legend_test.php
+++ b/tests/groupposition/legend_test.php
@@ -43,7 +43,7 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case
if ($throws_exception)
{
- $this->setExpectedException($throws_exception);
+ $this->expectException($throws_exception);
}
$test_class = new \phpbb\groupposition\legend($db, $user);
diff --git a/tests/groupposition/teampage_test.php b/tests/groupposition/teampage_test.php
index 3b916670f7..8598e5cfb0 100644
--- a/tests/groupposition/teampage_test.php
+++ b/tests/groupposition/teampage_test.php
@@ -43,7 +43,7 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case
if ($throws_exception)
{
- $this->setExpectedException($throws_exception);
+ $this->expectException($throws_exception);
}
$test_class = new \phpbb\groupposition\teampage($db, $user, $cache);
diff --git a/tests/help/manager_test.php b/tests/help/manager_test.php
index 68534d9a32..118a38ad3e 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()
+ public 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 ed355884f6..9ffdad3e03 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()
+ public 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 13ac325a79..6fa8248b68 100644
--- a/tests/installer/installer_config_test.php
+++ b/tests/installer/installer_config_test.php
@@ -20,11 +20,12 @@ class phpbb_installer_config_test extends phpbb_test_case
*/
private $config;
- public function setUp()
+ public function setUp(): void
{
$phpbb_root_path = __DIR__ . './../../phpBB/';
- $filesystem = $this->getMock('\phpbb\filesystem\filesystem');
+ $filesystem = $this->createMock('\phpbb\filesystem\filesystem');
$php_ini = $this->getMockBuilder('\bantu\IniGetWrapper\IniGetWrapper')
+ ->setMethods(array('getInt', 'getBytes'))
->getMock();
$php_ini->method('getInt')
->willReturn(-1);
diff --git a/tests/installer/module_base_test.php b/tests/installer/module_base_test.php
index 9578010047..887d29f4c6 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()
+ public function setUp(): void
{
// DI container mock
$this->container = new phpbb_mock_container_builder();
@@ -42,7 +42,7 @@ class module_base_test extends phpbb_test_case
$this->module = new test_installer_module($module_collection, true, false);
- $iohandler = $this->getMock('\phpbb\install\helper\iohandler\iohandler_interface');
+ $iohandler = $this->createMock('\phpbb\install\helper\iohandler\iohandler_interface');
$config = new \phpbb\install\helper\config(new \phpbb\filesystem\filesystem(), new \bantu\IniGetWrapper\IniGetWrapper(), '', 'php');
$this->module->setup($config, $iohandler);
}
diff --git a/tests/language/language_test.php b/tests/language/language_test.php
index 29b4873dcb..8b822472cd 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()
+ public function setUp(): void
{
global $phpbb_root_path, $phpEx;
diff --git a/tests/lint_test.php b/tests/lint_test.php
index 8ab31f976c..8356389acf 100644
--- a/tests/lint_test.php
+++ b/tests/lint_test.php
@@ -45,11 +45,6 @@ class phpbb_lint_test extends phpbb_test_case
*/
public function test_lint($path)
{
- if (version_compare(PHP_VERSION, '5.3.0', '<'))
- {
- $this->markTestSkipped('phpBB uses PHP 5.3 syntax in some files, linting on PHP < 5.3 will fail');
- }
-
$cmd = sprintf('(%s -l %s) 2>&1', self::$php_binary, escapeshellarg($path));
$output = array();
$status = 1;
diff --git a/tests/lock/db_test.php b/tests/lock/db_test.php
index 5fbfa26554..e96920ed1f 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()
+ public function setUp(): void
{
global $db, $config;
diff --git a/tests/log/add_test.php b/tests/log/add_test.php
index 604c8364dc..469d4ebd69 100644
--- a/tests/log/add_test.php
+++ b/tests/log/add_test.php
@@ -28,7 +28,7 @@ class phpbb_log_add_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');
- $auth = $this->getMock('\phpbb\auth\auth');
+ $auth = $this->createMock('\phpbb\auth\auth');
$log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
@@ -59,7 +59,7 @@ class phpbb_log_add_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');
- $auth = $this->getMock('\phpbb\auth\auth');
+ $auth = $this->createMock('\phpbb\auth\auth');
$log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
diff --git a/tests/log/delete_test.php b/tests/log/delete_test.php
index e8b75d01d9..fd8a2cb3df 100644
--- a/tests/log/delete_test.php
+++ b/tests/log/delete_test.php
@@ -20,9 +20,9 @@ class phpbb_log_delete_test extends phpbb_database_test_case
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/delete_log.xml');
}
- protected function setUp()
+ protected function setUp(): void
{
- global $phpbb_root_path, $phpEx, $db, $phpbb_dispatcher, $auth;
+ global $phpbb_root_path, $phpEx, $db, $phpbb_dispatcher, $auth, $user;
$db = $this->new_dbal();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
@@ -30,7 +30,7 @@ class phpbb_log_delete_test extends phpbb_database_test_case
$lang = new \phpbb\language\language($lang_loader);
$user = new \phpbb\user($lang, '\phpbb\datetime');
$user->data['user_id'] = 1;
- $auth = $this->getMock('\phpbb\auth\auth');
+ $auth = $this->createMock('\phpbb\auth\auth');
$this->log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
diff --git a/tests/log/function_add_log_test.php b/tests/log/function_add_log_test.php
index 3b5537fc13..c3f1a0beba 100644
--- a/tests/log/function_add_log_test.php
+++ b/tests/log/function_add_log_test.php
@@ -159,11 +159,11 @@ class phpbb_log_function_add_log_test extends phpbb_database_test_case
$db = $this->new_dbal();
$cache = new phpbb_mock_cache;
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
- $user = $this->getMock('\phpbb\user', array(), array(
+ $user = $this->createMock('\phpbb\user', array(), array(
new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
'\phpbb\datetime'
));
- $auth = $this->getMock('\phpbb\auth\auth');
+ $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/log/function_view_log_test.php b/tests/log/function_view_log_test.php
index ee9c3e5893..edab371769 100644
--- a/tests/log/function_view_log_test.php
+++ b/tests/log/function_view_log_test.php
@@ -274,7 +274,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
// Offset that will be returned from the function
'expected_returned' => 0,
// view_log parameters (see includes/functions_admin.php for docblock)
- // $log is ommited!
+ // $log is omitted!
'mod', 5, 0, 12, 45,
),
*/
@@ -378,7 +378,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
// Create auth mock
- $auth = $this->getMock('\phpbb\auth\auth');
+ $auth = $this->createMock('\phpbb\auth\auth');
$acl_get_map = array(
array('f_read', 23, true),
array('m_', 23, true),
@@ -411,6 +411,8 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
2 => 'plural (%d)',
),
);
+ $user->session_id = false;
+ $user->data['user_id'] = 10;
$phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
diff --git a/tests/mcp/post_ip_test.php b/tests/mcp/post_ip_test.php
index 72a9f62774..f53066c9e6 100644
--- a/tests/mcp/post_ip_test.php
+++ b/tests/mcp/post_ip_test.php
@@ -23,7 +23,7 @@ class phpbb_mcp_post_ip_test extends phpbb_database_test_case
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/post_ip.xml');
}
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/tests/migrator/convert_timezones_test.php b/tests/migrator/convert_timezones_test.php
index f8d780da0c..4bb0aec34f 100644
--- a/tests/migrator/convert_timezones_test.php
+++ b/tests/migrator/convert_timezones_test.php
@@ -49,7 +49,7 @@ class phpbb_migrator_convert_timezones_test extends phpbb_database_test_case
);
}
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/tests/migrator/get_callable_from_step_test.php b/tests/migrator/get_callable_from_step_test.php
index af636f5d21..b0abb6199c 100644
--- a/tests/migrator/get_callable_from_step_test.php
+++ b/tests/migrator/get_callable_from_step_test.php
@@ -13,9 +13,9 @@
class get_callable_from_step_test extends phpbb_database_test_case
{
- public function setUp()
+ public function setUp(): void
{
- global $phpbb_root_path, $php_ext, $table_prefix, $phpbb_log;
+ global $phpbb_root_path, $php_ext, $table_prefix, $phpbb_log, $user;
parent::setUp();
@@ -24,6 +24,7 @@ class get_callable_from_step_test extends phpbb_database_test_case
$factory = new \phpbb\db\tools\factory();
$cache_service = $this->getMockBuilder('\phpbb\cache\service')->disableOriginalConstructor()->getMock();
$user = $this->getMockBuilder('\phpbb\user')->disableOriginalConstructor()->getMock();
+ $user->ip = '127.0.0.1';
$module_manager = new \phpbb\module\module_manager(
$this->getMockBuilder('\phpbb\cache\driver\dummy')->disableOriginalConstructor()->getMock(),
$db,
diff --git a/tests/migrator/get_schema_steps_test.php b/tests/migrator/get_schema_steps_test.php
index 3d15d2b200..10accb3d68 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()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/migrator/reverse_update_data_test.php b/tests/migrator/reverse_update_data_test.php
index b85e48c64c..b93680c2e2 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()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/migrator/schema_generator_test.php b/tests/migrator/schema_generator_test.php
index 1996d207ea..1349b98953 100644
--- a/tests/migrator/schema_generator_test.php
+++ b/tests/migrator/schema_generator_test.php
@@ -24,8 +24,10 @@ class schema_generator_test extends phpbb_test_case
/** @var \phpbb\db\migration\schema_generator */
protected $generator;
- public function setUp()
+ public function setUp(): void
{
+ global $phpbb_root_path, $phpEx;
+
parent::setUp();
$this->config = new \phpbb\config\config(array());
@@ -33,6 +35,8 @@ class schema_generator_test extends phpbb_test_case
$factory = new \phpbb\db\tools\factory();
$this->db_tools = $factory->get($this->db);
$this->table_prefix = 'phpbb_';
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->php_ext = $phpEx;
}
protected function get_schema_generator(array $class_names)
diff --git a/tests/mimetype/guesser_test.php b/tests/mimetype/guesser_test.php
index fa53e6c8c4..238e7ae2d6 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()
+ public function setUp(): void
{
global $phpbb_root_path;
@@ -181,7 +181,7 @@ class guesser_test extends \phpbb_test_case
if (!$supported)
{
- $this->setExpectedException('\LogicException');
+ $this->expectException('\LogicException');
}
$guesser = new \phpbb\mimetype\guesser($guessers);
diff --git a/tests/mock/cache.php b/tests/mock/cache.php
index 5fa3d28147..2306fd9009 100644
--- a/tests/mock/cache.php
+++ b/tests/mock/cache.php
@@ -72,13 +72,13 @@ class phpbb_mock_cache implements \phpbb\cache\driver\driver_interface
}
}
- public function checkVar(PHPUnit_Framework_Assert $test, $var_name, $data)
+ public function checkVar(PHPUnit\Framework\Assert $test, $var_name, $data)
{
$test->assertTrue(isset($this->data[$var_name]));
$test->assertEquals($data, $this->data[$var_name]);
}
- public function checkAssociativeVar(PHPUnit_Framework_Assert $test, $var_name, $data, $sort = true)
+ public function checkAssociativeVar(PHPUnit\Framework\Assert $test, $var_name, $data, $sort = true)
{
$test->assertTrue(isset($this->data[$var_name]));
@@ -93,12 +93,12 @@ class phpbb_mock_cache implements \phpbb\cache\driver\driver_interface
$test->assertEquals($data, $this->data[$var_name]);
}
- public function checkVarUnset(PHPUnit_Framework_Assert $test, $var_name)
+ public function checkVarUnset(PHPUnit\Framework\Assert $test, $var_name)
{
$test->assertFalse(isset($this->data[$var_name]));
}
- public function check(PHPUnit_Framework_Assert $test, $data, $ignore_db_info = true)
+ public function check(PHPUnit\Framework\Assert $test, $data, $ignore_db_info = true)
{
$cache_data = $this->data;
diff --git a/tests/mock/container_builder.php b/tests/mock/container_builder.php
index 134589b0b8..17c4ae22dd 100644
--- a/tests/mock/container_builder.php
+++ b/tests/mock/container_builder.php
@@ -18,16 +18,22 @@ class phpbb_mock_container_builder implements ContainerInterface
protected $services = array();
protected $parameters = array();
+ public function __construct()
+ {
+ $this->setParameter('debug.load_time', false);
+ $this->setParameter('session.log_errors', false);
+ }
+
/**
* Sets a service.
*
* @param string $id The service identifier
* @param object $service The service instance
- * @param string $scope The scope of the service
+ * @param bool $shared Whether service is shared
*
* @api
*/
- public function set($id, $service, $scope = self::SCOPE_CONTAINER)
+ public function set($id, $service, $shared = false)
{
$this->services[$id] = $service;
}
@@ -193,4 +199,9 @@ class phpbb_mock_container_builder implements ContainerInterface
{
return false;
}
+
+ public function initialized($id)
+ {
+ return true;
+ }
}
diff --git a/tests/mock/session_testable.php b/tests/mock/session_testable.php
index 2f24978ba8..7828a864d4 100644
--- a/tests/mock/session_testable.php
+++ b/tests/mock/session_testable.php
@@ -30,14 +30,14 @@ class phpbb_mock_session_testable extends \phpbb\session
/**
* Checks if the cookies were set correctly.
*
- * @param PHPUnit_Framework_Assert test The test from which this is called
+ * @param PHPUnit\Framework\Assert test The test from which this is called
* @param array(string => mixed) cookies The cookie data to check against.
* The keys are cookie names, the values can either be null to
- * check only the existance of the cookie, or an array(d, t),
+ * check only the existence of the cookie, or an array(d, t),
* where d is the cookie data to check, or null to skip the
* check and t is the cookie time to check, or null to skip.
*/
- public function check_cookies(PHPUnit_Framework_Assert $test, $cookies)
+ public function check_cookies(PHPUnit\Framework\Assert $test, $cookies)
{
$test->assertEquals(array_keys($cookies), array_keys($this->_cookies), 'Incorrect cookies were set');
diff --git a/tests/network/checkdnsrr_test.php b/tests/network/checkdnsrr_test.php
deleted file mode 100644
index 8cbd4f7e97..0000000000
--- a/tests/network/checkdnsrr_test.php
+++ /dev/null
@@ -1,67 +0,0 @@
-<?php
-/**
-*
-* This file is part of the phpBB Forum Software package.
-*
-* @copyright (c) phpBB Limited <https://www.phpbb.com>
-* @license GNU General Public License, version 2 (GPL-2.0)
-*
-* For full copyright and license information, please see
-* the docs/CREDITS.txt file.
-*
-*/
-
-/**
-* @group slow
-*/
-class phpbb_network_checkdnsrr_test extends phpbb_test_case
-{
- public function data_provider()
- {
- return array(
- // Existing MX record
- array('phpbb.com', 'MX', true),
-
- // Non-existing MX record
- array('does-not-exist.phpbb.com', 'MX', false),
-
- // Existing A record
- array('www.phpbb.com', 'A', true),
-
- // Non-existing A record
- array('does-not-exist.phpbb.com', 'A', false),
-
- // Existing AAAA record
- array('www.six.heise.de', 'AAAA', true),
-
- // Non-existing AAAA record
- array('does-not-exist.phpbb.com', 'AAAA', false),
-
- // Existing CNAME record
- array('area51.phpbb.com', 'CNAME', true),
-
- // Non-existing CNAME record
- array('does-not-exist.phpbb.com', 'CNAME', false),
-
- // Existing NS record
- array('phpbb.com', 'NS', true),
-
- // Non-existing NS record
- array('does-not-exist', 'NS', false),
-
- // Existing TXT record
- array('phpbb.com', 'TXT', true),
-
- // Non-existing TXT record
- array('does-not-exist', 'TXT', false),
- );
- }
-
- /**
- * @dataProvider data_provider
- */
- public function test_checkdnsrr($host, $type, $expected)
- {
- $this->assertEquals($expected, phpbb_checkdnsrr($host, $type));
- }
-}
diff --git a/tests/network/inet_ntop_pton_test.php b/tests/network/inet_ntop_pton_test.php
deleted file mode 100644
index dbd58ce783..0000000000
--- a/tests/network/inet_ntop_pton_test.php
+++ /dev/null
@@ -1,56 +0,0 @@
-<?php
-/**
-*
-* This file is part of the phpBB Forum Software package.
-*
-* @copyright (c) phpBB Limited <https://www.phpbb.com>
-* @license GNU General Public License, version 2 (GPL-2.0)
-*
-* For full copyright and license information, please see
-* the docs/CREDITS.txt file.
-*
-*/
-
-class phpbb_network_inet_ntop_pton_test extends phpbb_test_case
-{
- public function data_provider()
- {
- return array(
- array('127.0.0.1', '7f000001'),
- array('192.232.131.223', 'c0e883df'),
- array('13.1.68.3', '0d014403'),
- array('129.144.52.38', '81903426'),
-
- array('2001:280:0:10::5', '20010280000000100000000000000005'),
- array('fe80::200:4cff:fefe:172f', 'fe8000000000000002004cfffefe172f'),
-
- array('::', '00000000000000000000000000000000'),
- array('::1', '00000000000000000000000000000001'),
- array('1::', '00010000000000000000000000000000'),
-
- array('1:1:0:0:1::', '00010001000000000001000000000000'),
-
- array('0:2:3:4:5:6:7:8', '00000002000300040005000600070008'),
- array('1:2:0:4:5:6:7:8', '00010002000000040005000600070008'),
- array('1:2:3:4:5:6:7:0', '00010002000300040005000600070000'),
-
- array('2001:0:0:1::1', '20010000000000010000000000000001'),
- );
- }
-
- /**
- * @dataProvider data_provider
- */
- public function test_inet_ntop($address, $hex)
- {
- $this->assertEquals($address, phpbb_inet_ntop(pack('H*', $hex)));
- }
-
- /**
- * @dataProvider data_provider
- */
- public function test_inet_pton($address, $hex)
- {
- $this->assertEquals($hex, bin2hex(phpbb_inet_pton($address)));
- }
-}
diff --git a/tests/notification/base.php b/tests/notification/base.php
index 80b9a0d777..f7faf50d68 100644
--- a/tests/notification/base.php
+++ b/tests/notification/base.php
@@ -50,7 +50,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
);
}
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/tests/notification/convert_test.php b/tests/notification/convert_test.php
index 4a7fd89409..d4a33ff537 100644
--- a/tests/notification/convert_test.php
+++ b/tests/notification/convert_test.php
@@ -21,7 +21,7 @@ class phpbb_notification_convert_test extends phpbb_database_test_case
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/convert.xml');
}
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
diff --git a/tests/notification/fixtures/services_notification.yml b/tests/notification/fixtures/services_notification.yml
index 6e68cccff6..c83d8bd323 100644
--- a/tests/notification/fixtures/services_notification.yml
+++ b/tests/notification/fixtures/services_notification.yml
@@ -70,7 +70,7 @@ services:
test:
class: phpbb\notification\type\test
- scope: prototype
+ shared: false
parent: notification.type.base
tags:
- { name: notification.type }
diff --git a/tests/notification/group_request_test.php b/tests/notification/group_request_test.php
index e849c66fa5..b935b180d9 100644
--- a/tests/notification/group_request_test.php
+++ b/tests/notification/group_request_test.php
@@ -49,7 +49,7 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas
$this->cache->get_driver()
));
$this->container->set('group_helper', new \phpbb\group\helper(
- $this->getMock('\phpbb\auth\auth'),
+ $this->getMockBuilder('\phpbb\auth\auth')->disableOriginalConstructor()->getMock(),
$this->cache,
$this->config,
new \phpbb\language\language(
@@ -61,7 +61,7 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas
new phpbb_mock_request()
),
new \phpbb\filesystem\filesystem(),
- $this->getMock('\phpbb\request\request'),
+ $this->getMockBuilder('\phpbb\request\request')->disableOriginalConstructor()->getMock(),
$phpbb_root_path,
$phpEx
),
diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php
index 21559c42a5..466d3ec07f 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()
+ public function setUp(): void
{
parent::setUp();
@@ -58,7 +58,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
$db = $this->db;
// Auth
- $auth = $this->getMock('\phpbb\auth\auth');
+ $auth = $this->createMock('\phpbb\auth\auth');
$auth->expects($this->any())
->method('acl_get')
->with($this->stringContains('_'),
@@ -92,7 +92,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
$lang = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
// User
- $user = $this->getMock('\phpbb\user', array(), array(
+ $user = $this->createMock('\phpbb\user', array(), array(
$lang,
'\phpbb\datetime'
));
@@ -105,8 +105,8 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
);
// Request
- $type_cast_helper = $this->getMock('\phpbb\request\type_cast_helper_interface');
- $request = $this->getMock('\phpbb\request\request');
+ $type_cast_helper = $this->createMock('\phpbb\request\type_cast_helper_interface');
+ $request = $this->createMock('\phpbb\request\request');
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$user_loader = new \phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE);
diff --git a/tests/notification/submit_post_type_bookmark_test.php b/tests/notification/submit_post_type_bookmark_test.php
index 7c3b9f938f..9af247b3c3 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()
+ public 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 1390e92d96..bced0ea48c 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()
+ public 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 037c326bc0..5580d0924e 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()
+ public 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 3fab8c05ba..655f12661b 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()
+ public 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 f14f305517..070b2fa21e 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()
+ public function setUp(): void
{
parent::setUp();
@@ -42,7 +42,7 @@ class phpbb_notification_submit_post_type_topic_test extends phpbb_notification_
),
)));
- $phpbb_log = $this->getMock('\phpbb\log\dummy');
+ $phpbb_log = $this->createMock('\phpbb\log\dummy');
}
/**
diff --git a/tests/notification/user_list_trim_test.php b/tests/notification/user_list_trim_test.php
index 7d4dff6024..bf3058c342 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()
+ public function setUp(): void
{
global $phpbb_root_path, $phpEx, $phpbb_dispatcher, $user, $cache, $auth;
@@ -39,7 +39,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case
$phpEx
);
- $auth = $this->getMock('\phpbb\auth\auth');
+ $auth = $this->createMock('\phpbb\auth\auth');
$auth->expects($this->any())
->method('acl_get')
->with($this->stringContains('_'),
diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php
index 2d7d1671a8..073ba1d5cd 100644
--- a/tests/pagination/pagination_test.php
+++ b/tests/pagination/pagination_test.php
@@ -22,14 +22,14 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
return implode('-', func_get_args());
}
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
global $phpbb_dispatcher, $phpbb_root_path, $phpEx;
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
- $this->user = $this->getMock('\phpbb\user', array(), array(
+ $this->user = $this->createMock('\phpbb\user', array(), array(
new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
'\phpbb\datetime'
));
@@ -47,7 +47,7 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
new \phpbb\routing\file_locator($filesystem, dirname(__FILE__) . '/')
);
$resources_locator = new \phpbb\routing\resources_locator\default_resources_locator(dirname(__FILE__) . '/', PHPBB_ENVIRONMENT, $manager);
- $router = new phpbb_mock_router(new phpbb_mock_container_builder(), $resources_locator, $loader, dirname(__FILE__) . '/', 'php');
+ $router = new phpbb_mock_router(new phpbb_mock_container_builder(), $resources_locator, $loader, dirname(__FILE__) . '/', 'php', false);
$request = new phpbb_mock_request();
$request->overwrite('SCRIPT_NAME', '/app.php', \phpbb\request\request_interface::SERVER);
diff --git a/tests/passwords/drivers_test.php b/tests/passwords/drivers_test.php
index 01c69a38bb..fc11ca0bc7 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()
+ public function setUp(): void
{
// Prepare dependencies for drivers
$config = new \phpbb\config\config(array());
@@ -21,6 +21,13 @@ class phpbb_passwords_helper_test extends \phpbb_test_case
$this->driver_helper = new \phpbb\passwords\driver\helper($config);
$phpbb_root_path = dirname(__FILE__) . '/../../phpBB/';
$php_ext = 'php';
+
+ // Initialize argon2 default options
+ $this->argon2_default_cost_options = [
+ 'memory_cost' => 1024,
+ 'time_cost' => 2,
+ 'threads' => 2
+ ];
$this->passwords_drivers = array(
'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($config, $this->driver_helper, 10),
@@ -37,13 +44,26 @@ class phpbb_passwords_helper_test extends \phpbb_test_case
);
$this->passwords_drivers['passwords.driver.md5_phpbb2'] = new \phpbb\passwords\driver\md5_phpbb2($request, $this->passwords_drivers['passwords.driver.salted_md5'], $this->driver_helper, $phpbb_root_path, $php_ext);
$this->passwords_drivers['passwords.driver.bcrypt_wcf2'] = new \phpbb\passwords\driver\bcrypt_wcf2($this->passwords_drivers['passwords.driver.bcrypt'], $this->driver_helper);
+
+ $pwhash_supported = function_exists('password_hash') && function_exists('password_needs_rehash') && function_exists('password_verify');
+ if (defined('PASSWORD_ARGON2I') && $pwhash_supported)
+ {
+ $this->passwords_drivers['passwords.driver.argon2i'] = new \phpbb\passwords\driver\argon2i($config, $this->driver_helper);
+ $this->argon2_default_cost_options = $this->passwords_drivers['passwords.driver.argon2i']->get_options();
+ }
+
+ if (defined('PASSWORD_ARGON2ID') && $pwhash_supported)
+ {
+ $this->passwords_drivers['passwords.driver.argon2id'] = new \phpbb\passwords\driver\argon2id($config, $this->driver_helper);
+ $this->argon2_default_cost_options = $this->passwords_drivers['passwords.driver.argon2id']->get_options();
+ }
}
public function data_helper_encode64()
{
return array(
- array('foobar', 6, 'axqPW3aQ'),
- array('foobar', 7, 'axqPW3aQ..'),
+ array('foobars', 6, 'axqPW3aQ'),
+ array('foobarss', 7, 'axqPW3aQn/'),
array('foobar', 5, 'axqPW34'),
);
}
@@ -416,13 +436,34 @@ class phpbb_passwords_helper_test extends \phpbb_test_case
public function data_needs_rehash()
{
- return array(
+ $data_array = [
array('passwords.driver.bcrypt_2y', '$2y$10$somerandomhash', false),
array('passwords.driver.bcrypt', '$2a$10$somerandomhash', false),
array('passwords.driver.salted_md5', 'foobar', false),
array('passwords.driver.bcrypt_2y', '$2y$9$somerandomhash', true),
array('passwords.driver.bcrypt', '$2a$04$somerandomhash', true),
- );
+ ];
+
+ if (isset($this->passwords_drivers['passwords.driver.argon2i']))
+ {
+ $data_array = array_merge($data_array, [
+ array('passwords.driver.argon2i', '$argon2i$v=19$m=' . $this->argon2_default_cost_options['memory_cost'] . ',t=' . $this->argon2_default_cost_options['time_cost'] . ',p=' . $this->argon2_default_cost_options['threads'] . '$NEF0S1JSN04yNGQ1UVRKdA$KYGNI9CbjoKh1UEu1PpdlqbuLbveGwkMcwcT2Un9pPM', false),
+ array('passwords.driver.argon2i', '$argon2i$v=19$m=128,t=2,p=2$M29GUi51QjdKLjIzbC9scQ$6h1gZDqn7JTmVdQ0lJh1x5nyvgO/DaJWUKOFJ0itCJ0', true),
+ array('passwords.driver.argon2i', '$argon2i$v=19$m=1024,t=1,p=2$UnFHb2F4NER3M0xWWmxMUQ$u3javvoAZJeIyR1P3eg0tb8VjEeXvQPagqwetonq1NA', true),
+ array('passwords.driver.argon2i', '$argon2i$v=19$m=1024,t=2,p=1$bm5SeGJ3R3ZRY1A0YXJPNg$v1A9m4sJW+ge0RBtpJ4w9861+J9xkguKBAsZHrG8LQU', true),
+ ]);
+ }
+
+ if (isset($this->passwords_drivers['passwords.driver.argon2id']))
+ {
+ $data_array = array_merge($data_array, [
+ array('passwords.driver.argon2id', '$argon2id$v=19$m=' . $this->argon2_default_cost_options['memory_cost'] . ',t=' . $this->argon2_default_cost_options['time_cost'] . ',p=' . $this->argon2_default_cost_options['threads'] . '$MXB4OW5sczE5TnFPYkEuYQ$2bxaMIp8+9x37O6v8zkqpBU72ohCibUrtgVZw7vyr5Q', false),
+ array('passwords.driver.argon2id', '$argon2id$v=19$m=128,t=2,p=2$RWV2VFAuWXk5bTVjbktOLg$Nt7Z7koa25SVRSKr3RKqjwKz26FENDuU+aL1DfMcWRo', true),
+ array('passwords.driver.argon2id', '$argon2id$v=19$m=1024,t=1,p=2$Rmw5M21IUFZDVEltYU0uTA$GIObGbHV6sOw5OQEtF8z+2ESztT96OWhCk17sUlwLAY', true),
+ ]);
+ }
+
+ return $data_array;
}
/**
@@ -430,6 +471,10 @@ class phpbb_passwords_helper_test extends \phpbb_test_case
*/
public function test_needs_rehash($driver, $hash, $expected)
{
- $this->assertSame($this->passwords_drivers[$driver]->needs_rehash($hash), $expected);
+ if (!$this->passwords_drivers[$driver]->is_supported())
+ {
+ $this->markTestSkipped($driver . ' is not supported');
+ }
+ $this->assertSame($expected, $this->passwords_drivers[$driver]->needs_rehash($hash));
}
}
diff --git a/tests/passwords/manager_test.php b/tests/passwords/manager_test.php
index 0410d7035f..90dbb47f46 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()
+ public function setUp(): void
{
// Prepare dependencies for manager and driver
$config = new \phpbb\config\config(array());
@@ -51,26 +51,13 @@ class phpbb_passwords_manager_test extends \phpbb_test_case
public function hash_password_data()
{
- if (version_compare(PHP_VERSION, '5.3.7', '<'))
- {
- return array(
- array('', '2a', 60),
- array('passwords.driver.bcrypt_2y', '2a', 60),
- array('passwords.driver.bcrypt', '2a', 60),
- array('passwords.driver.salted_md5', 'H', 34),
- array('passwords.driver.foobar', '', false),
- );
- }
- else
- {
- return array(
- array('', '2y', 60),
- array('passwords.driver.bcrypt_2y', '2y', 60),
- array('passwords.driver.bcrypt', '2a', 60),
- array('passwords.driver.salted_md5', 'H', 34),
- array('passwords.driver.foobar', '', false),
- );
- }
+ return array(
+ array('', '2y', 60),
+ array('passwords.driver.bcrypt_2y', '2y', 60),
+ array('passwords.driver.bcrypt', '2a', 60),
+ array('passwords.driver.salted_md5', 'H', 34),
+ array('passwords.driver.foobar', '', false),
+ );
}
/**
@@ -100,23 +87,12 @@ class phpbb_passwords_manager_test extends \phpbb_test_case
public function check_password_data()
{
- if (version_compare(PHP_VERSION, '5.3.7', '<'))
- {
- return array(
- array('passwords.driver.bcrypt'),
- array('passwords.driver.salted_md5'),
- array('passwords.driver.phpass'),
- );
- }
- else
- {
- return array(
- array('passwords.driver.bcrypt_2y'),
- array('passwords.driver.bcrypt'),
- array('passwords.driver.salted_md5'),
- array('passwords.driver.phpass'),
- );
- }
+ return array(
+ array('passwords.driver.bcrypt_2y'),
+ array('passwords.driver.bcrypt'),
+ array('passwords.driver.salted_md5'),
+ array('passwords.driver.phpass'),
+ );
}
/**
@@ -136,7 +112,7 @@ class phpbb_passwords_manager_test extends \phpbb_test_case
}
// Check if convert_flag is correctly set
- $default_type = (version_compare(PHP_VERSION, '5.3.7', '<')) ? 'passwords.driver.bcrypt' : 'passwords.driver.bcrypt_2y';
+ $default_type = 'passwords.driver.bcrypt_2y';
$this->assertEquals(($hash_type !== $default_type), $this->manager->convert_flag);
}
@@ -200,79 +176,43 @@ class phpbb_passwords_manager_test extends \phpbb_test_case
public function test_hash_password_8bit_bcrypt()
{
$this->assertEquals(false, $this->manager->hash('foobar𝄞', 'passwords.driver.bcrypt'));
- if (version_compare(PHP_VERSION, '5.3.7', '<'))
- {
- $this->assertEquals(false, $this->manager->hash('foobar𝄞', 'passwords.driver.bcrypt_2y'));
- }
- else
- {
- $this->assertNotEquals(false, $this->manager->hash('foobar𝄞', 'passwords.driver.bcrypt_2y'));
- }
+ $this->assertNotEquals(false, $this->manager->hash('foobar𝄞', 'passwords.driver.bcrypt_2y'));
}
public function combined_hash_data()
{
- if (version_compare(PHP_VERSION, '5.3.7', '<'))
- {
- return array(
- array(
- 'passwords.driver.salted_md5',
- array('passwords.driver.bcrypt'),
- ),
- array(
- 'passwords.driver.phpass',
- array('passwords.driver.salted_md5'),
- ),
- array(
- 'passwords.driver.salted_md5',
- array('passwords.driver.phpass', 'passwords.driver.bcrypt'),
- ),
- array(
- 'passwords.driver.salted_md5',
- array('passwords.driver.salted_md5'),
- false,
- ),
- array(
- '$H$',
- array('$2a$'),
- ),
- );
- }
- else
- {
- return array(
- array(
- 'passwords.driver.salted_md5',
- array('passwords.driver.bcrypt_2y'),
- ),
- array(
- 'passwords.driver.salted_md5',
- array('passwords.driver.bcrypt'),
- ),
- array(
- 'passwords.driver.phpass',
- array('passwords.driver.salted_md5'),
- ),
- array(
- 'passwords.driver.salted_md5',
- array('passwords.driver.bcrypt_2y', 'passwords.driver.bcrypt'),
- ),
- array(
- 'passwords.driver.salted_md5',
- array('passwords.driver.salted_md5'),
- false,
- ),
- array(
- 'passwords.driver.bcrypt_2y',
- array('passwords.driver.salted_md4'),
- false,
- ),
- array(
- '$H$',
- array('$2y$'),
- ),
- );
- }
+ return array(
+ array(
+ 'passwords.driver.salted_md5',
+ array('passwords.driver.bcrypt_2y'),
+ ),
+ array(
+ 'passwords.driver.salted_md5',
+ array('passwords.driver.bcrypt'),
+ ),
+ array(
+ 'passwords.driver.phpass',
+ array('passwords.driver.salted_md5'),
+ ),
+ array(
+ 'passwords.driver.salted_md5',
+ array('passwords.driver.bcrypt_2y', 'passwords.driver.bcrypt'),
+ ),
+ array(
+ 'passwords.driver.salted_md5',
+ array('passwords.driver.salted_md5'),
+ false,
+ ),
+ array(
+ 'passwords.driver.bcrypt_2y',
+ array('passwords.driver.salted_md4'),
+ false,
+ ),
+ array(
+ '$H$',
+ array('$2y$'),
+ ),
+ );
}
/**
@@ -361,13 +301,13 @@ class phpbb_passwords_manager_test extends \phpbb_test_case
{
if ($use_new_interface)
{
- $test_driver = $this->getMock('\phpbb\passwords\driver\rehashable_driver_interface', array('needs_rehash', 'get_prefix', 'check', 'is_supported', 'is_legacy', 'hash', 'get_settings_only'));
+ $test_driver = $this->createMock('\phpbb\passwords\driver\rehashable_driver_interface', array('needs_rehash', 'get_prefix', 'check', 'is_supported', 'is_legacy', 'hash', 'get_settings_only'));
$test_driver->method('needs_rehash')
->willReturn($needs_rehash);
}
else
{
- $test_driver = $this->getMock('\phpbb\passwords\driver\driver_interface', array('get_prefix', 'check', 'is_supported', 'is_legacy', 'hash', 'get_settings_only'));
+ $test_driver = $this->createMock('\phpbb\passwords\driver\driver_interface', array('get_prefix', 'check', 'is_supported', 'is_legacy', 'hash', 'get_settings_only'));
}
$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 49dd40fbec..447ed7a2db 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()
+ public function setUp(): void
{
parent::setUp();
@@ -29,7 +29,7 @@ class phpbb_path_helper_test extends phpbb_test_case
new phpbb_mock_request()
),
new \phpbb\filesystem\filesystem(),
- $this->getMock('\phpbb\request\request'),
+ $this->createMock('\phpbb\request\request'),
$this->phpbb_root_path,
'php'
);
@@ -180,7 +180,7 @@ class phpbb_path_helper_test extends phpbb_test_case
*/
public function test_update_web_root_path($input, $getPathInfo, $getRequestUri, $getScriptName, $correction)
{
- $symfony_request = $this->getMock('\phpbb\symfony_request', array(), array(
+ $symfony_request = $this->createMock('\phpbb\symfony_request', array(), array(
new phpbb_mock_request(),
));
$symfony_request->expects($this->any())
@@ -196,7 +196,7 @@ class phpbb_path_helper_test extends phpbb_test_case
$path_helper = new \phpbb\path_helper(
$symfony_request,
new \phpbb\filesystem\filesystem(),
- $this->getMock('\phpbb\request\request'),
+ $this->createMock('\phpbb\request\request'),
$this->phpbb_root_path,
'php'
);
diff --git a/tests/profilefields/type_bool_test.php b/tests/profilefields/type_bool_test.php
index 10239172c3..3e7cace288 100644
--- a/tests/profilefields/type_bool_test.php
+++ b/tests/profilefields/type_bool_test.php
@@ -23,19 +23,21 @@ class phpbb_profilefield_type_bool_test extends phpbb_test_case
* @access public
* @return void
*/
- public function setUp()
+ public function setUp(): void
{
global $phpbb_root_path, $phpEx;
- $user = $this->getMock('\phpbb\user', array(), array(
- new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
- '\phpbb\datetime'
- ));
+ $db = $this->createMock('phpbb\\db\\driver\\driver');
+
+ $user = $this->createMock('\phpbb\user');
$user->expects($this->any())
->method('lang')
->will($this->returnCallback(array($this, 'return_callback_implode')));
- $lang = $this->getMock('\phpbb\profilefields\lang_helper', array(), array(null, null));
+ $lang = $this->getMockBuilder('\phpbb\profilefields\lang_helper')
+ ->setMethods(array('get_options_lang', 'is_set', 'get'))
+ ->setConstructorArgs(array($db, LANG_TABLE))
+ ->getMock();
$lang->expects($this->any())
->method('get_options_lang');
@@ -48,8 +50,8 @@ class phpbb_profilefield_type_bool_test extends phpbb_test_case
->method('get')
->will($this->returnCallback(array($this, 'get')));
- $request = $this->getMock('\phpbb\request\request');
- $template = $this->getMock('\phpbb\template\template');
+ $request = $this->createMock('\phpbb\request\request');
+ $template = $this->createMock('\phpbb\template\template');
$this->cp = new \phpbb\profilefields\type\type_bool(
$lang,
diff --git a/tests/profilefields/type_date_test.php b/tests/profilefields/type_date_test.php
index e0807b2f9b..b70aa60368 100644
--- a/tests/profilefields/type_date_test.php
+++ b/tests/profilefields/type_date_test.php
@@ -23,11 +23,11 @@ class phpbb_profilefield_type_date_test extends phpbb_test_case
* @access public
* @return null
*/
- public function setUp()
+ public function setUp(): void
{
global $phpbb_root_path, $phpEx;
- $this->user = $this->getMock('\phpbb\user', array(), array(
+ $this->user = $this->createMock('\phpbb\user', array(), array(
new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
'\phpbb\datetime'
));
@@ -45,8 +45,8 @@ class phpbb_profilefield_type_date_test extends phpbb_test_case
'DATE_FORMAT' => 'm/d/Y',
);
- $request = $this->getMock('\phpbb\request\request');
- $template = $this->getMock('\phpbb\template\template');
+ $request = $this->createMock('\phpbb\request\request');
+ $template = $this->createMock('\phpbb\template\template');
$this->cp = new \phpbb\profilefields\type\type_date(
$request,
diff --git a/tests/profilefields/type_dropdown_test.php b/tests/profilefields/type_dropdown_test.php
index ab02353fb9..738801d524 100644
--- a/tests/profilefields/type_dropdown_test.php
+++ b/tests/profilefields/type_dropdown_test.php
@@ -23,22 +23,24 @@ class phpbb_profilefield_type_dropdown_test extends phpbb_test_case
* @access public
* @return null
*/
- public function setUp()
+ public function setUp(): void
{
global $phpbb_root_path, $phpEx;
- $user = $this->getMock('\phpbb\user', array(), array(
- new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
- '\phpbb\datetime'
- ));
+ $db = $this->createMock('phpbb\\db\\driver\\driver');
+
+ $user = $this->createMock('\phpbb\user');
$user->expects($this->any())
->method('lang')
->will($this->returnCallback(array($this, 'return_callback_implode')));
- $request = $this->getMock('\phpbb\request\request');
- $template = $this->getMock('\phpbb\template\template');
+ $request = $this->createMock('\phpbb\request\request');
+ $template = $this->createMock('\phpbb\template\template');
- $lang = $this->getMock('\phpbb\profilefields\lang_helper', array(), array(null, null));
+ $lang = $this->getMockBuilder('\phpbb\profilefields\lang_helper')
+ ->setMethods(array('get_options_lang', 'is_set', 'get'))
+ ->setConstructorArgs(array($db, LANG_TABLE))
+ ->getMock();
$lang->expects($this->any())
->method('get_options_lang');
diff --git a/tests/profilefields/type_googleplus_test.php b/tests/profilefields/type_googleplus_test.php
index 9222362214..a5f934ea17 100644
--- a/tests/profilefields/type_googleplus_test.php
+++ b/tests/profilefields/type_googleplus_test.php
@@ -15,7 +15,7 @@ class phpbb_profilefield_type_googleplus_test extends phpbb_test_case
{
protected $field;
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
@@ -25,8 +25,8 @@ class phpbb_profilefield_type_googleplus_test extends phpbb_test_case
$lang = new \phpbb\language\language($lang_loader);
$user = new \phpbb\user($lang, '\phpbb\datetime');
$user->add_lang('ucp');
- $request = $this->getMock('\phpbb\request\request');
- $template = $this->getMock('\phpbb\template\template');
+ $request = $this->createMock('\phpbb\request\request');
+ $template = $this->createMock('\phpbb\template\template');
$this->field = new \phpbb\profilefields\type\type_googleplus(
$request,
diff --git a/tests/profilefields/type_int_test.php b/tests/profilefields/type_int_test.php
index 33f3f575c8..943f130835 100644
--- a/tests/profilefields/type_int_test.php
+++ b/tests/profilefields/type_int_test.php
@@ -22,11 +22,11 @@ class phpbb_profilefield_type_int_test extends phpbb_test_case
* @access public
* @return null
*/
- public function setUp()
+ public function setUp(): void
{
global $phpbb_root_path, $phpEx;
- $user = $this->getMock('\phpbb\user', array(), array(
+ $user = $this->createMock('\phpbb\user', array(), array(
new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
'\phpbb\datetime'
));
@@ -34,8 +34,8 @@ class phpbb_profilefield_type_int_test extends phpbb_test_case
->method('lang')
->will($this->returnCallback(array($this, 'return_callback_implode')));
- $request = $this->getMock('\phpbb\request\request');
- $template = $this->getMock('\phpbb\template\template');
+ $request = $this->createMock('\phpbb\request\request');
+ $template = $this->createMock('\phpbb\template\template');
$this->cp = new \phpbb\profilefields\type\type_int(
$request,
diff --git a/tests/profilefields/type_string_test.php b/tests/profilefields/type_string_test.php
index 54bb406838..19bfbbc926 100644
--- a/tests/profilefields/type_string_test.php
+++ b/tests/profilefields/type_string_test.php
@@ -22,11 +22,11 @@ class phpbb_profilefield_type_string_test extends phpbb_test_case
* @access public
* @return null
*/
- public function setUp()
+ public function setUp(): void
{
global $config, $request, $user, $cache, $phpbb_root_path, $phpEx;
- $user = $this->getMock('\phpbb\user', array(), array(
+ $user = $this->createMock('\phpbb\user', array(), array(
new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
'\phpbb\datetime'
));
@@ -36,8 +36,8 @@ class phpbb_profilefield_type_string_test extends phpbb_test_case
->will($this->returnCallback(array($this, 'return_callback_implode')));
$config = new \phpbb\config\config([]);
- $request = $this->getMock('\phpbb\request\request');
- $template = $this->getMock('\phpbb\template\template');
+ $request = $this->createMock('\phpbb\request\request');
+ $template = $this->createMock('\phpbb\template\template');
$this->cp = new \phpbb\profilefields\type\type_string(
$request,
diff --git a/tests/profilefields/type_url_test.php b/tests/profilefields/type_url_test.php
index 3bb5d52899..5ed5fb4c2f 100644
--- a/tests/profilefields/type_url_test.php
+++ b/tests/profilefields/type_url_test.php
@@ -26,13 +26,13 @@ class phpbb_profilefield_type_url_test extends phpbb_test_case
* @access public
* @return null
*/
- public function setUp()
+ public function setUp(): void
{
global $config, $request, $user, $cache, $phpbb_root_path, $phpEx;
$config = new \phpbb\config\config([]);
$cache = new phpbb_mock_cache;
- $user = $this->getMock('\phpbb\user', array(), array(
+ $user = $this->createMock('\phpbb\user', array(), array(
new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
'\phpbb\datetime'
));
@@ -40,8 +40,8 @@ class phpbb_profilefield_type_url_test extends phpbb_test_case
->method('lang')
->will($this->returnCallback(array($this, 'return_callback_implode')));
- $request = $this->getMock('\phpbb\request\request');
- $template = $this->getMock('\phpbb\template\template');
+ $request = $this->createMock('\phpbb\request\request');
+ $template = $this->createMock('\phpbb\template\template');
$this->cp = new \phpbb\profilefields\type\type_url(
$request,
diff --git a/tests/random/gen_rand_string_test.php b/tests/random/gen_rand_string_test.php
index 428db6ac98..044fd3cc15 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()
+ public function setUp(): void
{
global $config;
diff --git a/tests/regex/email_test.php b/tests/regex/email_test.php
index 5187b8bda6..7b10b0a6ef 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()
+ public function setUp(): void
{
$this->regex = '#^' . get_preg_expression('email') . '$#i';
}
@@ -36,7 +36,7 @@ class phpbb_regex_email_test extends phpbb_test_case
//array('"John Doe"@example.com'),
//array('Alice@[192.168.2.1]'), // IPv4
//array('Bob@[2001:0db8:85a3:08d3:1319:8a2e:0370:7344]'), // IPv6
-
+
// http://fightingforalostcause.net/misc/2006/compare-email-regex.php
array('l3tt3rsAndNumb3rs@domain.com'),
array('has-dash@domain.com'),
@@ -80,7 +80,7 @@ class phpbb_regex_email_test extends phpbb_test_case
array('abc,def@example.com'), // invalid character ,
array('abc<def@example.com'), // invalid character <
array('abc>def@example.com'), // invalid character >
-
+
// http://fightingforalostcause.net/misc/2006/compare-email-regex.php
array('missingDomain@.com'),
array('@missingLocal.org'),
diff --git a/tests/regex/ipv4_test.php b/tests/regex/ipv4_test.php
index e21a2d77fa..5d859c240b 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()
+ public function setUp(): void
{
$this->regex = get_preg_expression('ipv4');
}
diff --git a/tests/regex/ipv6_test.php b/tests/regex/ipv6_test.php
index 223161df7f..d4a86015ae 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()
+ public function setUp(): void
{
$this->regex = get_preg_expression('ipv6');
}
diff --git a/tests/request/deactivated_super_global_test.php b/tests/request/deactivated_super_global_test.php
index d45f9ca666..eabc79ed96 100644
--- a/tests/request/deactivated_super_global_test.php
+++ b/tests/request/deactivated_super_global_test.php
@@ -19,7 +19,7 @@ class phpbb_deactivated_super_global_test extends phpbb_test_case
public function test_write_triggers_error()
{
$this->setExpectedTriggerError(E_USER_ERROR);
- $obj = new \phpbb\request\deactivated_super_global($this->getMock('\phpbb\request\request_interface'), 'obj', \phpbb\request\request_interface::POST);
+ $obj = new \phpbb\request\deactivated_super_global($this->createMock('\phpbb\request\request_interface'), 'obj', \phpbb\request\request_interface::POST);
$obj->offsetSet(0, 0);
}
}
diff --git a/tests/request/request_test.php b/tests/request/request_test.php
index ebaea1f9ef..d03253ceb9 100644
--- a/tests/request/request_test.php
+++ b/tests/request/request_test.php
@@ -19,7 +19,7 @@ class phpbb_request_test extends phpbb_test_case
/** @var \phpbb\request\request */
private $request;
- protected function setUp()
+ protected function setUp(): void
{
// populate super globals
$_POST['test'] = 1;
@@ -39,7 +39,7 @@ class phpbb_request_test extends phpbb_test_case
$_SERVER['HTTP_ACCEPT'] = 'application/json';
$_SERVER['HTTP_SOMEVAR'] = '<value>';
- $this->type_cast_helper = $this->getMock('\phpbb\request\type_cast_helper_interface');
+ $this->type_cast_helper = $this->createMock('\phpbb\request\type_cast_helper_interface');
$this->request = new \phpbb\request\request($this->type_cast_helper);
}
@@ -264,7 +264,7 @@ class phpbb_request_test extends phpbb_test_case
/**
* Makes sure super globals work properly after these tests
*/
- protected function tearDown()
+ protected function tearDown(): void
{
$this->request->enable_super_globals();
}
diff --git a/tests/request/request_var_test.php b/tests/request/request_var_test.php
index 84c81c4e84..8dc8e4c7c7 100644
--- a/tests/request/request_var_test.php
+++ b/tests/request/request_var_test.php
@@ -16,7 +16,7 @@ class phpbb_request_var_test extends phpbb_test_case
/**
* Makes sure request_var has its standard behaviour.
*/
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
request_var(false, false, false, false, false);
diff --git a/tests/request/type_cast_helper_test.php b/tests/request/type_cast_helper_test.php
index 6407dca894..5810c67b78 100644
--- a/tests/request/type_cast_helper_test.php
+++ b/tests/request/type_cast_helper_test.php
@@ -15,7 +15,7 @@ class phpbb_type_cast_helper_test extends phpbb_test_case
{
private $type_cast_helper;
- protected function setUp()
+ protected function setUp(): void
{
$this->type_cast_helper = new \phpbb\request\type_cast_helper();
}
diff --git a/tests/search/mysql_test.php b/tests/search/mysql_test.php
index 3a791f5e81..7d3917296e 100644
--- a/tests/search/mysql_test.php
+++ b/tests/search/mysql_test.php
@@ -23,7 +23,7 @@ class phpbb_search_mysql_test extends phpbb_search_common_test_case
return $this->createXMLDataSet(dirname(__FILE__) . '/../fixtures/empty.xml');
}
- protected function setUp()
+ protected function setUp(): void
{
global $phpbb_root_path, $phpEx, $config, $user, $cache;
diff --git a/tests/search/native_test.php b/tests/search/native_test.php
index 0e6f719cef..2e11eaff14 100644
--- a/tests/search/native_test.php
+++ b/tests/search/native_test.php
@@ -23,7 +23,7 @@ class phpbb_search_native_test extends phpbb_search_test_case
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/posts.xml');
}
- protected function setUp()
+ protected function setUp(): void
{
global $phpbb_root_path, $phpEx, $config, $user, $cache;
diff --git a/tests/search/postgres_test.php b/tests/search/postgres_test.php
index 97cca0e70c..7e2a6cec85 100644
--- a/tests/search/postgres_test.php
+++ b/tests/search/postgres_test.php
@@ -23,7 +23,7 @@ class phpbb_search_postgres_test extends phpbb_search_common_test_case
return $this->createXMLDataSet(dirname(__FILE__) . '/../fixtures/empty.xml');
}
- protected function setUp()
+ protected function setUp(): void
{
global $phpbb_root_path, $phpEx, $config, $user, $cache;
diff --git a/tests/security/base.php b/tests/security/base.php
index d2abdbc362..ad518b5543 100644
--- a/tests/security/base.php
+++ b/tests/security/base.php
@@ -18,7 +18,7 @@ abstract class phpbb_security_test_base extends phpbb_test_case
/**
* Set up the required user object and server variables for the suites
*/
- protected function setUp()
+ protected function setUp(): void
{
global $user, $phpbb_root_path, $phpEx, $request, $symfony_request, $phpbb_filesystem;
@@ -60,7 +60,7 @@ abstract class phpbb_security_test_base extends phpbb_test_case
$user->page = \phpbb\session::extract_current_page($phpbb_root_path);
}
- protected function tearDown()
+ protected function tearDown(): void
{
global $user;
$user = NULL;
diff --git a/tests/security/hash_test.php b/tests/security/hash_test.php
index 84d4fcf479..40d14f24bf 100644
--- a/tests/security/hash_test.php
+++ b/tests/security/hash_test.php
@@ -13,12 +13,12 @@
class phpbb_security_hash_test extends phpbb_test_case
{
- public function setUp()
+ public function setUp(): void
{
global $phpbb_container;
$config = new \phpbb\config\config(array());
- $phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $phpbb_container = $this->createMock('Symfony\Component\DependencyInjection\ContainerInterface');
$driver_helper = new \phpbb\passwords\driver\helper($config);
$passwords_drivers = array(
'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($config, $driver_helper),
diff --git a/tests/security/redirect_test.php b/tests/security/redirect_test.php
index 0177eb4259..313e329e20 100644
--- a/tests/security/redirect_test.php
+++ b/tests/security/redirect_test.php
@@ -67,7 +67,7 @@ class phpbb_security_redirect_test extends phpbb_security_test_base
new phpbb_mock_request()
),
new \phpbb\filesystem\filesystem(),
- $this->getMock('\phpbb\request\request'),
+ $this->createMock('\phpbb\request\request'),
$this->phpbb_root_path,
'php'
);
@@ -75,7 +75,7 @@ class phpbb_security_redirect_test extends phpbb_security_test_base
return $this->path_helper;
}
- protected function setUp()
+ protected function setUp(): void
{
global $phpbb_dispatcher;
diff --git a/tests/session/check_ban_test.php b/tests/session/check_ban_test.php
index 16a65b0ade..0ee655f4ac 100644
--- a/tests/session/check_ban_test.php
+++ b/tests/session/check_ban_test.php
@@ -17,6 +17,7 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case
{
protected $user_id = 4;
protected $key_id = 4;
+ /** @var \phpbb\session */
protected $session;
protected $backup_cache;
@@ -37,7 +38,7 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case
);
}
- public function setUp()
+ public function setUp(): void
{
parent::setUp();
// Get session here so that config is mocked correctly
@@ -59,7 +60,7 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case
);
}
- public function tearDown()
+ public function tearDown(): void
{
parent::tearDown();
// Set cache back to what it was before the test changed it
@@ -75,7 +76,7 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case
$ban = $this->session->check_ban($user_id, $user_ips, $user_email, $return);
$is_banned = !empty($ban);
}
- catch (PHPUnit_Framework_Error_Notice $e)
+ catch (PHPUnit\Framework\Error\Notice $e)
{
// User error was triggered, user must have been banned
$is_banned = true;
diff --git a/tests/session/fixtures/sessions_garbage.xml b/tests/session/fixtures/sessions_garbage.xml
index 5eace839d0..59a2dc2ebe 100644
--- a/tests/session/fixtures/sessions_garbage.xml
+++ b/tests/session/fixtures/sessions_garbage.xml
@@ -5,11 +5,23 @@
<column>username_clean</column>
<column>user_permissions</column>
<column>user_sig</column>
+ <column>user_lastpage</column>
+ <column>user_lastvisit</column>
<row>
<value>4</value>
<value>bar</value>
<value></value>
<value></value>
+ <value>oldpage_user_bar.php</value>
+ <value>1400000000</value>
+ </row>
+ <row>
+ <value>5</value>
+ <value>foo</value>
+ <value></value>
+ <value></value>
+ <value>oldpage_user_foo.php</value>
+ <value>1400000000</value>
</row>
</table>
<table name="phpbb_sessions">
@@ -18,12 +30,16 @@
<column>session_ip</column>
<column>session_browser</column>
<column>session_admin</column>
+ <column>session_page</column>
+ <column>session_time</column>
<row>
<value>anon_session00000000000000000000</value>
<value>1</value>
<value>127.0.0.1</value>
<value>anonymous user agent</value>
<value>0</value>
+ <value></value>
+ <value>1500000005</value>
</row>
<row>
<value>bar_session000000000000000000000</value>
@@ -31,6 +47,35 @@
<value>127.0.0.1</value>
<value>user agent</value>
<value>1</value>
+ <value>newpage_user_bar.php</value>
+ <value>1500000000</value>
+ </row>
+ <row>
+ <value>bar_session000000000000000000002</value>
+ <value>4</value>
+ <value>127.0.0.1</value>
+ <value>user agent</value>
+ <value>1</value>
+ <value>oldpage_user_bar.php</value>
+ <value>1400000000</value>
+ </row>
+ <row>
+ <value>foo_session000000000000000000000</value>
+ <value>5</value>
+ <value>127.0.0.1</value>
+ <value>user agent</value>
+ <value>0</value>
+ <value>newpage_user_foo.php</value>
+ <value>1500000000</value>
+ </row>
+ <row>
+ <value>foo_session000000000000000000002</value>
+ <value>5</value>
+ <value>127.0.0.1</value>
+ <value>user agent</value>
+ <value>0</value>
+ <value>oldpage_user_foo.php</value>
+ <value>1400000000</value>
</row>
</table>
<table name="phpbb_login_attempts">
diff --git a/tests/session/garbage_collection_test.php b/tests/session/garbage_collection_test.php
index 3dc591a328..ec248b2904 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()
+ public function setUp(): void
{
parent::setUp();
$this->session = $this->session_factory->get_session($this->db);
@@ -41,19 +41,91 @@ class phpbb_session_garbage_collection_test extends phpbb_session_test_case
);
}
+ public function test_session_gc()
+ {
+ global $config;
+ $config['session_length'] = 3600;
+
+ $this->check_expired_sessions_recent(
+ [
+ [
+ 'session_user_id' => 4,
+ 'recent_time' => 1500000000,
+ ],
+ [
+ 'session_user_id' => 5,
+ 'recent_time' => 1500000000,
+ ],
+ ],
+ 'Before test, should get recent expired sessions only.'
+ );
+
+ $this->check_user_session_data(
+ [
+ [
+ 'username_clean' => 'bar',
+ 'user_lastvisit' => 1400000000,
+ 'user_lastpage' => 'oldpage_user_bar.php',
+ ],
+ [
+ 'username_clean' => 'foo',
+ 'user_lastvisit' => 1400000000,
+ 'user_lastpage' => 'oldpage_user_foo.php',
+ ],
+ ],
+ 'Before test, users session data is not updated yet.'
+ );
+
+ // There is an error unless the captcha plugin is set
+ $config['captcha_plugin'] = 'core.captcha.plugins.nogd';
+ $this->session->session_gc();
+ $this->check_expired_sessions_recent(
+ [],
+ 'After garbage collection, all expired sessions should be removed.'
+ );
+
+ $this->check_user_session_data(
+ [
+ [
+ 'username_clean' => 'bar',
+ 'user_lastvisit' => '1500000000',
+ 'user_lastpage' => 'newpage_user_bar.php',
+ ],
+ [
+ 'username_clean' => 'foo',
+ 'user_lastvisit' => '1500000000',
+ 'user_lastpage' => 'newpage_user_foo.php',
+ ],
+ ],
+ 'After garbage collection, users session data should be updated to the recent expired sessions data.'
+ );
+ }
+
public function test_cleanup_all()
{
$this->check_sessions_equals(
- array(
- array(
+ [
+ [
'session_id' => 'anon_session00000000000000000000',
'session_user_id' => 1,
- ),
- array(
+ ],
+ [
'session_id' => 'bar_session000000000000000000000',
'session_user_id' => 4,
- ),
- ),
+ ],
+ [
+ 'session_id' => 'bar_session000000000000000000002',
+ 'session_user_id' => 4,
+ ],
+ [
+ 'session_id' => 'foo_session000000000000000000000',
+ 'session_user_id' => 5,
+ ],
+ [
+ 'session_id' => 'foo_session000000000000000000002',
+ 'session_user_id' => 5,
+ ],
+ ],
'Before test, should have some sessions.'
);
// Set session length so it clears all
@@ -63,7 +135,7 @@ class phpbb_session_garbage_collection_test extends phpbb_session_test_case
$config['captcha_plugin'] = 'core.captcha.plugins.nogd';
$this->session->session_gc();
$this->check_sessions_equals(
- array(),
+ [],
'After setting session time to 0, should remove all.'
);
}
diff --git a/tests/session/testable_factory.php b/tests/session/testable_factory.php
index 6f8b49122b..d381b4cbbd 100644
--- a/tests/session/testable_factory.php
+++ b/tests/session/testable_factory.php
@@ -120,10 +120,10 @@ class phpbb_session_testable_factory
/**
* Check if the cache used for the generated session contains correct data.
*
- * @param PHPUnit_Framework_Assert $test The test case to call assert methods
+ * @param PHPUnit\Framework\Assert $test The test case to call assert methods
* on
*/
- public function check(PHPUnit_Framework_Assert $test)
+ public function check(PHPUnit\Framework\Assert $test)
{
$this->cache->check($test, $this->get_cache_data());
}
diff --git a/tests/template/context_test.php b/tests/template/context_test.php
index 52ce6c8fde..a1be672f51 100644
--- a/tests/template/context_test.php
+++ b/tests/template/context_test.php
@@ -14,7 +14,7 @@
class context_test extends phpbb_test_case
{
protected $context;
- protected function setUp()
+ protected function setUp(): void
{
$this->context = new \phpbb\template\context();
@@ -31,7 +31,7 @@ class context_test extends phpbb_test_case
'SUBFOO' => 'subfoo' . $j,
'SUBBAR' => 'subbar' . $j,
));
-
+
for ($k = 0; $k < 10; $k++)
{
$this->context->assign_block_vars('block' . $i . '.subblock.subsubblock', array(
diff --git a/tests/template/extension_test.php b/tests/template/extension_test.php
new file mode 100644
index 0000000000..d633001060
--- /dev/null
+++ b/tests/template/extension_test.php
@@ -0,0 +1,258 @@
+<?php
+/**
+ *
+ * This file is part of the phpBB Forum Software package.
+ *
+ * @copyright (c) phpBB Limited <https://www.phpbb.com>
+ * @license GNU General Public License, version 2 (GPL-2.0)
+ *
+ * For full copyright and license information, please see
+ * the docs/CREDITS.txt file.
+ *
+ */
+
+require_once dirname(__FILE__) . '/template_test_case.php';
+
+class phpbb_template_extension_test extends phpbb_template_template_test_case
+{
+ protected function setup_engine(array $new_config = array())
+ {
+ global $config, $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx;
+
+ $defaults = $this->config_defaults();
+ $defaults = array_merge($defaults, [
+ 'allow_avatar' => true,
+ 'allow_avatar_upload' => true,
+ ]);
+ $config = new \phpbb\config\config(array_merge($defaults, $new_config));
+ $lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
+ $this->lang = $lang = new \phpbb\language\language($lang_loader);
+ $this->user = new \phpbb\user($lang, '\phpbb\datetime');
+
+ global $auth, $request, $symfony_request, $user;
+ $user = new phpbb_mock_user();
+ $user->optionset('user_id', 2);
+ $auth = $this->getMockBuilder('phpbb\auth\auth')
+ ->disableOriginalConstructor()
+ ->setMethods(['acl_get'])
+ ->getMock();
+ $auth->method('acl_get')
+ ->willReturn(true);
+
+ $filesystem = new \phpbb\filesystem\filesystem();
+ $request = new phpbb_mock_request;
+ $symfony_request = new \phpbb\symfony_request(
+ $request
+ );
+ $phpbb_path_helper = new \phpbb\path_helper(
+ $symfony_request,
+ $filesystem,
+ $request,
+ $phpbb_root_path,
+ $phpEx
+ );
+
+ $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
+ $phpbb_container = new phpbb_mock_container_builder();
+ $files = new phpbb\files\factory($phpbb_container);
+ $upload_avatar_driver = new phpbb\avatar\driver\upload($config, $phpbb_root_path, $phpEx, $filesystem, $phpbb_path_helper, $phpbb_dispatcher, $files);
+ $upload_avatar_driver->set_name('avatar.driver.upload');
+ $phpbb_container->set('avatar.manager', new \phpbb\avatar\manager($config, $phpbb_dispatcher, [
+ $upload_avatar_driver,
+ ]));
+ $phpbb_container->set('path_helper', $phpbb_path_helper);
+
+ $class = new ReflectionClass('\phpbb\avatar\manager');
+ $enabled_drivers = $class->getProperty('enabled_drivers');
+ $enabled_drivers->setAccessible(true);
+ $enabled_drivers->setValue(false);
+
+ $this->template_path = $this->test_path . '/templates';
+
+ $cache_path = $phpbb_root_path . 'cache/twig';
+ $context = new \phpbb\template\context();
+ $loader = new \phpbb\template\twig\loader($filesystem);
+ $twig = new \phpbb\template\twig\environment(
+ $config,
+ $filesystem,
+ $phpbb_path_helper,
+ $cache_path,
+ null,
+ $loader,
+ new \phpbb\event\dispatcher($phpbb_container),
+ array(
+ 'cache' => false,
+ 'debug' => false,
+ 'auto_reload' => true,
+ 'autoescape' => false,
+ )
+ );
+ $this->template = new phpbb\template\twig\twig(
+ $phpbb_path_helper,
+ $config,
+ $context,
+ $twig,
+ $cache_path,
+ $this->user,
+ [
+ new \phpbb\template\twig\extension($context, $twig, $this->lang),
+ new \phpbb\template\twig\extension\avatar(),
+ new \phpbb\template\twig\extension\config($config),
+ new \phpbb\template\twig\extension\username(),
+ ]
+ );
+ $twig->setLexer(new \phpbb\template\twig\lexer($twig));
+ $this->template->set_custom_style('tests', $this->template_path);
+ }
+
+ public function data_template_extensions()
+ {
+ return [
+ [
+ 'avatar_user.html',
+ [
+ 'row' => [
+ 'user_avatar' => 'great_avatar.png',
+ 'user_avatar_type' => 'avatar.driver.upload',
+ 'user_avatar_width' => 90,
+ 'user_avatar_height' => 90,
+ ],
+ 'alt' => 'foo'
+ ],
+ [],
+ [],
+ '<img class="avatar" src="phpBB/download/file.php?avatar=great_avatar.png" width="90" height="90" alt="foo" />',
+ []
+ ],
+ [
+ 'avatar_user.html',
+ [
+ 'row' => [
+ 'user_avatar' => 'great_avatar.png',
+ 'user_avatar_type' => 'avatar.driver.upload',
+ 'user_avatar_width' => 90,
+ 'user_avatar_height' => 90,
+ ],
+ 'alt' => 'foo',
+ 'ignore_config' => true,
+ 'lazy' => true,
+ ],
+ [],
+ [],
+ '<img class="avatar" src="phpBB/styles//theme/images/no_avatar.gif" data-src="phpBB/download/file.php?avatar=great_avatar.png" width="90" height="90" alt="foo" />',
+ []
+ ],
+ [
+ 'avatar_user.html',
+ [
+ 'row' => [
+ 'user_avatar' => 'foo@bar.com',
+ 'user_avatar_type' => 'avatar.driver.gravatar',
+ 'user_avatar_width' => 90,
+ 'user_avatar_height' => 90,
+ ],
+ 'alt' => 'foo'
+ ],
+ [],
+ [],
+ '',
+ []
+ ],
+ [
+ 'extension_username_test.html',
+ [
+ 'mode' => 'profile',
+ 'user_id' => 2,
+ 'username' => 'admin',
+ 'user_colour' => 'abcdef',
+ 'guest_username' => 'lol',
+ ],
+ [],
+ [],
+ 'phpBB/memberlist.php?mode=viewprofile&amp;u=2',
+ []
+ ],
+ [
+ 'extension_username_test.html',
+ [
+ 'mode' => 'profile',
+ 'user_id' => 2,
+ 'username' => 'admin',
+ 'user_colour' => 'abcdef',
+ 'guest_username' => 'lol',
+ 'custom_profile_url' => 'http://lol.bar',
+ ],
+ [],
+ [],
+ 'http://lol.bar&amp;u=2',
+ []
+ ],
+ [
+ 'extension_username_test.html',
+ [
+ 'mode' => 'full',
+ 'user_id' => 2,
+ 'username' => 'admin',
+ 'user_colour' => 'abcdef',
+ 'guest_username' => 'lol',
+ ],
+ [],
+ [],
+ '<a href="phpBB/memberlist.php?mode=viewprofile&amp;u=2" style="color: #abcdef;" class="username-coloured">admin</a>',
+ []
+ ],
+ [
+ 'extension_username_test.html',
+ [
+ 'mode' => 'no_profile',
+ 'user_id' => 2,
+ 'username' => 'admin',
+ 'user_colour' => 'abcdef',
+ 'guest_username' => 'lol',
+ ],
+ [],
+ [],
+ '<span style="color: #abcdef;" class="username-coloured">admin</span>',
+ []
+ ],
+ [
+ 'extension_config_test.html',
+ [
+ 'config_name' => 'allow_avatar',
+ ],
+ [],
+ [],
+ '1',
+ []
+ ],
+ [
+ 'extension_config_test.html',
+ [
+ 'config_name' => 'does not exist',
+ ],
+ [],
+ [],
+ '',
+ []
+ ],
+ [
+ 'extension_config_test.html',
+ [
+ 'config_name' => 'tpl_allow_php',
+ ],
+ [],
+ [],
+ '',
+ []
+ ],
+ ];
+ }
+
+ /**
+ * @dataProvider data_template_extensions
+ */
+ public function test_get_user_avatar($file, $vars, $block_vars, $destroy_array, $expected, $lang_vars = [])
+ {
+ $this->run_template($file, $vars, $block_vars, $destroy_array, $expected, $lang_vars);
+ }
+}
diff --git a/tests/template/template_allfolder_test.php b/tests/template/template_allfolder_test.php
index 63a6ef08ea..a9a8ecc287 100644
--- a/tests/template/template_allfolder_test.php
+++ b/tests/template/template_allfolder_test.php
@@ -40,7 +40,7 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case
new phpbb_mock_request()
),
$filesystem,
- $this->getMock('\phpbb\request\request'),
+ $this->createMock('\phpbb\request\request'),
$phpbb_root_path,
$phpEx
);
@@ -75,7 +75,7 @@ class phpbb_template_allfolder_test extends phpbb_template_template_test_case
'autoescape' => false,
)
);
- $this->template = new \phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user)), $this->extension_manager);
+ $this->template = new \phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $twig, $this->user)), $this->extension_manager);
$twig->setLexer(new \phpbb\template\twig\lexer($twig));
$this->template_path = $this->test_path . '/templates';
diff --git a/tests/template/template_events_test.php b/tests/template/template_events_test.php
index 3a93c91e11..9243390937 100644
--- a/tests/template/template_events_test.php
+++ b/tests/template/template_events_test.php
@@ -145,7 +145,7 @@ Zeta test event in all',
new phpbb_mock_request()
),
new \phpbb\filesystem\filesystem(),
- $this->getMock('\phpbb\request\request'),
+ $this->createMock('\phpbb\request\request'),
$phpbb_root_path,
$phpEx
);
@@ -169,7 +169,7 @@ Zeta test event in all',
'autoescape' => false,
)
);
- $this->template = new \phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user)), $this->extension_manager);
+ $this->template = new \phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $twig, $this->user)), $this->extension_manager);
$twig->setLexer(new \phpbb\template\twig\lexer($twig));
$this->template->set_custom_style(((!empty($style_names)) ? $style_names : 'silver'), array($this->template_path));
diff --git a/tests/template/template_includecss_test.php b/tests/template/template_includecss_test.php
index 4eb30eda1e..5f9875a556 100644
--- a/tests/template/template_includecss_test.php
+++ b/tests/template/template_includecss_test.php
@@ -35,7 +35,7 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te
new phpbb_mock_request()
),
$filesystem,
- $this->getMock('\phpbb\request\request'),
+ $this->createMock('\phpbb\request\request'),
$phpbb_root_path,
$phpEx
);
@@ -68,7 +68,7 @@ class phpbb_template_template_includecss_test extends phpbb_template_template_te
$twig,
$cache_path,
$this->user,
- array(new \phpbb\template\twig\extension($context, $this->user)),
+ array(new \phpbb\template\twig\extension($context, $twig, $this->user)),
new phpbb_mock_extension_manager(
dirname(__FILE__) . '/',
array(
diff --git a/tests/template/template_test.php b/tests/template/template_test.php
index 727f35e9d2..01c132e032 100644
--- a/tests/template/template_test.php
+++ b/tests/template/template_test.php
@@ -521,7 +521,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
$this->template->set_filenames(array('test' => $filename));
$this->assertFileNotExists($this->template_path . '/' . $filename, 'Testing missing file, file cannot exist');
- $this->setExpectedException('Twig_Error_Loader');
+ $this->expectException('Twig_Error_Loader');
$this->display('test');
}
@@ -529,7 +529,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
public function test_invalid_handle()
{
- $this->setExpectedException('Twig_Error_Loader');
+ $this->expectException('Twig_Error_Loader');
$this->display('test');
}
diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php
index 8adbafb1b2..0389088ec8 100644
--- a/tests/template/template_test_case.php
+++ b/tests/template/template_test_case.php
@@ -87,7 +87,7 @@ class phpbb_template_template_test_case extends phpbb_test_case
new phpbb_mock_request()
),
$filesystem,
- $this->getMock('\phpbb\request\request'),
+ $this->createMock('\phpbb\request\request'),
$phpbb_root_path,
$phpEx
);
@@ -113,12 +113,12 @@ class phpbb_template_template_test_case extends phpbb_test_case
'autoescape' => false,
)
);
- $this->template = new phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user)));
+ $this->template = new phpbb\template\twig\twig($path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $twig, $this->user)));
$twig->setLexer(new \phpbb\template\twig\lexer($twig));
$this->template->set_custom_style('tests', $this->template_path);
}
- protected function setUp()
+ protected function setUp(): void
{
// Test the engine can be used
$this->setup_engine();
@@ -130,7 +130,7 @@ class phpbb_template_template_test_case extends phpbb_test_case
$phpbb_filesystem = new \phpbb\filesystem\filesystem();
}
- protected function tearDown()
+ protected function tearDown(): void
{
if ($this->template)
{
diff --git a/tests/template/template_test_case_with_tree.php b/tests/template/template_test_case_with_tree.php
index 75e3918f44..c0238b6f03 100644
--- a/tests/template/template_test_case_with_tree.php
+++ b/tests/template/template_test_case_with_tree.php
@@ -29,7 +29,7 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat
new phpbb_mock_request()
),
$filesystem,
- $this->getMock('\phpbb\request\request'),
+ $this->createMock('\phpbb\request\request'),
$phpbb_root_path,
$phpEx
);
@@ -56,7 +56,7 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat
'autoescape' => false,
)
);
- $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $this->user)));
+ $this->template = new phpbb\template\twig\twig($this->phpbb_path_helper, $config, $context, $twig, $cache_path, $this->user, array(new \phpbb\template\twig\extension($context, $twig, $this->user)));
$twig->setLexer(new \phpbb\template\twig\lexer($twig));
$this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path));
}
diff --git a/tests/template/templates/avatar_user.html b/tests/template/templates/avatar_user.html
new file mode 100644
index 0000000000..bd0b960611
--- /dev/null
+++ b/tests/template/templates/avatar_user.html
@@ -0,0 +1 @@
+{{ avatar('user', row, alt, ignore_config, lazy) }}
diff --git a/tests/template/templates/expressions.html b/tests/template/templates/expressions.html
index e1283f165f..17a5b8d265 100644
--- a/tests/template/templates/expressions.html
+++ b/tests/template/templates/expressions.html
@@ -3,7 +3,7 @@
<!-- IF not 390 is even -->fail<!-- ELSE -->pass<!-- ENDIF -->
<!-- IF 9 is odd -->pass<!-- ELSE -->fail<!-- ENDIF -->
<!-- IF 32 is odd -->fail<!-- ELSE -->pass<!-- ENDIF -->
-<!-- IF 32 is div by 16 -->pass<!-- ELSE -->fail<!-- ENDIF -->
+<!-- IF 32 is divisible by(16) -->pass<!-- ELSE -->fail<!-- ENDIF -->
<!-- IF 10 is not even -->fail<!-- ELSE -->pass<!-- ENDIF -->
<!-- IF 24 == 24 -->pass<!-- ELSE -->fail<!-- ENDIF -->
<!-- IF 24 eq 24 -->pass<!-- ELSE -->fail<!-- ENDIF -->
diff --git a/tests/template/templates/extension_config_test.html b/tests/template/templates/extension_config_test.html
new file mode 100644
index 0000000000..0f12ab2672
--- /dev/null
+++ b/tests/template/templates/extension_config_test.html
@@ -0,0 +1 @@
+{{ config(config_name) }}
diff --git a/tests/template/templates/extension_username_test.html b/tests/template/templates/extension_username_test.html
new file mode 100644
index 0000000000..a78bf0df62
--- /dev/null
+++ b/tests/template/templates/extension_username_test.html
@@ -0,0 +1 @@
+{{ username(mode, user_id, username, user_colour, guest_username, custom_profile_url) }}
diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php
index 606c40a623..c098ff64bd 100644
--- a/tests/test_framework/phpbb_database_test_case.php
+++ b/tests/test_framework/phpbb_database_test_case.php
@@ -11,7 +11,9 @@
*
*/
-abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_TestCase
+use PHPUnit\DbUnit\TestCase;
+
+abstract class phpbb_database_test_case extends TestCase
{
static private $already_connected;
@@ -31,10 +33,10 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
{
parent::__construct($name, $data, $dataName);
$this->backupStaticAttributesBlacklist += array(
- 'PHP_CodeCoverage' => array('instance'),
- 'PHP_CodeCoverage_Filter' => array('instance'),
- 'PHP_CodeCoverage_Util' => array('ignoredLines', 'templateMethods'),
- 'PHP_Timer' => array('startTimes',),
+ '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'),
@@ -99,7 +101,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
parent::tearDownAfterClass();
}
- protected function tearDown()
+ protected function tearDown(): void
{
parent::tearDown();
@@ -113,7 +115,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
}
}
- protected function setUp()
+ protected function setUp(): void
{
parent::setUp();
@@ -146,7 +148,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
* Create xml data set for insertion into database
*
* @param string $path Path to fixture XML
- * @return PHPUnit_Extensions_Database_DataSet_DefaultDataSet|PHPUnit_Extensions_Database_DataSet_XmlDataSet
+ * @return PHPUnit\DbUnit\DataSet\DefaultDataSet|PHPUnit\DbUnit\DataSet\XmlDataSet
*/
public function createXMLDataSet($path)
{
@@ -155,11 +157,11 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
// Extend XML data set on MSSQL
if (strpos($this->get_database_config()['dbms'], 'mssql') !== false)
{
- $newXmlData = new PHPUnit_Extensions_Database_DataSet_DefaultDataSet();
+ $newXmlData = new PHPUnit\DbUnit\DataSet\DefaultDataSet([]);
$db = $this->new_dbal();
foreach ($this->fixture_xml_data as $key => $value)
{
- /** @var \PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData $tableMetaData */
+ /** @var PHPUnit\DbUnit\DataSet\DefaultTableMetaData $tableMetaData */
$tableMetaData = $value->getTableMetaData();
$columns = $tableMetaData->getColumns();
$primaryKeys = $tableMetaData->getPrimaryKeys();
@@ -201,8 +203,8 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
$columns[] = 'mssqlindex';
}
- $newMetaData = new PHPUnit_Extensions_Database_DataSet_DefaultTableMetaData($key, $columns, $primaryKeys);
- $newTable = new PHPUnit_Extensions_Database_DataSet_DefaultTable($newMetaData);
+ $newMetaData = new PHPUnit\DbUnit\DataSet\DefaultTableMetaData($key, $columns, $primaryKeys);
+ $newTable = new PHPUnit\DbUnit\DataSet\DefaultTable($newMetaData);
for ($i = 0; $i < $value->getRowCount(); $i++)
{
$dataRow = $value->getRow($i);
diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php
index f3adbefc1b..fec4709fbd 100644
--- a/tests/test_framework/phpbb_database_test_connection_manager.php
+++ b/tests/test_framework/phpbb_database_test_connection_manager.php
@@ -150,7 +150,6 @@ class phpbb_database_test_connection_manager
switch ($this->config['dbms'])
{
- case 'phpbb\db\driver\mysql':
case 'phpbb\db\driver\mysqli':
$this->pdo->exec('SET NAMES utf8');
@@ -270,7 +269,6 @@ class phpbb_database_test_connection_manager
switch ($this->config['dbms'])
{
- case 'phpbb\db\driver\mysql':
case 'phpbb\db\driver\mysqli':
$sql = 'SHOW TABLES';
break;
@@ -336,14 +334,7 @@ class phpbb_database_test_connection_manager
$sth = $this->pdo->query('SELECT VERSION() AS version');
$row = $sth->fetch(PDO::FETCH_ASSOC);
- if (version_compare($row['version'], '4.1.3', '>='))
- {
- $schema .= '_41';
- }
- else
- {
- $schema .= '_40';
- }
+ $schema .= '_41';
}
$filename = $directory . $schema . '_schema.sql';
@@ -424,11 +415,6 @@ class phpbb_database_test_connection_manager
'DELIM' => ';',
'PDO' => 'mysql',
),
- 'phpbb\db\driver\mysql' => array(
- 'SCHEMA' => 'mysql',
- 'DELIM' => ';',
- 'PDO' => 'mysql',
- ),
'phpbb\db\driver\mssql' => array(
'SCHEMA' => 'mssql',
'DELIM' => 'GO',
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index f1b30f0fed..a31aa648bc 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()
+ public function setUp(): void
{
parent::setUp();
@@ -114,7 +114,7 @@ class phpbb_functional_test_case extends phpbb_test_case
}
}
- protected function tearDown()
+ protected function tearDown(): void
{
parent::tearDown();
@@ -234,7 +234,7 @@ class phpbb_functional_test_case extends phpbb_test_case
{
global $phpbb_root_path, $phpEx;
- $config = new \phpbb\config\config(array());
+ $config = new \phpbb\config\config(array('version' => PHPBB_VERSION));
$db = $this->get_db();
$factory = new \phpbb\db\tools\factory();
$db_tools = $factory->get($db);
@@ -424,9 +424,9 @@ class phpbb_functional_test_case extends phpbb_test_case
$ext_path = str_replace('/', '%2F', $extension);
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=' . $ext_path . '&sid=' . $this->sid);
- $this->assertGreaterThan(0, $crawler->filter('.submit-buttons')->count());
+ $this->assertGreaterThan(1, $crawler->filter('div.main fieldset div input.button2')->count());
- $form = $crawler->selectButton('Enable')->form();
+ $form = $crawler->selectButton('confirm')->form();
$crawler = self::submit($form);
$this->add_lang('acp/extensions');
@@ -446,6 +446,72 @@ class phpbb_functional_test_case extends phpbb_test_case
$this->logout();
}
+ public function disable_ext($extension)
+ {
+ $this->login();
+ $this->admin_login();
+
+ $ext_path = str_replace('/', '%2F', $extension);
+
+ $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=' . $ext_path . '&sid=' . $this->sid);
+ $this->assertGreaterThan(1, $crawler->filter('div.main fieldset div input.button2')->count());
+
+ $form = $crawler->selectButton('confirm')->form();
+ $crawler = self::submit($form);
+ $this->add_lang('acp/extensions');
+
+ $meta_refresh = $crawler->filter('meta[http-equiv="refresh"]');
+
+ // Wait for extension to be fully enabled
+ while (count($meta_refresh))
+ {
+ preg_match('#url=.+/(adm+.+)#', $meta_refresh->attr('content'), $match);
+ $url = $match[1];
+ $crawler = self::request('POST', $url);
+ $meta_refresh = $crawler->filter('meta[http-equiv="refresh"]');
+ }
+
+ $this->assertContainsLang('EXTENSION_DISABLE_SUCCESS', $crawler->filter('div.successbox')->text());
+
+ $this->logout();
+ }
+
+ public function delete_ext_data($extension)
+ {
+ $this->login();
+ $this->admin_login();
+
+ $ext_path = str_replace('/', '%2F', $extension);
+
+ $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=' . $ext_path . '&sid=' . $this->sid);
+ $this->assertGreaterThan(1, $crawler->filter('div.main fieldset div input.button2')->count());
+
+ $form = $crawler->selectButton('confirm')->form();
+ $crawler = self::submit($form);
+ $this->add_lang('acp/extensions');
+
+ $meta_refresh = $crawler->filter('meta[http-equiv="refresh"]');
+
+ // Wait for extension to be fully enabled
+ while (count($meta_refresh))
+ {
+ preg_match('#url=.+/(adm+.+)#', $meta_refresh->attr('content'), $match);
+ $url = $match[1];
+ $crawler = self::request('POST', $url);
+ $meta_refresh = $crawler->filter('meta[http-equiv="refresh"]');
+ }
+
+ $this->assertContainsLang('EXTENSION_DELETE_DATA_SUCCESS', $crawler->filter('div.successbox')->text());
+
+ $this->logout();
+ }
+
+ public function uninstall_ext($extension)
+ {
+ $this->disable_ext($extension);
+ $this->delete_ext_data($extension);
+ }
+
static private function recreate_database($config)
{
$db_conn_mgr = new phpbb_database_test_connection_manager($config);
@@ -651,11 +717,11 @@ class phpbb_functional_test_case extends phpbb_test_case
$db = $this->get_db();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
- $user = $this->getMock('\phpbb\user', array(), array(
+ $user = $this->createMock('\phpbb\user', array(), array(
new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
'\phpbb\datetime'
));
- $auth = $this->getMock('\phpbb\auth\auth');
+ $auth = $this->createMock('\phpbb\auth\auth');
$phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
$cache = new phpbb_mock_null_cache;
@@ -688,17 +754,17 @@ class phpbb_functional_test_case extends phpbb_test_case
$db = $this->get_db();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
- $user = $this->getMock('\phpbb\user', array(), array(
+ $user = $this->createMock('\phpbb\user', array(), array(
new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
'\phpbb\datetime'
));
- $auth = $this->getMock('\phpbb\auth\auth');
+ $auth = $this->createMock('\phpbb\auth\auth');
$phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
$cache = new phpbb_mock_null_cache;
$cache_driver = new \phpbb\cache\driver\dummy();
- $phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
+ $phpbb_container = $this->createMock('Symfony\Component\DependencyInjection\ContainerInterface');
$phpbb_container
->expects($this->any())
->method('get')
@@ -863,7 +929,7 @@ class phpbb_functional_test_case extends phpbb_test_case
* @param string $haystack Search this
* @param string $message Optional failure message
*/
- public function assertContainsLang($needle, $haystack, $message = null)
+ public function assertContainsLang($needle, $haystack, $message = '')
{
$this->assertContains(html_entity_decode($this->lang($needle), ENT_QUOTES), $haystack, $message);
}
@@ -875,7 +941,7 @@ class phpbb_functional_test_case extends phpbb_test_case
* @param string $haystack Search this
* @param string $message Optional failure message
*/
- public function assertNotContainsLang($needle, $haystack, $message = null)
+ public function assertNotContainsLang($needle, $haystack, $message = '')
{
$this->assertNotContains(html_entity_decode($this->lang($needle), ENT_QUOTES), $haystack, $message);
}
diff --git a/tests/test_framework/phpbb_session_test_case.php b/tests/test_framework/phpbb_session_test_case.php
index b3d7780d14..530d8c6b48 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()
+ function setUp(): void
{
parent::setUp();
@@ -37,7 +37,7 @@ abstract class phpbb_session_test_case extends phpbb_database_test_case
$phpbb_path_helper = new \phpbb\path_helper(
$symfony_request,
$phpbb_filesystem,
- $this->getMock('\phpbb\request\request'),
+ $this->createMock('\phpbb\request\request'),
$phpbb_root_path,
$phpEx
);
@@ -48,11 +48,33 @@ abstract class phpbb_session_test_case extends phpbb_database_test_case
new phpbb_session_testable_facade($this->db, $this->session_factory);
}
+ protected function check_user_session_data($expected_session_data, $message)
+ {
+ $sql= 'SELECT username_clean, user_lastvisit, user_lastpage
+ FROM ' . USERS_TABLE . '
+ ORDER BY user_id';
+
+ $this->assertSqlResultEquals($expected_session_data, $sql, $message);
+ }
+
+ protected function check_expired_sessions_recent($expected_sessions, $message)
+ {
+ global $config;
+ $time_now = time();
+ $sql = 'SELECT session_user_id, MAX(session_time) AS recent_time
+ FROM ' . SESSIONS_TABLE . '
+ WHERE session_time < ' . ($time_now - (int) $config['session_length']) . '
+ AND session_user_id <> ' . ANONYMOUS . '
+ GROUP BY session_user_id';
+
+ $this->assertSqlResultEquals($expected_sessions, $sql, $message);
+ }
+
protected function check_sessions_equals($expected_sessions, $message)
{
$sql = 'SELECT session_id, session_user_id
FROM phpbb_sessions
- ORDER BY session_user_id';
+ ORDER BY session_user_id, session_id';
$this->assertSqlResultEquals($expected_sessions, $sql, $message);
}
diff --git a/tests/test_framework/phpbb_test_case.php b/tests/test_framework/phpbb_test_case.php
index 01d26fb67d..8e09f17ede 100644
--- a/tests/test_framework/phpbb_test_case.php
+++ b/tests/test_framework/phpbb_test_case.php
@@ -11,7 +11,9 @@
*
*/
-class phpbb_test_case extends PHPUnit_Framework_TestCase
+use PHPUnit\Framework\TestCase;
+
+class phpbb_test_case extends TestCase
{
protected $test_case_helpers;
@@ -19,10 +21,10 @@ class phpbb_test_case extends PHPUnit_Framework_TestCase
{
parent::__construct($name, $data, $dataName);
$this->backupStaticAttributesBlacklist += array(
- 'PHP_CodeCoverage' => array('instance'),
- 'PHP_CodeCoverage_Filter' => array('instance'),
- 'PHP_CodeCoverage_Util' => array('ignoredLines', 'templateMethods'),
- 'PHP_Timer' => array('startTimes',),
+ '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'),
diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php
index c792976b1e..9a2ea275d0 100644
--- a/tests/test_framework/phpbb_test_case_helpers.php
+++ b/tests/test_framework/phpbb_test_case_helpers.php
@@ -81,21 +81,26 @@ class phpbb_test_case_helpers
{
case E_NOTICE:
case E_STRICT:
- PHPUnit_Framework_Error_Notice::$enabled = true;
- $exceptionName = 'PHPUnit_Framework_Error_Notice';
+ PHPUnit\Framework\Error\Notice::$enabled = true;
+ $exceptionName = 'PHPUnit\Framework\Error\Notice';
break;
case E_WARNING:
- PHPUnit_Framework_Error_Warning::$enabled = true;
- $exceptionName = 'PHPUnit_Framework_Error_Warning';
+ PHPUnit\Framework\Error\Warning::$enabled = true;
+ $exceptionName = 'PHPUnit\Framework\Error\Warning';
break;
default:
- $exceptionName = 'PHPUnit_Framework_Error';
+ $exceptionName = 'PHPUnit\Framework\Error\Error';
break;
}
$this->expectedTriggerError = true;
- $this->test_case->setExpectedException($exceptionName, (string) $message, $errno);
+ $this->test_case->expectException($exceptionName);
+ $this->test_case->expectExceptionCode($errno);
+ if ($message)
+ {
+ $this->test_case->expectExceptionMessage((string) $message);
+ }
}
public function makedirs($path)
@@ -168,6 +173,16 @@ class phpbb_test_case_helpers
{
$config['fulltext_sphinx_id'] = $fulltext_sphinx_id;
}
+
+ if (isset($phpbb_memcached_host))
+ {
+ $config['memcached_host'] = $phpbb_memcached_host;
+ }
+
+ if (isset($phpbb_memcached_port))
+ {
+ $config['memcached_port'] = $phpbb_memcached_port;
+ }
}
if (isset($_SERVER['PHPBB_TEST_DBMS']))
@@ -200,6 +215,16 @@ class phpbb_test_case_helpers
$config['redis_port'] = $_SERVER['PHPBB_TEST_REDIS_PORT'];
}
+ if (isset($_SERVER['PHPBB_TEST_MEMCACHED_HOST']))
+ {
+ $config['memcached_host'] = $_SERVER['PHPBB_TEST_MEMCACHED_HOST'];
+ }
+
+ if (isset($_SERVER['PHPBB_TEST_MEMCACHED_PORT']))
+ {
+ $config['memcached_port'] = $_SERVER['PHPBB_TEST_MEMCACHED_PORT'];
+ }
+
return $config;
}
@@ -382,10 +407,16 @@ class phpbb_test_case_helpers
}
// Mock the DAL, make it return data from the fixture
+ $db_driver = $this->test_case->getMockBuilder('phpbb\\db\\driver\\driver')
+ ->disableOriginalConstructor()
+ ->disableOriginalClone()
+ ->disableArgumentCloning()
+ ->disallowMockingUnknownTypes()
+ ->getMock();
$mb = $this->test_case->getMockBuilder('phpbb\\textformatter\\data_access');
$mb->setMethods(array('get_bbcodes', 'get_censored_words', 'get_smilies', 'get_styles'));
$mb->setConstructorArgs(array(
- $this->test_case->getMockBuilder('phpbb\\db\\driver\\driver')->getMock(),
+ $db_driver,
'phpbb_bbcodes',
'phpbb_smilies',
'phpbb_styles',
diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php
index 48e510abe3..243db39d69 100644
--- a/tests/test_framework/phpbb_ui_test_case.php
+++ b/tests/test_framework/phpbb_ui_test_case.php
@@ -53,15 +53,10 @@ class phpbb_ui_test_case extends phpbb_test_case
{
parent::setUpBeforeClass();
- if (version_compare(PHP_VERSION, '5.3.19', '<'))
- {
- self::markTestSkipped('UI test case requires at least PHP 5.3.19.');
- }
- else if (!class_exists('\Facebook\WebDriver\Remote\RemoteWebDriver'))
+ if (!class_exists('\Facebook\WebDriver\Remote\RemoteWebDriver'))
{
self::markTestSkipped(
- 'Could not find RemoteWebDriver class. ' .
- 'Run "php ../composer.phar install" from the tests folder.'
+ 'Could not find RemoteWebDriver class.'
);
}
@@ -108,7 +103,7 @@ class phpbb_ui_test_case extends phpbb_test_case
return array();
}
- public function setUp()
+ public function setUp(): void
{
if (!self::$install_success)
{
@@ -140,7 +135,7 @@ class phpbb_ui_test_case extends phpbb_test_case
}
}
- protected function tearDown()
+ protected function tearDown(): void
{
parent::tearDown();
@@ -344,9 +339,9 @@ class phpbb_ui_test_case extends phpbb_test_case
$ext_path = str_replace('/', '%2F', $extension);
$this->visit('adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=' . $ext_path . '&sid=' . $this->sid);
- $this->assertNotEmpty(count($this->find_element('cssSelector', '.submit-buttons')));
+ $this->assertNotEmpty(count($this->find_element('cssSelector', 'div.main fieldset div input.button2')));
- $this->find_element('cssSelector', "input[value='Enable']")->submit();
+ $this->find_element('cssSelector', "input[value='Yes']")->submit();
$this->add_lang('acp/extensions');
try
@@ -371,6 +366,82 @@ class phpbb_ui_test_case extends phpbb_test_case
$this->logout();
}
+ public function disable_ext($extension)
+ {
+ $this->login();
+ $this->admin_login();
+
+ $ext_path = str_replace('/', '%2F', $extension);
+
+ $this->visit('adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=' . $ext_path . '&sid=' . $this->sid);
+ $this->assertNotEmpty(count($this->find_element('cssSelector', 'div.main fieldset div input.button2')));
+
+ $this->find_element('cssSelector', "input[value='Yes']")->submit();
+ $this->add_lang('acp/extensions');
+
+ try
+ {
+ $meta_refresh = $this->find_element('cssSelector', 'meta[http-equiv="refresh"]');
+
+ // Wait for extension to be fully enabled
+ while (count($meta_refresh))
+ {
+ preg_match('#url=.+/(adm+.+)#', $meta_refresh->getAttribute('content'), $match);
+ $this->getDriver()->execute(array('method' => 'post', 'url' => $match[1]));
+ $meta_refresh = $this->find_element('cssSelector', 'meta[http-equiv="refresh"]');
+ }
+ }
+ catch (\Facebook\WebDriver\Exception\NoSuchElementException $e)
+ {
+ // Probably no refresh triggered
+ }
+
+ $this->assertContainsLang('EXTENSION_DISABLE_SUCCESS', $this->find_element('cssSelector', 'div.successbox')->getText());
+
+ $this->logout();
+ }
+
+ public function delete_ext_data($extension)
+ {
+ $this->login();
+ $this->admin_login();
+
+ $ext_path = str_replace('/', '%2F', $extension);
+
+ $this->visit('adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=' . $ext_path . '&sid=' . $this->sid);
+ $this->assertNotEmpty(count($this->find_element('cssSelector', 'div.main fieldset div input.button2')));
+
+ $this->find_element('cssSelector', "input[value='Yes']")->submit();
+ $this->add_lang('acp/extensions');
+
+ try
+ {
+ $meta_refresh = $this->find_element('cssSelector', 'meta[http-equiv="refresh"]');
+
+ // Wait for extension to be fully enabled
+ while (count($meta_refresh))
+ {
+ preg_match('#url=.+/(adm+.+)#', $meta_refresh->getAttribute('content'), $match);
+ $this->getDriver()->execute(array('method' => 'post', 'url' => $match[1]));
+ $meta_refresh = $this->find_element('cssSelector', 'meta[http-equiv="refresh"]');
+ }
+ }
+ catch (\Facebook\WebDriver\Exception\NoSuchElementException $e)
+ {
+ // Probably no refresh triggered
+ }
+
+ $this->assertContainsLang('EXTENSION_DELETE_DATA_SUCCESS', $this->find_element('cssSelector', 'div.successbox')->getText());
+
+ $this->logout();
+ }
+
+ public function uninstall_ext($extension)
+ {
+ $this->disable_ext($extension);
+ $this->delete_ext_data($extension);
+ }
+
protected function get_cache_driver()
{
if (!$this->cache)
@@ -402,7 +473,8 @@ class phpbb_ui_test_case extends phpbb_test_case
$config = new \phpbb\config\config(array());
$db = $this->get_db();
- $db_tools = new \phpbb\db\tools($db);
+ $factory = new \phpbb\db\tools\factory();
+ $db_tools = $factory->get($this->db);
$container = new phpbb_mock_container_builder();
$migrator = new \phpbb\db\migrator(
diff --git a/tests/text_formatter/s9e/acp_utils_test.php b/tests/text_formatter/s9e/acp_utils_test.php
new file mode 100644
index 0000000000..9d84924042
--- /dev/null
+++ b/tests/text_formatter/s9e/acp_utils_test.php
@@ -0,0 +1,79 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+class phpbb_textformatter_s9e_acp_utils_test extends phpbb_test_case
+{
+ /**
+ * @dataProvider get_analyse_bbcode_tests
+ */
+ public function test_analyse_bbcode($definition, $template, $expected)
+ {
+ $container = $this->get_test_case_helpers()->set_s9e_services();
+ $factory = $container->get('text_formatter.s9e.factory');
+ $acp_utils = new \phpbb\textformatter\s9e\acp_utils($factory);
+ $actual = $acp_utils->analyse_bbcode($definition, $template);
+
+ $this->assertEquals($expected, $actual);
+ }
+
+ public function get_analyse_bbcode_tests()
+ {
+ return [
+ [
+ '[x]{TEXT}[/x]',
+ '<b>{TEXT}</b>',
+ [
+ 'status' => 'safe',
+ 'name' => 'X'
+ ]
+ ],
+ [
+ '[hr]',
+ '<hr>',
+ [
+ 'status' => 'safe',
+ 'name' => 'HR'
+ ]
+ ],
+ [
+ '[x]{TEXT}[/x]',
+ '<script>{TEXT}</script>',
+ [
+ 'status' => 'unsafe',
+ 'name' => 'X',
+ 'error_text' => 'Cannot allow unfiltered data in this context',
+ 'error_html' => '&lt;script&gt;
+ <span class="highlight">&lt;xsl:apply-templates/&gt;</span>
+&lt;/script&gt;'
+ ]
+ ],
+ [
+ '???',
+ '<hr>',
+ [
+ 'status' => 'invalid_definition',
+ 'error_text' => 'Cannot interpret the BBCode definition'
+ ]
+ ],
+ [
+ '[x]{TEXT}[/x]',
+ '<xsl:invalid',
+ [
+ 'status' => 'invalid_template',
+ 'name' => 'X',
+ 'error_text' => "Invalid XSL: Couldn't find end of Start Tag invalid line 1\n"
+ ]
+ ],
+ ];
+ }
+}
diff --git a/tests/text_formatter/s9e/factory_test.php b/tests/text_formatter/s9e/factory_test.php
index 0d780a19a9..d3be7d2fb4 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()
+ public function setUp(): void
{
$this->cache = new phpbb_mock_cache;
$this->dispatcher = new phpbb_mock_event_dispatcher;
@@ -286,7 +286,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
*/
public function test_configure_events()
{
- $this->dispatcher = $this->getMock('phpbb\\event\\dispatcher_interface');
+ $this->dispatcher = $this->createMock('phpbb\\event\\dispatcher_interface');
$this->dispatcher
->expects($this->at(0))
->method('trigger_event')
diff --git a/tests/text_formatter/s9e/parser_test.php b/tests/text_formatter/s9e/parser_test.php
index 4b9bbf9bb2..e10ebd29ee 100644
--- a/tests/text_formatter/s9e/parser_test.php
+++ b/tests/text_formatter/s9e/parser_test.php
@@ -19,7 +19,7 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case
->disableOriginalConstructor()
->getMock();
- $cache = $this->getMock('phpbb_mock_cache');
+ $cache = $this->createMock('phpbb_mock_cache');
$cache->expects($this->once())
->method('get')
->with('_foo_parser')
@@ -172,7 +172,7 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case
public function test_setup_event()
{
$container = $this->get_test_case_helpers()->set_s9e_services();
- $dispatcher = $this->getMock('phpbb\\event\\dispatcher_interface');
+ $dispatcher = $this->createMock('phpbb\\event\\dispatcher_interface');
$dispatcher
->expects($this->once())
->method('trigger_event')
@@ -202,7 +202,7 @@ class phpbb_textformatter_s9e_parser_test extends phpbb_test_case
public function test_parse_event()
{
$container = $this->get_test_case_helpers()->set_s9e_services();
- $dispatcher = $this->getMock('phpbb\\event\\dispatcher_interface');
+ $dispatcher = $this->createMock('phpbb\\event\\dispatcher_interface');
$dispatcher
->expects($this->any())
->method('trigger_event')
diff --git a/tests/text_formatter/s9e/renderer_test.php b/tests/text_formatter/s9e/renderer_test.php
index 175b90fdc7..672069590a 100644
--- a/tests/text_formatter/s9e/renderer_test.php
+++ b/tests/text_formatter/s9e/renderer_test.php
@@ -26,7 +26,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
'<?php class renderer_foo { public function setParameter() {} }'
);
- $cache = $this->getMock('phpbb_mock_cache');
+ $cache = $this->createMock('phpbb_mock_cache');
$cache->expects($this->once())
->method('get')
->with('_foo_renderer')
@@ -50,7 +50,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
{
$mock = $this->getMockForAbstractClass('s9e\\TextFormatter\\Renderer');
- $cache = $this->getMock('phpbb_mock_cache');
+ $cache = $this->createMock('phpbb_mock_cache');
$cache->expects($this->once())
->method('get')
->with('_foo_renderer')
@@ -197,7 +197,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
$config = new \phpbb\config\config(array('allow_nocensors' => true));
- $auth = $test->getMock('phpbb\\auth\\auth');
+ $auth = $test->createMock('phpbb\\auth\\auth');
$auth->expects($test->any())
->method('acl_get')
->with('u_chgcensors')
@@ -393,7 +393,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
public function test_setup_event()
{
$container = $this->get_test_case_helpers()->set_s9e_services();
- $dispatcher = $this->getMock('phpbb\\event\\dispatcher_interface');
+ $dispatcher = $this->createMock('phpbb\\event\\dispatcher_interface');
$dispatcher
->expects($this->once())
->method('trigger_event')
@@ -424,7 +424,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
public function test_render_event()
{
$container = $this->get_test_case_helpers()->set_s9e_services();
- $dispatcher = $this->getMock('phpbb\\event\\dispatcher_interface');
+ $dispatcher = $this->createMock('phpbb\\event\\dispatcher_interface');
$dispatcher
->expects($this->any())
->method('trigger_event')
diff --git a/tests/text_processing/decode_message_test.php b/tests/text_processing/decode_message_test.php
index e2402e721a..805dd89039 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()
+ public 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 86bc803c98..f7da27cc35 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()
+ public function setUp(): void
{
global $cache, $user, $phpbb_dispatcher;
@@ -77,7 +77,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca
$config = new \phpbb\config\config(array('allow_nocensors' => true));
- $auth = $this->getMock('phpbb\\auth\\auth');
+ $auth = $this->createMock('phpbb\\auth\\auth');
$auth->expects($this->any())
->method('acl_get')
->with('u_chgcensors')
diff --git a/tests/text_processing/generate_text_for_storage_test.php b/tests/text_processing/generate_text_for_storage_test.php
index f0588fec4f..c6c62c7579 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()
+ public function setUp(): void
{
global $config, $phpbb_container, $phpbb_dispatcher;
diff --git a/tests/text_reparser/base_test.php b/tests/text_reparser/base_test.php
index 2c6844b063..59604da4e3 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()
+ public 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 df6adacb66..afa557deff 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()
+ public 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 757b02be39..690d3a4046 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()
+ public 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 177faac51d..32fb8a0411 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()
+ public 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 3e9ff09448..cf913c9c1e 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()
+ public 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 498c6a69a2..e91e816b2a 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()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/upload/filespec_test.php b/tests/upload/filespec_test.php
index b41b95d925..656b801372 100644
--- a/tests/upload/filespec_test.php
+++ b/tests/upload/filespec_test.php
@@ -28,7 +28,7 @@ class phpbb_filespec_test extends phpbb_test_case
/** @var string phpBB root path */
protected $phpbb_root_path;
- protected function setUp()
+ protected function setUp(): void
{
// Global $config required by unique_id
global $config, $phpbb_root_path, $phpEx;
@@ -101,7 +101,7 @@ class phpbb_filespec_test extends phpbb_test_case
return $filespec->set_upload_ary(array_merge($upload_ary, $override));
}
- protected function tearDown()
+ protected function tearDown(): void
{
$this->config = array();
@@ -420,7 +420,7 @@ class phpbb_filespec_test extends phpbb_test_case
/**
* @dataProvider data_move_file_copy
*/
- public function test_move_file_copy($tmp_name, $move_success, $safe_mode_on, $expected_error)
+ public function test_move_file_copy($tmp_name, $move_success, $open_basedir_on, $expected_error)
{
// Initialise a blank filespec object for use with trivial methods
$upload_ary = array(
@@ -436,7 +436,7 @@ class phpbb_filespec_test extends phpbb_test_case
$php_ini->expects($this->any())
->method('getBool')
->with($this->anything())
- ->willReturn($safe_mode_on);
+ ->willReturn($open_basedir_on);
$upload = new phpbb_mock_fileupload();
$upload->max_filesize = self::UPLOAD_MAX_FILESIZE;
$filespec = new \phpbb\files\filespec($this->filesystem, $this->language, $php_ini, new \FastImageSize\FastImagesize, '', $this->mimetype_guesser);
diff --git a/tests/upload/fileupload_test.php b/tests/upload/fileupload_test.php
index 5b3357237d..ca9259d357 100644
--- a/tests/upload/fileupload_test.php
+++ b/tests/upload/fileupload_test.php
@@ -37,7 +37,7 @@ class phpbb_fileupload_test extends phpbb_test_case
/** @var string phpBB root path */
protected $phpbb_root_path;
- protected function setUp()
+ protected function setUp(): void
{
// Global $config required by unique_id
global $config, $phpbb_root_path, $phpEx;
@@ -50,7 +50,7 @@ class phpbb_fileupload_test extends phpbb_test_case
$config['rand_seed'] = '';
$config['rand_seed_last_update'] = time() + 600;
- $this->request = $this->getMock('\phpbb\request\request');
+ $this->request = $this->createMock('\phpbb\request\request');
$this->php_ini = new \bantu\IniGetWrapper\IniGetWrapper;
$this->filesystem = new \phpbb\filesystem\filesystem();
@@ -83,13 +83,13 @@ class phpbb_fileupload_test extends phpbb_test_case
$this->php_ini,
$plupload,
$this->request
- ), phpbb_mock_container_builder::SCOPE_PROTOTYPE);
+ ));
$this->container->set('files.types.local', new \phpbb\files\types\local(
$this->factory,
$this->language,
$this->php_ini,
$this->request
- ), phpbb_mock_container_builder::SCOPE_PROTOTYPE);
+ ));
$this->path = __DIR__ . '/fixture/';
$this->phpbb_root_path = $phpbb_root_path;
@@ -107,7 +107,7 @@ class phpbb_fileupload_test extends phpbb_test_case
return $filespec;
}
- protected function tearDown()
+ protected function tearDown(): void
{
// Clear globals
global $config, $user;
diff --git a/tests/upload/imagesize_test.php b/tests/upload/imagesize_test.php
index 5429bb5c5e..3adf61dedc 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()
+ public 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 f871f324ca..f283e993dc 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()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/version/version_fetch_test.php b/tests/version/version_fetch_test.php
index c44bd5514a..4e8e82567a 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()
+ public function setUp(): void
{
parent::setUp();
@@ -42,7 +42,7 @@ class phpbb_version_helper_fetch_test extends phpbb_test_case
global $phpbb_root_path, $phpEx;
include_once($phpbb_root_path . 'includes/functions.' . $phpEx);
- if (!phpbb_checkdnsrr('version.phpbb.com', 'A'))
+ if (!checkdnsrr('version.phpbb.com', 'A'))
{
$this->markTestSkipped(sprintf(
'Could not find a DNS record for hostname %s. ' .
diff --git a/tests/version/version_helper_remote_test.php b/tests/version/version_helper_remote_test.php
index 35c3d92a3a..e15ff897b0 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()
+ public function setUp(): void
{
parent::setUp();
@@ -30,7 +30,11 @@ class version_helper_remote_test extends \phpbb_test_case
));
$container = new \phpbb_mock_container_builder();
$db = new \phpbb\db\driver\factory($container);
- $this->cache = $this->getMock('\phpbb\cache\service', array('get'), array(new \phpbb\cache\driver\dummy(), $config, $db, '../../', 'php'));
+ $this->cache = $this->getMockBuilder('\phpbb\cache\service')
+ ->setMethods(array('get'))
+ ->setConstructorArgs(array(new \phpbb\cache\driver\dummy(), $config, $db, '../../', 'php'))
+ ->getMock();
+
$this->cache->expects($this->any())
->method('get')
->with($this->anything())
diff --git a/tests/version/version_test.php b/tests/version/version_test.php
index 2a0240f847..3298213487 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()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/viewonline/helper_test.php b/tests/viewonline/helper_test.php
index 6540d33287..d7c9965ad1 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()
+ public function setUp(): void
{
parent::setUp();
diff --git a/tests/wrapper/phpbb_php_ini_test.php b/tests/wrapper/phpbb_php_ini_test.php
index 5827744702..d6ce11219f 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()
+ public function setUp(): void
{
$this->php_ini = new phpbb_php_ini_fake;
}