aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/content_visibility/delete_post_test.php3
-rw-r--r--tests/content_visibility/get_forums_visibility_sql_test.php3
-rw-r--r--tests/content_visibility/get_global_visibility_sql_test.php3
-rw-r--r--tests/content_visibility/get_visibility_sql_test.php3
-rw-r--r--tests/content_visibility/set_post_visibility_test.php6
-rw-r--r--tests/content_visibility/set_topic_visibility_test.php3
-rw-r--r--tests/controller/config/test/routing/environment.yml2
-rw-r--r--tests/controller/ext/vendor2/foo/config/routing.yml2
-rw-r--r--tests/controller/ext/vendor2/foo/config/routing_2.yml4
-rw-r--r--tests/controller/ext/vendor2/foo/subfolder/config/routing.yml2
-rw-r--r--tests/dbal/auto_increment_test.php2
-rw-r--r--tests/dbal/db_tools_test.php15
-rw-r--r--tests/dbal/migrator_test.php10
-rw-r--r--tests/error_collector_test.php30
-rw-r--r--tests/event/exception_listener_test.php100
-rw-r--r--tests/extension/manager_test.php6
-rw-r--r--tests/extension/metadata_manager_test.php6
-rw-r--r--tests/functional/acp_profile_field_test.php71
-rw-r--r--tests/functional/fileupload_form_test.php23
-rw-r--r--tests/functional/fixtures/ext/foo/bar/config/routing.yml18
-rw-r--r--tests/functional/fixtures/ext/foo/foo/config/resource.yml2
-rw-r--r--tests/functional/prune_shadow_topic_test.php2
-rw-r--r--tests/functions/get_remote_file_test.php2
-rw-r--r--tests/functions/make_clickable_test.php84
-rw-r--r--tests/migrator/convert_timezones_test.php6
-rw-r--r--tests/migrator/schema_generator_test.php2
-rw-r--r--tests/mock/file_downloader.php27
-rw-r--r--tests/mock/metadata_manager.php2
-rw-r--r--tests/notification/base.php3
-rw-r--r--tests/notification/convert_test.php2
-rw-r--r--tests/notification/submit_post_base.php5
-rw-r--r--tests/pagination/config/test/routing/environment.yml4
-rw-r--r--tests/path_helper/path_helper_test.php40
-rw-r--r--tests/profilefields/type_string_test.php24
-rw-r--r--tests/profilefields/type_url_test.php40
-rw-r--r--tests/regex/url_test.php2
-rw-r--r--tests/test_framework/phpbb_database_test_case.php2
-rw-r--r--tests/test_framework/phpbb_database_test_connection_manager.php4
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php6
-rw-r--r--tests/version/version_helper_remote_test.php173
40 files changed, 677 insertions, 67 deletions
diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php
index 65dda3ce48..6ad6351a0c 100644
--- a/tests/content_visibility/delete_post_test.php
+++ b/tests/content_visibility/delete_post_test.php
@@ -296,6 +296,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
$phpbb_config = new \phpbb\config\config(array('num_posts' => 3, 'num_topics' => 1));
+ $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
set_config_count(null, null, null, $phpbb_config);
// Create auth mock
@@ -312,7 +313,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
$phpbb_container = new phpbb_mock_container_builder();
$phpbb_container->set('notification_manager', new phpbb_mock_notification_manager());
- $phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $phpbb_config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE));
+ $phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $phpbb_config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE));
delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason);
diff --git a/tests/content_visibility/get_forums_visibility_sql_test.php b/tests/content_visibility/get_forums_visibility_sql_test.php
index fe7ab36436..28e463ecb5 100644
--- a/tests/content_visibility/get_forums_visibility_sql_test.php
+++ b/tests/content_visibility/get_forums_visibility_sql_test.php
@@ -136,7 +136,8 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data
->will($this->returnValueMap($permissions));
$user = new \phpbb\user('\phpbb\datetime');
$config = new phpbb\config\config(array());
- $content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE);
+ $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
FROM ' . $table . '
diff --git a/tests/content_visibility/get_global_visibility_sql_test.php b/tests/content_visibility/get_global_visibility_sql_test.php
index 43a80c792b..586bae8668 100644
--- a/tests/content_visibility/get_global_visibility_sql_test.php
+++ b/tests/content_visibility/get_global_visibility_sql_test.php
@@ -136,7 +136,8 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data
->will($this->returnValueMap($permissions));
$user = new \phpbb\user('\phpbb\datetime');
$config = new phpbb\config\config(array());
- $content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE);
+ $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
FROM ' . $table . '
diff --git a/tests/content_visibility/get_visibility_sql_test.php b/tests/content_visibility/get_visibility_sql_test.php
index f718e6c29a..9ae2d2fdc4 100644
--- a/tests/content_visibility/get_visibility_sql_test.php
+++ b/tests/content_visibility/get_visibility_sql_test.php
@@ -83,7 +83,8 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te
->will($this->returnValueMap($permissions));
$user = new \phpbb\user('\phpbb\datetime');
$config = new phpbb\config\config(array());
- $content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE);
+ $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
FROM ' . $table . '
diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php
index ab79fbc2ee..36ebf58374 100644
--- a/tests/content_visibility/set_post_visibility_test.php
+++ b/tests/content_visibility/set_post_visibility_test.php
@@ -126,7 +126,8 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t
$auth = $this->getMock('\phpbb\auth\auth');
$user = new \phpbb\user('\phpbb\datetime');
$config = new phpbb\config\config(array());
- $content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE);
+ $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);
$content_visibility->set_post_visibility($visibility, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest);
@@ -176,7 +177,8 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t
$auth = $this->getMock('\phpbb\auth\auth');
$user = new \phpbb\user('\phpbb\datetime');
$config = new phpbb\config\config(array());
- $content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE);
+ $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);
$content_visibility->set_post_visibility(ITEM_DELETED, $post_id, $topic_id, $forum_id, $user_id, $time, $reason, $is_starter, $is_latest);
diff --git a/tests/content_visibility/set_topic_visibility_test.php b/tests/content_visibility/set_topic_visibility_test.php
index 4d02a55490..6c34f42167 100644
--- a/tests/content_visibility/set_topic_visibility_test.php
+++ b/tests/content_visibility/set_topic_visibility_test.php
@@ -90,7 +90,8 @@ class phpbb_content_visibility_set_topic_visibility_test extends phpbb_database_
$auth = $this->getMock('\phpbb\auth\auth');
$user = new \phpbb\user('\phpbb\datetime');
$config = new phpbb\config\config(array());
- $content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE);
+ $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);
$content_visibility->set_topic_visibility($visibility, $topic_id, $forum_id, $user_id, $time, $reason, $force_update_all);
diff --git a/tests/controller/config/test/routing/environment.yml b/tests/controller/config/test/routing/environment.yml
index 175b11f130..1e7df02684 100644
--- a/tests/controller/config/test/routing/environment.yml
+++ b/tests/controller/config/test/routing/environment.yml
@@ -1,3 +1,3 @@
core_controller:
- pattern: /core_foo
+ path: /core_foo
defaults: { _controller: core_foo.controller:bar }
diff --git a/tests/controller/ext/vendor2/foo/config/routing.yml b/tests/controller/ext/vendor2/foo/config/routing.yml
index 6cc275d96d..e3e8ee5f98 100644
--- a/tests/controller/ext/vendor2/foo/config/routing.yml
+++ b/tests/controller/ext/vendor2/foo/config/routing.yml
@@ -1,5 +1,5 @@
controller1:
- pattern: /foo
+ path: /foo
defaults: { _controller: foo.controller:handle }
include_controller2:
diff --git a/tests/controller/ext/vendor2/foo/config/routing_2.yml b/tests/controller/ext/vendor2/foo/config/routing_2.yml
index d987a65aea..ee05898c66 100644
--- a/tests/controller/ext/vendor2/foo/config/routing_2.yml
+++ b/tests/controller/ext/vendor2/foo/config/routing_2.yml
@@ -1,6 +1,6 @@
controller2:
- pattern: /bar
+ path: /bar
defaults: { _controller: foo.controller:handle }
controller3:
- pattern: /bar/p-{p}
+ path: /bar/p-{p}
defaults: { _controller: foo.controller:handle }
diff --git a/tests/controller/ext/vendor2/foo/subfolder/config/routing.yml b/tests/controller/ext/vendor2/foo/subfolder/config/routing.yml
index b4d8d19107..20810a8f25 100644
--- a/tests/controller/ext/vendor2/foo/subfolder/config/routing.yml
+++ b/tests/controller/ext/vendor2/foo/subfolder/config/routing.yml
@@ -1,3 +1,3 @@
controller_noroute:
- pattern: /donotfindthis
+ path: /donotfindthis
defaults: { _controller: foo.controller:handle }
diff --git a/tests/dbal/auto_increment_test.php b/tests/dbal/auto_increment_test.php
index 1ed8ea29e3..057bcb5bac 100644
--- a/tests/dbal/auto_increment_test.php
+++ b/tests/dbal/auto_increment_test.php
@@ -30,7 +30,7 @@ class phpbb_dbal_auto_increment_test extends phpbb_database_test_case
parent::setUp();
$this->db = $this->new_dbal();
- $this->tools = new \phpbb\db\tools($this->db);
+ $this->tools = new \phpbb\db\tools\tools($this->db);
$this->table_data = array(
'COLUMNS' => array(
diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php
index 51f9daacfb..c09b34f55c 100644
--- a/tests/dbal/db_tools_test.php
+++ b/tests/dbal/db_tools_test.php
@@ -17,7 +17,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
{
/** @var \phpbb\db\driver\driver_interface */
protected $db;
- /** @var \phpbb\db\tools */
+ /** @var \phpbb\db\tools\tools_interface */
protected $tools;
protected $table_exists;
protected $table_data;
@@ -32,7 +32,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
parent::setUp();
$this->db = $this->new_dbal();
- $this->tools = new \phpbb\db\tools($this->db);
+ $this->tools = new \phpbb\db\tools\tools($this->db);
$this->table_data = array(
'COLUMNS' => array(
@@ -340,7 +340,7 @@ 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', array(
+ $db_tools = $this->getMock('\phpbb\db\tools\tools', array(
'sql_table_exists',
'sql_table_drop',
), array(&$this->db));
@@ -366,7 +366,7 @@ 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', array(
+ $db_tools = $this->getMock('\phpbb\db\tools\tools', array(
'sql_column_exists',
'sql_column_remove',
), array(&$this->db));
@@ -415,4 +415,11 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
$this->tools->sql_create_unique_index('prefix_table_name', 'i_uniq_ts_id', array('c_timestamp', 'c_id'));
$this->assertTrue($this->tools->sql_unique_index_exists('prefix_table_name', 'i_uniq_ts_id'));
}
+
+ public function test_create_int_default_null()
+ {
+ $this->assertFalse($this->tools->sql_column_exists('prefix_table_name', 'c_bug_13282'));
+ $this->assertTrue($this->tools->sql_column_add('prefix_table_name', 'c_bug_13282', array('TINT:2')));
+ $this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_bug_13282'));
+ }
}
diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php
index 10a9444d63..9b8383fc88 100644
--- a/tests/dbal/migrator_test.php
+++ b/tests/dbal/migrator_test.php
@@ -38,7 +38,7 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
parent::setUp();
$this->db = $this->new_dbal();
- $this->db_tools = new \phpbb\db\tools($this->db);
+ $this->db_tools = new \phpbb\db\tools\tools($this->db);
$this->config = new \phpbb\config\db($this->db, new phpbb_mock_cache, 'phpbb_config');
@@ -46,7 +46,10 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
new \phpbb\db\migration\tool\config($this->config),
);
+ $container = new phpbb_mock_container_builder();
+
$this->migrator = new \phpbb\db\migrator(
+ $container,
$this->config,
$this->db,
$this->db_tools,
@@ -57,9 +60,8 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
$tools,
new \phpbb\db\migration\helper()
);
-
- $container = new phpbb_mock_container_builder();
- $container->set('migrator', $migrator);
+ $container->set('migrator', $this->migrator);
+ $container->set('dispatcher', new phpbb_mock_event_dispatcher());
$user = new \phpbb\user('\phpbb\datetime');
$this->extension_manager = new \phpbb\extension\manager(
diff --git a/tests/error_collector_test.php b/tests/error_collector_test.php
index 1d8ef367f5..b92c4fa6bb 100644
--- a/tests/error_collector_test.php
+++ b/tests/error_collector_test.php
@@ -17,7 +17,7 @@ class phpbb_error_collector_test extends phpbb_test_case
{
public function test_collection()
{
- $collector = new \phpbb\error_collector;
+ $collector = new \phpbb\error_collector(E_ALL | E_STRICT); // php set_error_handler() default
$collector->install();
// Cause a warning
@@ -35,4 +35,32 @@ class phpbb_error_collector_test extends phpbb_test_case
$this->assertStringStartsWith('Errno 2: Division by zero at ', $error_contents);
$this->assertStringEndsWith(" line $line", $error_contents);
}
+
+ public function test_collection_with_mask()
+ {
+ $collector = new \phpbb\error_collector(E_ALL & ~E_NOTICE); // not collecting notices
+ $collector->install();
+
+ // Cause a warning
+ 1/0; $line = __LINE__;
+
+ // Cause a notice
+ $array = array('ITEM' => 'value');
+ $value = $array[ITEM]; $line2 = __LINE__;
+
+ $collector->uninstall();
+
+ // The notice should not be collected
+ $this->assertEmpty($collector->errors[1]);
+
+ list($errno, $msg_text, $errfile, $errline) = $collector->errors[0];
+ $error_contents = $collector->format_errors();
+
+ $this->assertEquals($errno, 2);
+
+ // Unfortunately $error_contents will contain the full path here,
+ // because the tests directory is outside of phpbb root path.
+ $this->assertStringStartsWith('Errno 2: Division by zero at ', $error_contents);
+ $this->assertStringEndsWith(" line $line", $error_contents);
+ }
}
diff --git a/tests/event/exception_listener_test.php b/tests/event/exception_listener_test.php
new file mode 100644
index 0000000000..4d3453cd83
--- /dev/null
+++ b/tests/event/exception_listener_test.php
@@ -0,0 +1,100 @@
+<?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__) . '/../../phpBB/includes/functions.php';
+
+class exception_listener extends phpbb_test_case
+{
+ public function phpbb_exception_data()
+ {
+ return array(
+ array(
+ true,
+ new \Exception(),
+ array(
+ 'status_code' => 500,
+ ),
+ ),
+ array(
+ true,
+ new \Exception('AJAX_ERROR_TEXT'),
+ array(
+ 'status_code' => 500,
+ 'content' => 'AJAX_ERROR_TEXT',
+ ),
+ ),
+ array(
+ true,
+ new \phpbb\exception\runtime_exception('AJAX_ERROR_TEXT'),
+ array(
+ 'status_code' => 500,
+ 'content' => 'Something went wrong when processing your request.',
+ ),
+ ),
+ array(
+ true,
+ new \Symfony\Component\HttpKernel\Exception\HttpException(404, 'AJAX_ERROR_TEXT'),
+ array(
+ 'status_code' => 404,
+ 'content' => 'AJAX_ERROR_TEXT',
+ ),
+ ),
+ array(
+ true,
+ new \phpbb\exception\http_exception(404, 'AJAX_ERROR_TEXT'),
+ array(
+ 'status_code' => 404,
+ 'content' => 'Something went wrong when processing your request.',
+ ),
+ ),
+ array(
+ true,
+ new \phpbb\exception\http_exception(404, 'CURRENT_TIME', array('today')),
+ array(
+ 'status_code' => 404,
+ 'content' => 'It is currently today',
+ ),
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider phpbb_exception_data
+ */
+ public function test_phpbb_exception($is_ajax, $exception, $expected)
+ {
+ $request = \Symfony\Component\HttpFoundation\Request::create('test.php', 'GET', array(), array(), array(), $is_ajax ? array('HTTP_X_REQUESTED_WITH' => 'XMLHttpRequest') : array());
+
+ $template = $this->getMockBuilder('\phpbb\template\twig\twig')
+ ->disableOriginalConstructor()
+ ->getMock();
+
+ $user = new \phpbb\user('\phpbb\datetime');
+ $user->add_lang('common');
+
+ $exception_listener = new \phpbb\event\kernel_exception_subscriber($template, $user);
+
+ $event = new \Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent($this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'), $request, \Symfony\Component\HttpKernel\HttpKernelInterface::MASTER_REQUEST, $exception);
+ $exception_listener->on_kernel_exception($event);
+
+ $response = $event->getResponse();
+
+ $this->assertEquals($expected['status_code'], $response->getStatusCode());
+ $this->assertEquals($is_ajax, $response instanceof \Symfony\Component\HttpFoundation\JsonResponse);
+
+ if (isset($expected['content']))
+ {
+ $this->assertContains($expected['content'], $response->getContent());
+ }
+ }
+}
diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php
index 5c7cad89f6..c737d33f95 100644
--- a/tests/extension/manager_test.php
+++ b/tests/extension/manager_test.php
@@ -150,13 +150,16 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
$config = new \phpbb\config\config(array('version' => PHPBB_VERSION));
$db = $this->new_dbal();
- $db_tools = new \phpbb\db\tools($db);
+ $db_tools = new \phpbb\db\tools\tools($db);
$phpbb_root_path = __DIR__ . './../../phpBB/';
$php_ext = 'php';
$table_prefix = 'phpbb_';
$user = new \phpbb\user('\phpbb\user');
+ $container = new phpbb_mock_container_builder();
+
$migrator = new \phpbb\db\migrator(
+ $container,
$config,
$db,
$db_tools,
@@ -167,7 +170,6 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
array(),
new \phpbb\db\migration\helper()
);
- $container = new phpbb_mock_container_builder();
$container->set('migrator', $migrator);
return new \phpbb\extension\manager(
diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php
index ead0076d90..bd7acf12f9 100644
--- a/tests/extension/metadata_manager_test.php
+++ b/tests/extension/metadata_manager_test.php
@@ -41,7 +41,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
'version' => '3.1.0',
));
$this->db = $this->new_dbal();
- $this->db_tools = new \phpbb\db\tools($this->db);
+ $this->db_tools = new \phpbb\db\tools\tools($this->db);
$this->phpbb_root_path = dirname(__FILE__) . '/';
$this->phpEx = 'php';
$this->user = new \phpbb\user('\phpbb\datetime');
@@ -77,7 +77,10 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $this->user, $context, $twig, $cache_path, array(new \phpbb\template\twig\extension($context, $this->user)));
$container->set('template.twig.lexer', new \phpbb\template\twig\lexer($twig));
+ $container = new phpbb_mock_container_builder();
+
$this->migrator = new \phpbb\db\migrator(
+ $container,
$this->config,
$this->db,
$this->db_tools,
@@ -137,6 +140,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
}
$json = json_decode(file_get_contents($this->phpbb_root_path . 'ext/vendor2/foo/composer.json'), true);
+ array_walk_recursive($json, array($manager, 'sanitize_json'));
$this->assertEquals($metadata, $json);
}
diff --git a/tests/functional/acp_profile_field_test.php b/tests/functional/acp_profile_field_test.php
new file mode 100644
index 0000000000..88df782faa
--- /dev/null
+++ b/tests/functional/acp_profile_field_test.php
@@ -0,0 +1,71 @@
+<?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_acp_profile_field_test extends phpbb_functional_test_case
+{
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->login();
+ $this->admin_login();
+ $this->add_lang('acp/profile');
+ }
+
+ public function data_add_profile_field()
+ {
+ return array(
+ array('bool', 'profilefields.type.bool',
+ array(
+ 'lang_options[0]' => 'foo',
+ 'lang_options[1]' => 'bar',
+ ),
+ array(),
+ ),
+ array('dropdown', 'profilefields.type.dropdown',
+ array(
+ 'lang_options' => "foo\nbar\nbar\nfoo",
+ ),
+ array(),
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider data_add_profile_field
+ */
+ public function test_add_profile_field($name, $type, $page1_settings, $page2_settings)
+ {
+ // Custom profile fields page
+ $crawler = self::request('GET', 'adm/index.php?i=acp_profile&mode=profile&sid=' . $this->sid);
+ // these language strings are html
+ $form = $crawler->selectButton('Create new field')->form(array(
+ 'field_ident' => $name,
+ 'field_type' => $type,
+ ));
+ $crawler = self::submit($form);
+
+ // Fill form for profile field options
+ $form = $crawler->selectButton('Profile type specific options')->form($page1_settings);
+ $crawler = self::submit($form);
+
+ // Fill form for profile field specific options
+ $form = $crawler->selectButton('Save')->form($page2_settings);
+ $crawler= self::submit($form);
+
+ $this->assertContainsLang('ADDED_PROFILE_FIELD', $crawler->text());
+ }
+}
diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php
index b8c48389e0..d381fa1ae2 100644
--- a/tests/functional/fileupload_form_test.php
+++ b/tests/functional/fileupload_form_test.php
@@ -93,23 +93,32 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case
$this->login();
$this->admin_login();
$this->add_lang('ucp');
- $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_attachments&mode=attach');
- $form = $crawler->selectButton('Submit')->form();
- $values = $form->getValues();
+ // Make sure check_attachment_content is set to false
+ $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_attachments&mode=attach');
- $values["config[check_attachment_content]"] = 0;
- $form->setValues($values);
- $crawler = self::submit($form);
+ $form = $crawler->selectButton('Submit')->form(array(
+ 'config[check_attachment_content]' => 0,
+ 'config[img_imagick]' => '',
+ ));
+ self::submit($form);
// Request index for correct URL
- $crawler = self::request('GET', 'index.php?sid=' . $this->sid);
+ self::request('GET', 'index.php?sid=' . $this->sid);
$crawler = $this->upload_file('disallowed.jpg', 'image/jpeg');
// Hitting the UNABLE_GET_IMAGE_SIZE error means we passed the
// DISALLOWED_CONTENT check
$this->assertContainsLang('UNABLE_GET_IMAGE_SIZE', $crawler->text());
+
+ // Reset check_attachment_content to default (enabled)
+ $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_attachments&mode=attach');
+
+ $form = $crawler->selectButton('Submit')->form(array(
+ 'config[check_attachment_content]' => 1,
+ ));
+ self::submit($form);
}
public function test_too_large()
diff --git a/tests/functional/fixtures/ext/foo/bar/config/routing.yml b/tests/functional/fixtures/ext/foo/bar/config/routing.yml
index 08bc73038f..374a58046d 100644
--- a/tests/functional/fixtures/ext/foo/bar/config/routing.yml
+++ b/tests/functional/fixtures/ext/foo/bar/config/routing.yml
@@ -1,35 +1,35 @@
foo_bar_controller:
- pattern: /foo/bar
+ path: /foo/bar
defaults: { _controller: foo_bar.controller:handle }
foo_baz_controller:
- pattern: /foo/baz
+ path: /foo/baz
defaults: { _controller: foo_bar.controller:baz }
foo_template_controller:
- pattern: /foo/template
+ path: /foo/template
defaults: { _controller: foo_bar.controller:template }
foo_exception_controller:
- pattern: /foo/exception
+ path: /foo/exception
defaults: { _controller: foo_bar.controller:exception }
foo_login_redirect_controller:
- pattern: /foo/login_redirect
+ path: /foo/login_redirect
defaults: { _controller: foo_bar.controller:login_redirect }
foo_redirect_controller:
- pattern: /foo/redirect
+ path: /foo/redirect
defaults: { _controller: foo_bar.controller:redirect }
foo_index_controller:
- pattern: /index
+ path: /index
defaults: { _controller: foo_bar.controller:redirect }
foo_tests_index_controller:
- pattern: /tests/index
+ path: /tests/index
defaults: { _controller: foo_bar.controller:redirect }
foo_tests_dotdot_index_controller:
- pattern: /tests/../index
+ path: /tests/../index
defaults: { _controller: foo_bar.controller:redirect }
diff --git a/tests/functional/fixtures/ext/foo/foo/config/resource.yml b/tests/functional/fixtures/ext/foo/foo/config/resource.yml
index ed1d018016..4f2b9cce70 100644
--- a/tests/functional/fixtures/ext/foo/foo/config/resource.yml
+++ b/tests/functional/fixtures/ext/foo/foo/config/resource.yml
@@ -1,3 +1,3 @@
foo_foo_controller:
- pattern: /foo
+ path: /foo
defaults: { _controller: foo_foo.controller:handle }
diff --git a/tests/functional/prune_shadow_topic_test.php b/tests/functional/prune_shadow_topic_test.php
index f00303060d..c014119b98 100644
--- a/tests/functional/prune_shadow_topic_test.php
+++ b/tests/functional/prune_shadow_topic_test.php
@@ -62,7 +62,7 @@ class phpbb_functional_prune_shadow_topic_test extends phpbb_functional_test_cas
$crawler = self::request('GET', "viewtopic.php?t={$this->post['topic_id']}&sid={$this->sid}");
$this->assertContains('Prune Shadow #1', $crawler->filter('html')->text());
- $this->data['topics']['Prune Shadow #1'] = (int) $post['topic_id'];
+ $this->data['topics']['Prune Shadow #1'] = (int) $this->post['topic_id'];
$this->data['posts']['Prune Shadow #1'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p');
$this->assert_forum_details($this->data['forums']['Prune Shadow'], array(
diff --git a/tests/functions/get_remote_file_test.php b/tests/functions/get_remote_file_test.php
index d412dce164..8e9ad1105a 100644
--- a/tests/functions/get_remote_file_test.php
+++ b/tests/functions/get_remote_file_test.php
@@ -12,7 +12,7 @@
*/
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
-require_once dirname(__FILE__) . '/../../phpBB/includes/functions_admin.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_compatibility.php';
/**
* @group slow
diff --git a/tests/functions/make_clickable_test.php b/tests/functions/make_clickable_test.php
index e61cb2c30e..63beeb06b2 100644
--- a/tests/functions/make_clickable_test.php
+++ b/tests/functions/make_clickable_test.php
@@ -74,13 +74,77 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case
'http://www.phpbb.com/community/path/to/long/url/file.ext#section',
'<!-- m --><a class="postlink" href="http://www.phpbb.com/community/path/to/long/url/file.ext#section">http://www.phpbb.com/community/path/to/ ... xt#section</a><!-- m -->'
),
+ );
+ }
- // IDN is not parsed and returned as is
- array('http://домен.рф', 'http://домен.рф'),
+ public function data_test_make_clickable_url_idn()
+ {
+ return array(
+ array(
+ 'http://www.täst.de/community/',
+ '<!-- m --><a class="postlink" href="http://www.täst.de/community/">http://www.täst.de/community/</a><!-- m -->'
+ ),
+ array(
+ 'http://www.täst.de/path/file.ext#section',
+ '<!-- m --><a class="postlink" href="http://www.täst.de/path/file.ext#section">http://www.täst.de/path/file.ext#section</a><!-- m -->'
+ ),
+ array(
+ 'ftp://ftp.täst.de/',
+ '<!-- m --><a class="postlink" href="ftp://ftp.täst.de/">ftp://ftp.täst.de/</a><!-- m -->'
+ ),
+ array(
+ 'sip://bantu@täst.de',
+ '<!-- m --><a class="postlink" href="sip://bantu@täst.de">sip://bantu@täst.de</a><!-- m -->'
+ ),
+ array(
+ 'www.täst.de/community/',
+ '<!-- w --><a class="postlink" href="http://www.täst.de/community/">www.täst.de/community/</a><!-- w -->'
+ ),
+ // Test appending punctuation mark to the URL
+ array(
+ 'http://домен.рф/viewtopic.php?t=1!',
+ '<!-- m --><a class="postlink" href="http://домен.рф/viewtopic.php?t=1">http://домен.рф/viewtopic.php?t=1</a><!-- m -->!'
+ ),
+ array(
+ 'www.домен.рф/сообщество/?',
+ '<!-- w --><a class="postlink" href="http://www.домен.рф/сообщество/">www.домен.рф/сообщество/</a><!-- w -->?'
+ ),
+ // Test shortened text for URL > 55 characters long
+ // URL text should be turned into: first 39 chars + ' ... ' + last 10 chars
+ array(
+ 'http://www.домен.рф/сообщество/путь/по/длинной/ссылке/file.ext#section',
+ '<!-- m --><a class="postlink" href="http://www.домен.рф/сообщество/путь/по/длинной/ссылке/file.ext#section">http://www.домен.рф/сообщество/путь/по/ ... xt#section</a><!-- m -->'
+ ),
+
+ // IDN with invalid characters shouldn't be parsed correctly (only 'valid' part)
+ array(
+ 'http://www.täst╫.de',
+ '<!-- m --><a class="postlink" href="http://www.täst">http://www.täst</a><!-- m -->╫.de'
+ ),
+ // IDN in emails is unsupported yet
array('почта@домен.рф', 'почта@домен.рф'),
);
}
+ public function data_test_make_clickable_local_url_idn()
+ {
+ return array(
+ array(
+ 'http://www.домен.рф/viewtopic.php?t=1',
+ '<!-- l --><a class="postlink-local" href="http://www.домен.рф/viewtopic.php?t=1">viewtopic.php?t=1</a><!-- l -->'
+ ),
+ // Test appending punctuation mark to the URL
+ array(
+ 'http://www.домен.рф/viewtopic.php?t=1!',
+ '<!-- l --><a class="postlink-local" href="http://www.домен.рф/viewtopic.php?t=1">viewtopic.php?t=1</a><!-- l -->!'
+ ),
+ array(
+ 'http://www.домен.рф/сообщество/?',
+ '<!-- l --><a class="postlink-local" href="http://www.домен.рф/сообщество/">сообщество/</a><!-- l -->?'
+ ),
+ );
+ }
+
protected function setUp()
{
parent::setUp();
@@ -97,4 +161,20 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case
{
$this->assertSame($expected, make_clickable($url));
}
+
+ /**
+ * @dataProvider data_test_make_clickable_url_idn
+ */
+ public function test_urls_matching_idn($url, $expected)
+ {
+ $this->assertSame($expected, make_clickable($url));
+ }
+
+ /**
+ * @dataProvider data_test_make_clickable_local_url_idn
+ */
+ public function test_local_urls_matching_idn($url, $expected)
+ {
+ $this->assertSame($expected, make_clickable($url, "http://www.домен.рф"));
+ }
}
diff --git a/tests/migrator/convert_timezones_test.php b/tests/migrator/convert_timezones_test.php
index 7501ed2ed0..80a43b4035 100644
--- a/tests/migrator/convert_timezones_test.php
+++ b/tests/migrator/convert_timezones_test.php
@@ -18,7 +18,7 @@ class phpbb_migrator_convert_timezones_test extends phpbb_database_test_case
public function getDataSet()
{
$this->db = $this->new_dbal();
- $db_tools = new \phpbb\db\tools($this->db);
+ $db_tools = new \phpbb\db\tools\tools($this->db);
// user_dst doesn't exist anymore, must re-add it to test this
$db_tools->sql_column_add('phpbb_users', 'user_dst', array('BOOL', 1));
@@ -59,7 +59,7 @@ class phpbb_migrator_convert_timezones_test extends phpbb_database_test_case
$this->migration = new \phpbb\db\migration\data\v310\timezone(
new \phpbb\config\config(array()),
$this->db,
- new \phpbb\db\tools($this->db),
+ new \phpbb\db\tools\tools($this->db),
$phpbb_root_path,
$phpEx,
'phpbb_'
@@ -90,7 +90,7 @@ class phpbb_migrator_convert_timezones_test extends phpbb_database_test_case
}
$this->db->sql_freeresult($result);
- $db_tools = new \phpbb\db\tools($this->db);
+ $db_tools = new \phpbb\db\tools\tools($this->db);
// Remove the user_dst field again
$db_tools->sql_column_remove('phpbb_users', 'user_dst');
diff --git a/tests/migrator/schema_generator_test.php b/tests/migrator/schema_generator_test.php
index 9adf518a5d..1e3b489426 100644
--- a/tests/migrator/schema_generator_test.php
+++ b/tests/migrator/schema_generator_test.php
@@ -30,7 +30,7 @@ class schema_generator_test extends phpbb_test_case
$this->config = new \phpbb\config\config(array());
$this->db = new \phpbb\db\driver\sqlite();
- $this->db_tools = new \phpbb\db\tools($this->db);
+ $this->db_tools = new \phpbb\db\tools\tools($this->db);
$this->table_prefix = 'phpbb_';
}
diff --git a/tests/mock/file_downloader.php b/tests/mock/file_downloader.php
new file mode 100644
index 0000000000..d8951cebf6
--- /dev/null
+++ b/tests/mock/file_downloader.php
@@ -0,0 +1,27 @@
+<?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_mock_file_downloader extends \phpbb\file_downloader
+{
+ public $data;
+
+ public function set($data)
+ {
+ $this->data = $data;
+ }
+
+ public function get($host, $directory, $filename, $port = 80, $timeout = 6)
+ {
+ return $this->data;
+ }
+}
diff --git a/tests/mock/metadata_manager.php b/tests/mock/metadata_manager.php
index 16900a0fc1..2443fad560 100644
--- a/tests/mock/metadata_manager.php
+++ b/tests/mock/metadata_manager.php
@@ -15,11 +15,13 @@ class phpbb_mock_metadata_manager extends \phpbb\extension\metadata_manager
{
public function set_metadata($metadata)
{
+ array_walk_recursive($metadata, array($this, 'sanitize_json'));
$this->metadata = $metadata;
}
public function merge_metadata($metadata)
{
+ array_walk_recursive($metadata, array($this, 'sanitize_json'));
$this->metadata = array_merge($this->metadata, $metadata);
}
}
diff --git a/tests/notification/base.php b/tests/notification/base.php
index c97b7c24e2..162feae557 100644
--- a/tests/notification/base.php
+++ b/tests/notification/base.php
@@ -66,6 +66,8 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
$phpbb_root_path,
$phpEx
);
+
+ $this->phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$phpbb_container = $this->container = new phpbb_mock_container_builder();
@@ -75,6 +77,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
$this->container,
$this->user_loader,
$this->config,
+ $this->phpbb_dispatcher,
$this->db,
$this->cache,
$this->user,
diff --git a/tests/notification/convert_test.php b/tests/notification/convert_test.php
index 32ab34c9bc..ad6e5849d3 100644
--- a/tests/notification/convert_test.php
+++ b/tests/notification/convert_test.php
@@ -32,7 +32,7 @@ class phpbb_notification_convert_test extends phpbb_database_test_case
$this->migration = new \phpbb\db\migration\data\v310\notification_options_reconvert(
new \phpbb\config\config(array()),
$this->db,
- new \phpbb\db\tools($this->db),
+ new \phpbb\db\tools\tools($this->db),
$phpbb_root_path,
$phpEx,
'phpbb_'
diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php
index 684dd99280..5e770f71c9 100644
--- a/tests/notification/submit_post_base.php
+++ b/tests/notification/submit_post_base.php
@@ -100,7 +100,8 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
// Container
$phpbb_container = new phpbb_mock_container_builder();
- $phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE));
+ $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
+ $phpbb_container->set('content.visibility', new \phpbb\content_visibility($auth, $config, $phpbb_dispatcher, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE));
$user_loader = new \phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE);
@@ -122,7 +123,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
// Notification Manager
$phpbb_notifications = new \phpbb\notification\manager($notification_types_array, array(),
- $phpbb_container, $user_loader, $config, $db, $cache, $user,
+ $phpbb_container, $user_loader, $config, $phpbb_dispatcher, $db, $cache, $user,
$phpbb_root_path, $phpEx,
NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE);
$phpbb_container->set('notification_manager', $phpbb_notifications);
diff --git a/tests/pagination/config/test/routing/environment.yml b/tests/pagination/config/test/routing/environment.yml
index dd667274cd..2ce082c9d1 100644
--- a/tests/pagination/config/test/routing/environment.yml
+++ b/tests/pagination/config/test/routing/environment.yml
@@ -1,6 +1,6 @@
core_controller:
- pattern: /test
+ path: /test
defaults: { _controller: core_foo.controller:bar, page: 1}
core_page_controller:
- pattern: /test/page/{page}
+ path: /test/page/{page}
defaults: { _controller: core_foo.controller:bar}
diff --git a/tests/path_helper/path_helper_test.php b/tests/path_helper/path_helper_test.php
index 3832307897..73f0e6bafc 100644
--- a/tests/path_helper/path_helper_test.php
+++ b/tests/path_helper/path_helper_test.php
@@ -411,6 +411,21 @@ class phpbb_path_helper_test extends phpbb_test_case
'http://www.phpbb.com/community',
'../community/',
),
+ array(
+ 'http://www.phpbb.com/foobar',
+ 'http://www.phpbb.com',
+ '',
+ ),
+ array(
+ 'http://www.foobar.com',
+ 'http://www.phpbb.com',
+ '/www.phpbb.com/',
+ ),
+ array(
+ 'foobar',
+ 'http://www.phpbb.com/community',
+ '',
+ )
);
}
@@ -421,4 +436,29 @@ class phpbb_path_helper_test extends phpbb_test_case
{
$this->assertEquals($this->phpbb_root_path . $expected, $this->path_helper->get_web_root_path_from_ajax_referer($referer_url, $board_url));
}
+
+ public function data_get_valid_page()
+ {
+ return array(
+ // array( current page , mod_rewrite setting , expected output )
+ array('index', true, 'index'),
+ array('index', false, 'index'),
+ array('foo/index', true, 'foo/index'),
+ array('foo/index', false, 'foo/index'),
+ array('app.php/foo', true, 'foo'),
+ array('app.php/foo', false, 'app.php/foo'),
+ array('/../app.php/foo', true, '../foo'),
+ array('/../app.php/foo', false, '../app.php/foo'),
+ array('/../example/app.php/foo/bar', true, '../example/foo/bar'),
+ array('/../example/app.php/foo/bar', false, '../example/app.php/foo/bar'),
+ );
+ }
+
+ /**
+ * @dataProvider data_get_valid_page
+ */
+ public function test_get_valid_page($page, $mod_rewrite, $expected)
+ {
+ $this->assertEquals($this->phpbb_root_path . $expected, $this->path_helper->get_valid_page($page, $mod_rewrite));
+ }
}
diff --git a/tests/profilefields/type_string_test.php b/tests/profilefields/type_string_test.php
index a7be087fb5..0417afbfab 100644
--- a/tests/profilefields/type_string_test.php
+++ b/tests/profilefields/type_string_test.php
@@ -133,37 +133,49 @@ class phpbb_profilefield_type_string_test extends phpbb_test_case
),
array(
'ö äö äö ä',
- array('field_validation' => '[\w]+'),
+ array('field_validation' => '[a-zA-Z0-9]+'),
'FIELD_INVALID_CHARS_ALPHA_ONLY-field',
'Required field should reject UTF-8 in alpha only field',
),
array(
+ 'a_abc',
+ array('field_validation' => '[a-zA-Z0-9]+'),
+ 'FIELD_INVALID_CHARS_ALPHA_ONLY-field',
+ 'Required field should reject underscore in alpha only field',
+ ),
+ array(
'Hello',
- array('field_validation' => '[\w]+'),
+ array('field_validation' => '[a-zA-Z0-9]+'),
false,
'Required field should accept a characters only field',
),
array(
'Valid.Username123',
- array('field_validation' => '[\w.]+'),
+ array('field_validation' => '[a-zA-Z0-9.]+'),
false,
'Required field should accept a alphanumeric field with dots',
),
array(
'Invalid.,username123',
- array('field_validation' => '[\w.]+'),
+ array('field_validation' => '[a-zA-Z0-9.]+'),
'FIELD_INVALID_CHARS_ALPHA_DOTS-field',
'Required field should reject field with comma',
),
array(
+ 'Invalid._username123',
+ array('field_validation' => '[a-zA-Z0-9.]+'),
+ 'FIELD_INVALID_CHARS_ALPHA_DOTS-field',
+ 'Required field should reject field with underscore',
+ ),
+ array(
'skype.test.name,_this',
- array('field_validation' => '[a-zA-Z][\w\.,\-_]+'),
+ array('field_validation' => '[a-zA-Z][\w\.,\-]+'),
false,
'Required field should accept alphanumeric field with punctuations',
),
array(
'1skype.this.should.faila',
- array('field_validation' => '[a-zA-Z][\w\.,\-_]+'),
+ array('field_validation' => '[a-zA-Z][\w\.,\-]+'),
'FIELD_INVALID_CHARS_ALPHA_PUNCTUATION-field',
'Required field should reject field having invalid input for the given validation',
),
diff --git a/tests/profilefields/type_url_test.php b/tests/profilefields/type_url_test.php
index 372c07418f..cc37f04f30 100644
--- a/tests/profilefields/type_url_test.php
+++ b/tests/profilefields/type_url_test.php
@@ -89,6 +89,32 @@ class phpbb_profilefield_type_url_test extends phpbb_test_case
'FIELD_INVALID_URL-field',
'Field should reject invalid URL having multi value parameters',
),
+
+ // IDN url type profilefields
+ array(
+ 'http://www.täst.de',
+ array(),
+ false,
+ 'Field should accept valid IDN',
+ ),
+ array(
+ 'http://täst.de/index.html?param1=test&param2=awesome',
+ array(),
+ false,
+ 'Field should accept valid IDN URL with params',
+ ),
+ array(
+ 'http://домен.рф/index.html/тест/path?document=get',
+ array(),
+ false,
+ 'Field should accept valid IDN URL',
+ ),
+ array(
+ 'http://домен.рф/index.html/тест/path?document[]=DocType%20test&document[]=AnotherDoc',
+ array(),
+ 'FIELD_INVALID_URL-field',
+ 'Field should reject invalid IDN URL having multi value parameters',
+ ),
);
}
@@ -119,6 +145,20 @@ class phpbb_profilefield_type_url_test extends phpbb_test_case
'http://example.com',
'Field should return correct raw value',
),
+
+ // IDN tests
+ array(
+ 'http://täst.de',
+ array('field_show_novalue' => true),
+ 'http://täst.de',
+ 'Field should return the correct raw value',
+ ),
+ array(
+ 'http://домен.рф',
+ array('field_show_novalue' => false),
+ 'http://домен.рф',
+ 'Field should return correct raw value',
+ ),
);
}
diff --git a/tests/regex/url_test.php b/tests/regex/url_test.php
index d3487a9c16..e5d7c3256a 100644
--- a/tests/regex/url_test.php
+++ b/tests/regex/url_test.php
@@ -32,6 +32,6 @@ class phpbb_regex_url_test extends phpbb_test_case
*/
public function test_url($url, $expected)
{
- $this->assertEquals($expected, preg_match('#^' . get_preg_expression('url') . '$#i', $url));
+ $this->assertEquals($expected, preg_match('#^' . get_preg_expression('url') . '$#iu', $url));
}
}
diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php
index fc1a3632f4..f630f4ab52 100644
--- a/tests/test_framework/phpbb_database_test_case.php
+++ b/tests/test_framework/phpbb_database_test_case.php
@@ -77,7 +77,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
global $table_prefix;
$db = new \phpbb\db\driver\sqlite();
- $schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, new \phpbb\db\tools($db, true), $phpbb_root_path, $phpEx, $table_prefix);
+ $schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, new \phpbb\db\tools\tools($db, true), $phpbb_root_path, $phpEx, $table_prefix);
file_put_contents(self::$schema_file, json_encode($schema_generator->get_schema()));
}
diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php
index 5d643e43e2..ba641c6fb7 100644
--- a/tests/test_framework/phpbb_database_test_connection_manager.php
+++ b/tests/test_framework/phpbb_database_test_connection_manager.php
@@ -370,11 +370,11 @@ class phpbb_database_test_connection_manager
->get_classes();
$db = new \phpbb\db\driver\sqlite();
- $schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, new \phpbb\db\tools($db, true), $phpbb_root_path, $phpEx, $table_prefix);
+ $schema_generator = new \phpbb\db\migration\schema_generator($classes, new \phpbb\config\config(array()), $db, new \phpbb\db\tools\tools($db, true), $phpbb_root_path, $phpEx, $table_prefix);
$db_table_schema = $schema_generator->get_schema();
}
- $db_tools = new \phpbb\db\tools($db, true);
+ $db_tools = new \phpbb\db\tools\tools($db, true);
foreach ($db_table_schema as $table_name => $table_data)
{
$queries = $db_tools->sql_create_table(
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index 9391795e32..5960956444 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -230,9 +230,11 @@ class phpbb_functional_test_case extends phpbb_test_case
$config = new \phpbb\config\config(array());
$db = $this->get_db();
- $db_tools = new \phpbb\db\tools($db);
+ $db_tools = new \phpbb\db\tools\tools($db);
+ $container = new phpbb_mock_container_builder();
$migrator = new \phpbb\db\migrator(
+ $container,
$config,
$db,
$db_tools,
@@ -243,8 +245,8 @@ class phpbb_functional_test_case extends phpbb_test_case
array(),
new \phpbb\db\migration\helper()
);
- $container = new phpbb_mock_container_builder();
$container->set('migrator', $migrator);
+ $container->set('dispatcher', new phpbb_mock_event_dispatcher());
$user = new \phpbb\user('\phpbb\datetime');
$extension_manager = new \phpbb\extension\manager(
diff --git a/tests/version/version_helper_remote_test.php b/tests/version/version_helper_remote_test.php
new file mode 100644
index 0000000000..65ae7646b9
--- /dev/null
+++ b/tests/version/version_helper_remote_test.php
@@ -0,0 +1,173 @@
+<?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 version_helper_remote_test extends \phpbb_test_case
+{
+ protected $file_downloader;
+ protected $cache;
+ protected $version_helper;
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ global $phpbb_root_path, $phpEx;
+
+ include_once($phpbb_root_path . 'includes/functions.' . $phpEx);
+
+ $config = new \phpbb\config\config(array(
+ 'version' => '3.1.0',
+ ));
+ $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\null(), $config, $db, '../../', 'php'));
+ $this->cache->expects($this->any())
+ ->method('get')
+ ->with($this->anything())
+ ->will($this->returnValue(false));
+ $this->file_downloader = new phpbb_mock_file_downloader();
+
+ $this->version_helper = new \phpbb\version_helper(
+ $this->cache,
+ $config,
+ $this->file_downloader,
+ new \phpbb\user('\phpbb\datetime')
+ );
+ $this->user = new \phpbb\user('\phpbb\datetime');
+ $this->user->add_lang('acp/common');
+ }
+
+ public function provider_get_versions()
+ {
+ return array(
+ array('', false),
+ array('foobar', false),
+ array('{
+ "stable": {
+ "1.0": {
+ "current": "1.0.1",
+ "download": "https://www.phpbb.com/customise/db/download/104136",
+ "announcement": "https://www.phpbb.com/customise/db/extension/boardrules/",
+ "eol": null,
+ "security": false
+ }
+ }
+}', true, array (
+ 'stable' => array (
+ '1.0' => array (
+ 'current' => '1.0.1',
+ 'download' => 'https://www.phpbb.com/customise/db/download/104136',
+ 'announcement' => 'https://www.phpbb.com/customise/db/extension/boardrules/',
+ 'eol' => NULL,
+ 'security' => false,
+ ),
+ ),
+ 'unstable' => array (
+ '1.0' => array (
+ 'current' => '1.0.1',
+ 'download' => 'https://www.phpbb.com/customise/db/download/104136',
+ 'announcement' => 'https://www.phpbb.com/customise/db/extension/boardrules/',
+ 'eol' => NULL,
+ 'security' => false,
+ ),
+ ),
+ )),
+ array('{
+ "foobar": {
+ "1.0": {
+ "current": "1.0.1",
+ "download": "https://www.phpbb.com/customise/db/download/104136",
+ "announcement": "https://www.phpbb.com/customise/db/extension/boardrules/",
+ "eol": null,
+ "security": false
+ }
+ }
+}', false),
+ array('{
+ "stable": {
+ "1.0": {
+ "current": "1.0.1<script>alert(\'foo\');</script>",
+ "download": "https://www.phpbb.com/customise/db/download/104136<script>alert(\'foo\');</script>",
+ "announcement": "https://www.phpbb.com/customise/db/extension/boardrules/<script>alert(\'foo\');</script>",
+ "eol": "<script>alert(\'foo\');</script>",
+ "security": "<script>alert(\'foo\');</script>"
+ }
+ }
+}', true, array (
+ 'stable' => array (
+ '1.0' => array (
+ 'current' => '1.0.1&lt;script&gt;alert(\'foo\');&lt;/script&gt;',
+ 'download' => 'https://www.phpbb.com/customise/db/download/104136&lt;script&gt;alert(\'foo\');&lt;/script&gt;',
+ 'announcement' => 'https://www.phpbb.com/customise/db/extension/boardrules/&lt;script&gt;alert(\'foo\');&lt;/script&gt;',
+ 'eol' => '&lt;script&gt;alert(\'foo\');&lt;/script&gt;',
+ 'security' => '&lt;script&gt;alert(\'foo\');&lt;/script&gt;',
+ ),
+ ),
+ 'unstable' => array (
+ '1.0' => array (
+ 'current' => '1.0.1&lt;script&gt;alert(\'foo\');&lt;/script&gt;',
+ 'download' => 'https://www.phpbb.com/customise/db/download/104136&lt;script&gt;alert(\'foo\');&lt;/script&gt;',
+ 'announcement' => 'https://www.phpbb.com/customise/db/extension/boardrules/&lt;script&gt;alert(\'foo\');&lt;/script&gt;',
+ 'eol' => '&lt;script&gt;alert(\'foo\');&lt;/script&gt;',
+ 'security' => '&lt;script&gt;alert(\'foo\');&lt;/script&gt;',
+ ),
+ ),
+ )),
+ array('{
+ "unstable": {
+ "1.0": {
+ "current": "1.0.1<script>alert(\'foo\');</script>",
+ "download": "https://www.phpbb.com/customise/db/download/104136<script>alert(\'foo\');</script>",
+ "announcement": "https://www.phpbb.com/customise/db/extension/boardrules/<script>alert(\'foo\');</script>",
+ "eol": "<script>alert(\'foo\');</script>",
+ "security": "<script>alert(\'foo\');</script>"
+ }
+ }
+}', true, array (
+ 'unstable' => array (
+ '1.0' => array (
+ 'current' => '1.0.1&lt;script&gt;alert(\'foo\');&lt;/script&gt;',
+ 'download' => 'https://www.phpbb.com/customise/db/download/104136&lt;script&gt;alert(\'foo\');&lt;/script&gt;',
+ 'announcement' => 'https://www.phpbb.com/customise/db/extension/boardrules/&lt;script&gt;alert(\'foo\');&lt;/script&gt;',
+ 'eol' => '&lt;script&gt;alert(\'foo\');&lt;/script&gt;',
+ 'security' => '&lt;script&gt;alert(\'foo\');&lt;/script&gt;',
+ ),
+ ),
+ 'stable' => array(),
+ )),
+ );
+ }
+
+ /**
+ * @dataProvider provider_get_versions
+ */
+ public function test_get_versions($input, $valid_data, $expected_return = '')
+ {
+ $this->file_downloader->set($input);
+
+ if (!$valid_data)
+ {
+ try {
+ $return = $this->version_helper->get_versions();
+ } catch (\RuntimeException $e) {
+ $this->assertEquals((string)$e->getMessage(), $this->user->lang('VERSIONCHECK_FAIL'));
+ }
+ }
+ else
+ {
+ $return = $this->version_helper->get_versions();
+ }
+
+ $this->assertEquals($expected_return, $return);
+ }
+}