aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auth/provider_db_test.php9
-rw-r--r--tests/avatar/fixtures/users.xml28
-rw-r--r--tests/avatar/manager_test.php56
-rw-r--r--tests/bootstrap.php6
-rw-r--r--tests/cache/cache_memory.php64
-rw-r--r--tests/cache/cache_memory_test.php129
-rw-r--r--tests/cache/fixtures/cache_memory.xml77
-rw-r--r--tests/composer.json5
-rw-r--r--tests/composer.lock66
-rw-r--r--tests/console/cache/purge_test.php95
-rw-r--r--tests/console/cron/run_test.php1
-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/common_helper_route.php229
-rw-r--r--tests/controller/config/routing.yml2
-rw-r--r--tests/controller/controller_test.php2
-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/controller/helper_route_other_app.php37
-rw-r--r--tests/datetime/from_format_test.php28
-rw-r--r--tests/dbal/db_tools_test.php7
-rw-r--r--tests/dbal/migrator_test.php8
-rw-r--r--tests/error_collector_test.php30
-rw-r--r--tests/event/exception_listener_test.php100
-rw-r--r--tests/event/fixtures/trigger_wspace.test15
-rw-r--r--tests/event/php_exporter_test.php16
-rw-r--r--tests/extension/manager_test.php4
-rw-r--r--tests/extension/metadata_manager_test.php5
-rw-r--r--tests/functional/acp_attachments_test.php78
-rw-r--r--tests/functional/acp_groups_test.php4
-rw-r--r--tests/functional/acp_profile_field_test.php71
-rw-r--r--tests/functional/acp_registration_test.php55
-rw-r--r--tests/functional/auth_test.php19
-rw-r--r--tests/functional/avatar_acp_groups_test.php4
-rw-r--r--tests/functional/avatar_acp_users_test.php4
-rw-r--r--tests/functional/avatar_ucp_groups_test.php4
-rw-r--r--tests/functional/avatar_ucp_users_test.php4
-rw-r--r--tests/functional/common_avatar_test_case.php (renamed from tests/functional/common_avatar_test.php)4
-rw-r--r--tests/functional/common_groups_test_case.php (renamed from tests/functional/common_groups_test.php)2
-rw-r--r--tests/functional/download_test.php15
-rw-r--r--tests/functional/feed_test.php37
-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/memberlist_test.php28
-rw-r--r--tests/functional/notification_test.php2
-rw-r--r--tests/functional/prune_shadow_topic_test.php6
-rw-r--r--tests/functional/registration_test.php15
-rw-r--r--tests/functional/ucp_groups_test.php4
-rw-r--r--tests/functional/viewforum_paging_test.php256
-rw-r--r--tests/functions/build_url_test.php5
-rw-r--r--tests/functions/get_remote_file_test.php4
-rw-r--r--tests/functions/make_clickable_email_test.php222
-rw-r--r--tests/functions/make_clickable_test.php180
-rw-r--r--tests/functions/validate_username_test.php1
-rw-r--r--tests/functions_acp/insert_config_array_test.php (renamed from tests/functions/insert_config_array_test.php)2
-rw-r--r--tests/functions_acp/validate_config_vars_test.php87
-rw-r--r--tests/mock/controller_helper.php3
-rw-r--r--tests/mock/event_dispatcher.php13
-rw-r--r--tests/mock/file_downloader.php27
-rw-r--r--tests/mock/metadata_manager.php2
-rw-r--r--tests/mock/request.php21
-rw-r--r--tests/notification/base.php3
-rw-r--r--tests/notification/group_request_test.php1
-rw-r--r--tests/notification/submit_post_base.php5
-rw-r--r--tests/pagination/config/routing.yml4
-rw-r--r--tests/pagination/pagination_test.php42
-rw-r--r--tests/pagination/templates/pagination_double_nested.html19
-rw-r--r--tests/pagination/templates/pagination_sub.html17
-rw-r--r--tests/passwords/drivers_test.php2
-rw-r--r--tests/passwords/manager_test.php20
-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/search/fixtures/posts.xml10
-rw-r--r--tests/search/native_test.php50
-rw-r--r--tests/security/base.php50
-rw-r--r--tests/security/extract_current_page_test.php49
-rw-r--r--tests/security/redirect_test.php4
-rw-r--r--tests/session/extract_page_test.php47
-rw-r--r--tests/session/session_key_test.php19
-rw-r--r--tests/template/ext/include/css/styles/all/theme/child_only.css0
-rw-r--r--tests/template/ext/include/css/styles/all/theme/test.css0
-rw-r--r--tests/template/template_includecss_test.php86
-rw-r--r--tests/template/templates/includecss.html11
-rw-r--r--tests/test_framework/phpbb_database_test_case.php47
-rw-r--r--tests/test_framework/phpbb_database_test_connection_manager.php19
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php35
-rw-r--r--tests/test_framework/phpbb_session_test_case.php6
-rw-r--r--tests/test_framework/phpbb_test_case.php2
-rw-r--r--tests/test_framework/phpbb_ui_test_case.php204
-rw-r--r--tests/tree/nestedset_forum_base.php2
-rw-r--r--tests/ui/quick_links_test.php27
-rw-r--r--tests/upload/filespec_test.php5
-rw-r--r--tests/version/version_fetch_test.php1
-rw-r--r--tests/version/version_helper_remote_test.php173
-rw-r--r--tests/version/version_test.php3
-rw-r--r--tests/wrapper/gmgetdate_test.php13
104 files changed, 2983 insertions, 369 deletions
diff --git a/tests/auth/provider_db_test.php b/tests/auth/provider_db_test.php
index e33eae6b54..09ca0816bf 100644
--- a/tests/auth/provider_db_test.php
+++ b/tests/auth/provider_db_test.php
@@ -78,7 +78,14 @@ class phpbb_auth_provider_db_test extends phpbb_database_test_case
),
);
- $this->assertEquals($expected, $provider->login('foobar', 'example'));
+ $login_return = $provider->login('foobar', 'example');
+ $this->assertEquals($expected['status'], $login_return['status']);
+ $this->assertEquals($expected['error_msg'], $login_return['error_msg']);
+
+ foreach ($expected['user_row'] as $key => $value)
+ {
+ $this->assertEquals($value, $login_return['user_row'][$key]);
+ }
// Check if convert works
$login_return = $provider->login('foobar2', 'example');
diff --git a/tests/avatar/fixtures/users.xml b/tests/avatar/fixtures/users.xml
index 3e6586e909..1773d438c2 100644
--- a/tests/avatar/fixtures/users.xml
+++ b/tests/avatar/fixtures/users.xml
@@ -29,5 +29,33 @@
<value></value>
<value></value>
</row>
+ <row>
+ <value>3</value>
+ <value>foo</value>
+ <value></value>
+ <value></value>
+ <value>g5_1414350991.jpg</value>
+ <value>avatar.driver.upload</value>
+ <value>80</value>
+ <value>80</value>
+ </row>
+ </table>
+ <table name="phpbb_groups">
+ <column>group_id</column>
+ <column>group_type</column>
+ <column>group_name</column>
+ <column>group_avatar</column>
+ <column>group_avatar_type</column>
+ <column>group_avatar_width</column>
+ <column>group_avatar_height</column>
+ <row>
+ <value>5</value>
+ <value>3</value>
+ <value>ADMINISTRATORS</value>
+ <value>g5_1414350991.jpg</value>
+ <value>avatar.driver.upload</value>
+ <value>80</value>
+ <value>80</value>
+ </row>
</table>
</dataset>
diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php
index 81c153aed4..a109a7b5de 100644
--- a/tests/avatar/manager_test.php
+++ b/tests/avatar/manager_test.php
@@ -299,17 +299,32 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
public function data_handle_avatar_delete()
{
return array(
- array(array(
- 'avatar' => '',
- 'avatar_type' => '',
- 'avatar_width' => 0,
- 'avatar_height' => 0,
- ), 1, array(
- 'avatar' => 'foobar@example.com',
- 'avatar_type' => 'avatar.driver.gravatar',
- 'avatar_width' => '16',
- 'avatar_height' => '16',
- ), USERS_TABLE, 'user_'),
+ array(
+ array(
+ 'avatar' => '',
+ 'avatar_type' => '',
+ 'avatar_width' => 0,
+ 'avatar_height' => 0,
+ ), 1, array(
+ 'avatar' => 'foobar@example.com',
+ 'avatar_type' => 'avatar.driver.gravatar',
+ 'avatar_width' => '16',
+ 'avatar_height' => '16',
+ ), USERS_TABLE, 'user_',
+ ),
+ array(
+ array(
+ 'avatar' => '',
+ 'avatar_type' => '',
+ 'avatar_width' => 0,
+ 'avatar_height' => 0,
+ ), 5, array(
+ 'avatar' => 'g5_1414350991.jpg',
+ 'avatar_type' => 'avatar.driver.upload',
+ 'avatar_width' => '80',
+ 'avatar_height' => '80'
+ ), GROUPS_TABLE, 'group_',
+ ),
);
}
@@ -333,4 +348,23 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
$this->assertEquals($value, $row[$key]);
}
}
+
+ /**
+ * @dependsOn test_handle_avatar_delete
+ */
+ public function test_user_group_avatar_deleted()
+ {
+ $sql = 'SELECT * FROM ' . USERS_TABLE . '
+ WHERE user_id = 3';
+ $result = $this->db->sql_query_limit($sql, 1);
+ $row = $this->manager->clean_row($this->db->sql_fetchrow($result), 'user');
+ $this->db->sql_freeresult($result);
+
+ $this->assertEquals(array(
+ 'avatar' => '',
+ 'avatar_type' => '',
+ 'avatar_width' => 0,
+ 'avatar_height' => 0,
+ ), $row);
+ }
}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 40c6ef7dfa..0e81f4372a 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -33,3 +33,9 @@ require_once 'test_framework/phpbb_test_case.php';
require_once 'test_framework/phpbb_database_test_case.php';
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'))
+{
+ require_once __DIR__ . '/vendor/autoload.php';
+}
diff --git a/tests/cache/cache_memory.php b/tests/cache/cache_memory.php
new file mode 100644
index 0000000000..806edb963a
--- /dev/null
+++ b/tests/cache/cache_memory.php
@@ -0,0 +1,64 @@
+<?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_cache_memory extends \phpbb\cache\driver\memory
+{
+ protected $data = array();
+
+ /**
+ * Set cache path
+ */
+ function phpbb_cache_memory()
+ {
+ }
+
+ /**
+ * Fetch an item from the cache
+ *
+ * @access protected
+ * @param string $var Cache key
+ * @return mixed Cached data
+ */
+ function _read($var)
+ {
+ return $this->data[$var];
+ }
+
+ /**
+ * Store data in the cache
+ *
+ * @access protected
+ * @param string $var Cache key
+ * @param mixed $data Data to store
+ * @param int $ttl Time-to-live of cached data
+ * @return bool True if the operation succeeded
+ */
+ function _write($var, $data, $ttl = 2592000)
+ {
+ $this->data[$var] = $data;
+ return true;
+ }
+
+ /**
+ * Remove an item from the cache
+ *
+ * @access protected
+ * @param string $var Cache key
+ * @return bool True if the operation succeeded
+ */
+ function _delete($var)
+ {
+ unset($this->data[$var]);
+ return true;
+ }
+}
diff --git a/tests/cache/cache_memory_test.php b/tests/cache/cache_memory_test.php
new file mode 100644
index 0000000000..9f92e8d8dc
--- /dev/null
+++ b/tests/cache/cache_memory_test.php
@@ -0,0 +1,129 @@
+<?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__) . '/cache_memory.php';
+
+class phpbb_cache_memory_test extends phpbb_database_test_case
+{
+ protected $cache;
+ protected $db;
+
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/cache_memory.xml');
+ }
+
+ protected function setUp()
+ {
+ global $db;
+ parent::setUp();
+
+ $this->cache = new phpbb_cache_memory();
+ $db = $this->new_dbal();
+ $this->db = $db;
+ }
+
+ static public function cache_single_query_data()
+ {
+ return array(
+ array(
+ array(
+ array(
+ 'SELECT * FROM ' . POSTS_TABLE,
+ 3,
+ ),
+ ),
+ POSTS_TABLE,
+ ),
+ array(
+ array(
+ array(
+ 'SELECT * FROM ' . POSTS_TABLE,
+ 3,
+ ),
+ array(
+ 'SELECT * FROM ' . POSTS_TABLE . ' p
+ LEFT JOIN ' . TOPICS_TABLE . ' t ON p.topic_id = t.topic_id',
+ 3,
+ ),
+ ),
+ POSTS_TABLE,
+ ),
+ array(
+ array(
+ array(
+ 'SELECT * FROM ' . POSTS_TABLE,
+ 3,
+ ),
+ array(
+ 'SELECT * FROM ' . POSTS_TABLE . ' p
+ LEFT JOIN ' . TOPICS_TABLE . ' t ON p.topic_id = t.topic_id',
+ 3,
+ ),
+ array(
+ 'SELECT * FROM ' . POSTS_TABLE . ' p
+ LEFT JOIN ' . TOPICS_TABLE . ' t ON p.topic_id = t.topic_id
+ LEFT JOIN ' . USERS_TABLE . ' u ON p.poster_id = u.user_id',
+ 3,
+ ),
+ ),
+ POSTS_TABLE,
+ ),
+ array(
+ array(
+ array(
+ 'SELECT * FROM ' . POSTS_TABLE . ' p
+ LEFT JOIN ' . TOPICS_TABLE . ' t ON p.topic_id = t.topic_id',
+ 3,
+ ),
+ array(
+ 'SELECT * FROM ' . POSTS_TABLE . ' p
+ LEFT JOIN ' . TOPICS_TABLE . ' t ON p.topic_id = t.topic_id
+ LEFT JOIN ' . USERS_TABLE . ' u ON p.poster_id = u.user_id',
+ 3,
+ ),
+ ),
+ TOPICS_TABLE,
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider cache_single_query_data
+ */
+ public function test_cache_single_query($sql_queries, $table)
+ {
+ foreach ($sql_queries as $query)
+ {
+ $sql_request_res = $this->db->sql_query($query[0]);
+
+ $this->cache->sql_save($this->db, $query[0], $sql_request_res, 1);
+
+ $results = array();
+ $query_id = $this->cache->sql_load($query[0]);
+ while ($row = $this->cache->sql_fetchrow($query_id))
+ {
+ $results[] = $row;
+ }
+ $this->cache->sql_freeresult($query_id);
+ $this->assertEquals($query[1], sizeof($results));
+ }
+
+ $this->cache->destroy('sql', $table);
+
+ foreach ($sql_queries as $query)
+ {
+ $this->assertNotEquals(false, $this->cache->sql_load($query[0]));
+ }
+ }
+}
diff --git a/tests/cache/fixtures/cache_memory.xml b/tests/cache/fixtures/cache_memory.xml
new file mode 100644
index 0000000000..9c19ebb7ba
--- /dev/null
+++ b/tests/cache/fixtures/cache_memory.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_topics">
+ <column>topic_id</column>
+ <column>forum_id</column>
+ <column>topic_title</column>
+ <column>topic_first_post_id</column>
+ <column>topic_last_post_id</column>
+ <row>
+ <value>1</value>
+ <value>1</value>
+ <value>Topic</value>
+ <value>2</value>
+ <value>2</value>
+ </row>
+ </table>
+ <table name="phpbb_posts">
+ <column>post_id</column>
+ <column>poster_id</column>
+ <column>topic_id</column>
+ <column>forum_id</column>
+ <column>post_text</column>
+ <row>
+ <value>1</value>
+ <value>1</value>
+ <value>1</value>
+ <value>1</value>
+ <value>Post 1</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>2</value>
+ <value>1</value>
+ <value>1</value>
+ <value>Post 2</value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>3</value>
+ <value>1</value>
+ <value>1</value>
+ <value>Post 3</value>
+ </row>
+ </table>
+ <table name="phpbb_users">
+ <column>user_id</column>
+ <column>user_posts</column>
+ <column>username</column>
+ <column>username_clean</column>
+ <column>user_permissions</column>
+ <column>user_sig</column>
+ <row>
+ <value>1</value>
+ <value>1</value>
+ <value>user 1</value>
+ <value>user 1</value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>1</value>
+ <value>user 2</value>
+ <value>user 2</value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>1</value>
+ <value>user 3</value>
+ <value>user 3</value>
+ <value></value>
+ <value></value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/composer.json b/tests/composer.json
new file mode 100644
index 0000000000..69512f30a6
--- /dev/null
+++ b/tests/composer.json
@@ -0,0 +1,5 @@
+{
+ "require-dev": {
+ "facebook/webdriver": "dev-master"
+ }
+}
diff --git a/tests/composer.lock b/tests/composer.lock
new file mode 100644
index 0000000000..f714495d84
--- /dev/null
+++ b/tests/composer.lock
@@ -0,0 +1,66 @@
+{
+ "_readme": [
+ "This file locks the dependencies of your project to a known state",
+ "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
+ ],
+ "hash": "cf1d8a4841e5e669b148e0df6645a788",
+ "packages": [
+
+ ],
+ "packages-dev": [
+ {
+ "name": "facebook/webdriver",
+ "version": "dev-master",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/facebook/php-webdriver.git",
+ "reference": "b6e002e5bf811a8edba393ce6872322c1b7cf796"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/facebook/php-webdriver/zipball/b6e002e5bf811a8edba393ce6872322c1b7cf796",
+ "reference": "b6e002e5bf811a8edba393ce6872322c1b7cf796",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.19"
+ },
+ "require-dev": {
+ "phpdocumentor/phpdocumentor": "2.*",
+ "phpunit/phpunit": "3.7.*"
+ },
+ "type": "library",
+ "autoload": {
+ "classmap": [
+ "lib/"
+ ]
+ },
+ "notification-url": "http://packagist.org/downloads/",
+ "license": [
+ "Apache-2.0"
+ ],
+ "description": "A php client for WebDriver",
+ "homepage": "https://github.com/facebook/php-webdriver",
+ "keywords": [
+ "facebook",
+ "php",
+ "selenium",
+ "webdriver"
+ ],
+ "time": "2014-08-05 02:55:46"
+ }
+ ],
+ "aliases": [
+
+ ],
+ "minimum-stability": "stable",
+ "stability-flags": {
+ "facebook/webdriver": 20
+ },
+ "platform": [
+
+ ],
+ "platform-dev": [
+
+ ]
+}
diff --git a/tests/console/cache/purge_test.php b/tests/console/cache/purge_test.php
new file mode 100644
index 0000000000..96988c1028
--- /dev/null
+++ b/tests/console/cache/purge_test.php
@@ -0,0 +1,95 @@
+<?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.
+*
+*/
+
+use Symfony\Component\Console\Application;
+use Symfony\Component\Console\Tester\CommandTester;
+use phpbb\console\command\cache\purge;
+
+require_once dirname(__FILE__) . '/../../../phpBB/includes/functions_admin.php';
+
+class phpbb_console_command_cache_purge_test extends phpbb_test_case
+{
+ protected $cache_dir;
+ protected $cache;
+ protected $command_name;
+ protected $db;
+ protected $config;
+
+ public function __construct()
+ {
+ $this->cache_dir = dirname(__FILE__) . '/tmp/cache/';
+ }
+
+ protected function setUp()
+ {
+ if (file_exists($this->cache_dir))
+ {
+ // cache directory possibly left after aborted
+ // or failed run earlier
+ $this->remove_cache_dir();
+ }
+ $this->create_cache_dir();
+
+ $this->cache = new \phpbb\cache\driver\file($this->cache_dir);
+
+ $this->db = $this->getMock('\phpbb\db\driver\driver_interface');
+
+ $this->config = new \phpbb\config\config(array('assets_version' => 1));
+ $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
+ }
+
+ public function test_purge()
+ {
+ $this->cache->put('test_key', 'test_value');
+
+ $this->assertEquals(
+ 'test_value',
+ $this->cache->get('test_key'),
+ 'File ACM put and get'
+ );
+
+ $command_tester = $this->get_command_tester();
+ $exit_status = $command_tester->execute(array('command' => $this->command_name));
+
+ $this->assertSame(false, $this->cache->get('test_key'));
+ $this->assertSame(2, $this->config['assets_version']);
+ }
+
+ private function create_cache_dir()
+ {
+ $this->get_test_case_helpers()->makedirs($this->cache_dir);
+ }
+
+ private function remove_cache_dir()
+ {
+ $iterator = new DirectoryIterator($this->cache_dir);
+ foreach ($iterator as $file)
+ {
+ if ($file != '.' && $file != '..')
+ {
+ unlink($this->cache_dir . '/' . $file);
+ }
+ }
+ rmdir($this->cache_dir);
+ }
+
+ 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\null(), $this->config));
+
+ $command = $application->find('cache:purge');
+ $this->command_name = $command->getName();
+ return new CommandTester($command);
+ }
+}
diff --git a/tests/console/cron/run_test.php b/tests/console/cron/run_test.php
index 029dc5249b..f76e967484 100644
--- a/tests/console/cron/run_test.php
+++ b/tests/console/cron/run_test.php
@@ -16,6 +16,7 @@ use Symfony\Component\Console\Tester\CommandTester;
use phpbb\console\command\cron\run;
require_once dirname(__FILE__) . '/tasks/simple.php';
+require_once dirname(__FILE__) . '/../../../phpBB/includes/functions.php';
class phpbb_console_command_cron_run_test extends phpbb_database_test_case
{
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/common_helper_route.php b/tests/controller/common_helper_route.php
index 1751578a75..6723e3bc52 100644
--- a/tests/controller/common_helper_route.php
+++ b/tests/controller/common_helper_route.php
@@ -56,23 +56,28 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
return 'app.php';
}
+ protected function path_to_app()
+ {
+ return '';
+ }
+
protected function generate_route_objects()
{
- $request = new phpbb_mock_request();
- $request->overwrite('SCRIPT_NAME', $this->get_uri(), \phpbb\request\request_interface::SERVER);
- $request->overwrite('SCRIPT_FILENAME', $this->get_script_name(), \phpbb\request\request_interface::SERVER);
- $request->overwrite('REQUEST_URI', $this->get_uri(), \phpbb\request\request_interface::SERVER);
- $request->overwrite('SERVER_NAME', 'localhost', \phpbb\request\request_interface::SERVER);
- $request->overwrite('SERVER_PORT', '80', \phpbb\request\request_interface::SERVER);
+ $this->request = new phpbb_mock_request();
+ $this->request->overwrite('SCRIPT_NAME', $this->get_uri(), \phpbb\request\request_interface::SERVER);
+ $this->request->overwrite('SCRIPT_FILENAME', $this->get_script_name(), \phpbb\request\request_interface::SERVER);
+ $this->request->overwrite('REQUEST_URI', $this->get_uri(), \phpbb\request\request_interface::SERVER);
+ $this->request->overwrite('SERVER_NAME', 'localhost', \phpbb\request\request_interface::SERVER);
+ $this->request->overwrite('SERVER_PORT', '80', \phpbb\request\request_interface::SERVER);
$this->symfony_request = new \phpbb\symfony_request(
- $request
+ $this->request
);
$this->filesystem = new \phpbb\filesystem();
$this->phpbb_path_helper = new \phpbb\path_helper(
$this->symfony_request,
$this->filesystem,
- $this->getMock('\phpbb\request\request'),
+ $this->request,
$phpbb_root_path,
$phpEx
);
@@ -93,30 +98,30 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
public function helper_url_data_no_rewrite()
{
return array(
- array('controller2', array('t' => 1, 'f' => 2), true, false, '/app.php/foo/bar?t=1&amp;f=2', 'parameters in params-argument as array'),
- array('controller2', array('t' => 1, 'f' => 2), false, false, '/app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, '/app.php/foo/bar/p-3?t=1&amp;f=2', 'parameters in params-argument as array'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, '/app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
+ array('controller2', array('t' => 1, 'f' => 2), true, false, '/' . $this->path_to_app() . 'app.php/foo/bar?t=1&amp;f=2', 'parameters in params-argument as array'),
+ array('controller2', array('t' => 1, 'f' => 2), false, false, '/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, '/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&amp;f=2', 'parameters in params-argument as array'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, '/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
// Custom sid parameter
- array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', '/app.php/foo/bar?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
- array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', '/app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', '/app.php/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', '/' . $this->path_to_app() . 'app.php/foo/bar?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', '/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', '/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
// Testing anchors
- array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, '/app.php/foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
- array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, '/app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, '/app.php/foo/bar/p-3?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, '/' . $this->path_to_app() . 'app.php/foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, '/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, '/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
// Anchors and custom sid
- array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '/app.php/foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
- array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', '/app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '/app.php/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '/' . $this->path_to_app() . 'app.php/foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', '/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
// Empty parameters should not append the &amp; or ?
- array('controller2', array(), true, false, '/app.php/foo/bar', 'no params using empty array'),
- array('controller2', array(), false, false, '/app.php/foo/bar', 'no params using empty array'),
- array('controller3', array('p' => 3), true, false, '/app.php/foo/bar/p-3', 'no params using empty array'),
+ array('controller2', array(), true, false, '/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'),
+ array('controller2', array(), false, false, '/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'),
+ array('controller3', array('p' => 3), true, false, '/' . $this->path_to_app() . 'app.php/foo/bar/p-3', 'no params using empty array'),
);
}
@@ -125,37 +130,37 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
*/
public function test_helper_url_no_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
{
- $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
+ $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id));
}
public function helper_url_data_with_rewrite()
{
return array(
- array('controller2', array('t' => 1, 'f' => 2), true, false, '/foo/bar?t=1&amp;f=2', 'parameters in params-argument as array'),
- array('controller2', array('t' => 1, 'f' => 2), false, false, '/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, '/foo/bar/p-3?t=1&amp;f=2', 'parameters in params-argument as array'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, '/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
+ array('controller2', array('t' => 1, 'f' => 2), true, false, '/' . $this->path_to_app() . 'foo/bar?t=1&amp;f=2', 'parameters in params-argument as array'),
+ array('controller2', array('t' => 1, 'f' => 2), false, false, '/' . $this->path_to_app() . 'foo/bar?t=1&f=2', 'parameters in params-argument as array'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, '/' . $this->path_to_app() . 'foo/bar/p-3?t=1&amp;f=2', 'parameters in params-argument as array'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, '/' . $this->path_to_app() . 'foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
// Custom sid parameter
- array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', '/foo/bar?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
- array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', '/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', '/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', '/' . $this->path_to_app() . 'foo/bar?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', '/' . $this->path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', '/' . $this->path_to_app() . 'foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
// Testing anchors
- array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, '/foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
- array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, '/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, '/foo/bar/p-3?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, '/' . $this->path_to_app() . 'foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, '/' . $this->path_to_app() . 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, '/' . $this->path_to_app() . 'foo/bar/p-3?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
// Anchors and custom sid
- array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '/foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
- array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', '/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '/' . $this->path_to_app() . 'foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', '/' . $this->path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '/' . $this->path_to_app() . 'foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
// Empty parameters should not append the &amp; or ?
- array('controller2', array(), true, false, '/foo/bar', 'no params using empty array'),
- array('controller2', array(), false, false, '/foo/bar', 'no params using empty array'),
- array('controller3', array('p' => 3), true, false, '/foo/bar/p-3', 'no params using empty array'),
+ array('controller2', array(), true, false, '/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'),
+ array('controller2', array(), false, false, '/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'),
+ array('controller3', array('p' => 3), true, false, '/' . $this->path_to_app() . 'foo/bar/p-3', 'no params using empty array'),
);
}
@@ -165,37 +170,37 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
public function test_helper_url_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
{
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
- $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
+ $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id));
}
public function helper_url_data_absolute()
{
return array(
- array('controller2', array('t' => 1, 'f' => 2), true, false, 'http://localhost/app.php/foo/bar?t=1&amp;f=2', 'parameters in params-argument as array'),
- array('controller2', array('t' => 1, 'f' => 2), false, false, 'http://localhost/app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, 'http://localhost/app.php/foo/bar/p-3?t=1&amp;f=2', 'parameters in params-argument as array'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, 'http://localhost/app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
+ array('controller2', array('t' => 1, 'f' => 2), true, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&amp;f=2', 'parameters in params-argument as array'),
+ array('controller2', array('t' => 1, 'f' => 2), false, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&amp;f=2', 'parameters in params-argument as array'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
// Custom sid parameter
- array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', 'http://localhost/app.php/foo/bar?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
- array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', 'http://localhost/app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', 'http://localhost/app.php/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
// Testing anchors
- array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'http://localhost/app.php/foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
- array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, 'http://localhost/app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'http://localhost/app.php/foo/bar/p-3?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
// Anchors and custom sid
- array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'http://localhost/app.php/foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
- array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', 'http://localhost/app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'http://localhost/app.php/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
// Empty parameters should not append the &amp; or ?
- array('controller2', array(), true, false, 'http://localhost/app.php/foo/bar', 'no params using empty array'),
- array('controller2', array(), false, false, 'http://localhost/app.php/foo/bar', 'no params using empty array'),
- array('controller3', array('p' => 3), true, false, 'http://localhost/app.php/foo/bar/p-3', 'no params using empty array'),
+ array('controller2', array(), true, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'),
+ array('controller2', array(), false, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'),
+ array('controller3', array('p' => 3), true, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3', 'no params using empty array'),
);
}
@@ -205,7 +210,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
public function test_helper_url_absolute($route, $params, $is_amp, $session_id, $expected, $description)
{
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
- $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
+ $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL));
}
@@ -245,37 +250,37 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
public function test_helper_url_relative_path($route, $params, $is_amp, $session_id, $expected, $description)
{
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
- $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
+ $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH));
}
public function helper_url_data_network()
{
return array(
- array('controller2', array('t' => 1, 'f' => 2), true, false, '//localhost/app.php/foo/bar?t=1&amp;f=2', 'parameters in params-argument as array'),
- array('controller2', array('t' => 1, 'f' => 2), false, false, '//localhost/app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, '//localhost/app.php/foo/bar/p-3?t=1&amp;f=2', 'parameters in params-argument as array'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, '//localhost/app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
+ array('controller2', array('t' => 1, 'f' => 2), true, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&amp;f=2', 'parameters in params-argument as array'),
+ array('controller2', array('t' => 1, 'f' => 2), false, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&amp;f=2', 'parameters in params-argument as array'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
// Custom sid parameter
- array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', '//localhost/app.php/foo/bar?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
- array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', '//localhost/app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', '//localhost/app.php/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', '//localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', '//localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', '//localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
// Testing anchors
- array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, '//localhost/app.php/foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
- array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, '//localhost/app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, '//localhost/app.php/foo/bar/p-3?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
// Anchors and custom sid
- array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '//localhost/app.php/foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
- array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', '//localhost/app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '//localhost/app.php/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '//localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', '//localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '//localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
// Empty parameters should not append the &amp; or ?
- array('controller2', array(), true, false, '//localhost/app.php/foo/bar', 'no params using empty array'),
- array('controller2', array(), false, false, '//localhost/app.php/foo/bar', 'no params using empty array'),
- array('controller3', array('p' => 3), true, false, '//localhost/app.php/foo/bar/p-3', 'no params using empty array'),
+ array('controller2', array(), true, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'),
+ array('controller2', array(), false, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'),
+ array('controller3', array('p' => 3), true, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3', 'no params using empty array'),
);
}
@@ -285,37 +290,37 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
public function test_helper_url_network($route, $params, $is_amp, $session_id, $expected, $description)
{
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
- $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
+ $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH));
}
//TODO
public function helper_url_data_absolute_with_rewrite()
{
return array(
- array('controller2', array('t' => 1, 'f' => 2), true, false, 'http://localhost/foo/bar?t=1&amp;f=2', 'parameters in params-argument as array'),
- array('controller2', array('t' => 1, 'f' => 2), false, false, 'http://localhost/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, 'http://localhost/foo/bar/p-3?t=1&amp;f=2', 'parameters in params-argument as array'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, 'http://localhost/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
+ array('controller2', array('t' => 1, 'f' => 2), true, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar?t=1&amp;f=2', 'parameters in params-argument as array'),
+ array('controller2', array('t' => 1, 'f' => 2), false, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2', 'parameters in params-argument as array'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar/p-3?t=1&amp;f=2', 'parameters in params-argument as array'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
// Custom sid parameter
- array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', 'http://localhost/foo/bar?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
- array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', 'http://localhost/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', 'http://localhost/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', 'http://localhost/' . $this->path_to_app() . 'foo/bar?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', 'http://localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', 'http://localhost/' . $this->path_to_app() . 'foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
// Testing anchors
- array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'http://localhost/foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
- array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, 'http://localhost/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'http://localhost/foo/bar/p-3?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar/p-3?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
// Anchors and custom sid
- array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'http://localhost/foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
- array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', 'http://localhost/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'http://localhost/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'http://localhost/' . $this->path_to_app() . 'foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', 'http://localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'http://localhost/' . $this->path_to_app() . 'foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
// Empty parameters should not append the &amp; or ?
- array('controller2', array(), true, false, 'http://localhost/foo/bar', 'no params using empty array'),
- array('controller2', array(), false, false, 'http://localhost/foo/bar', 'no params using empty array'),
- array('controller3', array('p' => 3), true, false, 'http://localhost/foo/bar/p-3', 'no params using empty array'),
+ array('controller2', array(), true, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'),
+ array('controller2', array(), false, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'),
+ array('controller3', array('p' => 3), true, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar/p-3', 'no params using empty array'),
);
}
@@ -325,7 +330,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
public function test_helper_url_absolute_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
{
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
- $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
+ $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL));
}
@@ -365,37 +370,37 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
public function test_helper_url_relative_path_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
{
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
- $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
+ $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH));
}
public function helper_url_data_network_with_rewrite()
{
return array(
- array('controller2', array('t' => 1, 'f' => 2), true, false, '//localhost/foo/bar?t=1&amp;f=2', 'parameters in params-argument as array'),
- array('controller2', array('t' => 1, 'f' => 2), false, false, '//localhost/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, '//localhost/foo/bar/p-3?t=1&amp;f=2', 'parameters in params-argument as array'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, '//localhost/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
+ array('controller2', array('t' => 1, 'f' => 2), true, false, '//localhost/' . $this->path_to_app() . 'foo/bar?t=1&amp;f=2', 'parameters in params-argument as array'),
+ array('controller2', array('t' => 1, 'f' => 2), false, false, '//localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2', 'parameters in params-argument as array'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, '//localhost/' . $this->path_to_app() . 'foo/bar/p-3?t=1&amp;f=2', 'parameters in params-argument as array'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, '//localhost/' . $this->path_to_app() . 'foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
// Custom sid parameter
- array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', '//localhost/foo/bar?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
- array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', '//localhost/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', '//localhost/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', '//localhost/' . $this->path_to_app() . 'foo/bar?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', '//localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', '//localhost/' . $this->path_to_app() . 'foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
// Testing anchors
- array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, '//localhost/foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
- array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, '//localhost/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, '//localhost/foo/bar/p-3?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, '//localhost/' . $this->path_to_app() . 'foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, '//localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, '//localhost/' . $this->path_to_app() . 'foo/bar/p-3?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
// Anchors and custom sid
- array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '//localhost/foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
- array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', '//localhost/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
- array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '//localhost/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '//localhost/' . $this->path_to_app() . 'foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', '//localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '//localhost/' . $this->path_to_app() . 'foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
// Empty parameters should not append the &amp; or ?
- array('controller2', array(), true, false, '//localhost/foo/bar', 'no params using empty array'),
- array('controller2', array(), false, false, '//localhost/foo/bar', 'no params using empty array'),
- array('controller3', array('p' => 3), true, false, '//localhost/foo/bar/p-3', 'no params using empty array'),
+ array('controller2', array(), true, false, '//localhost/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'),
+ array('controller2', array(), false, false, '//localhost/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'),
+ array('controller3', array('p' => 3), true, false, '//localhost/' . $this->path_to_app() . 'foo/bar/p-3', 'no params using empty array'),
);
}
@@ -405,7 +410,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_test_case
public function test_helper_url_network_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
{
$this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
- $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
+ $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, $this->symfony_request, $this->request, $this->filesystem, $this->root_path, 'php', dirname(__FILE__) . '/');
$this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH));
}
}
diff --git a/tests/controller/config/routing.yml b/tests/controller/config/routing.yml
index 175b11f130..1e7df02684 100644
--- a/tests/controller/config/routing.yml
+++ b/tests/controller/config/routing.yml
@@ -1,3 +1,3 @@
core_controller:
- pattern: /core_foo
+ path: /core_foo
defaults: { _controller: core_foo.controller:bar }
diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php
index 58bcf0ef81..62feee3fed 100644
--- a/tests/controller/controller_test.php
+++ b/tests/controller/controller_test.php
@@ -11,6 +11,8 @@
*
*/
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
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/controller/helper_route_other_app.php b/tests/controller/helper_route_other_app.php
new file mode 100644
index 0000000000..e5513a5180
--- /dev/null
+++ b/tests/controller/helper_route_other_app.php
@@ -0,0 +1,37 @@
+<?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_helper_route.php';
+
+class phpbb_controller_helper_route_other_app_test extends phpbb_controller_common_helper_route
+{
+ protected function get_phpbb_root_path()
+ {
+ return './../';
+ }
+
+ protected function get_uri()
+ {
+ return '/foo/app.php';
+ }
+
+ protected function get_script_name()
+ {
+ return 'app.php';
+ }
+
+ protected function path_to_app()
+ {
+ return 'foo/';
+ }
+}
diff --git a/tests/datetime/from_format_test.php b/tests/datetime/from_format_test.php
index 0f87abc180..8968619bb5 100644
--- a/tests/datetime/from_format_test.php
+++ b/tests/datetime/from_format_test.php
@@ -60,44 +60,44 @@ class phpbb_datetime_from_format_test extends phpbb_test_case
// If the current time is too close to the testing time,
// the relative time will use "x minutes ago" instead of "today ..."
// So we use 18:01 in the morning and 06:01 in the afternoon.
- $testing_time = date('H') <= 12 ? '06:01' : '18:01';
+ $testing_time = gmdate('H') <= 12 ? '18:01' : '06:01';
return array(
array(
- date('Y-m-d', time() + 2 * 86400) . ' ' . $testing_time, false,
- date('Y-m-d', time() + 2 * 86400) . ' ' . $testing_time,
+ gmdate('Y-m-d', time() + 2 * 86400) . ' ' . $testing_time, false,
+ gmdate('Y-m-d', time() + 2 * 86400) . ' ' . $testing_time,
),
array(
- date('Y-m-d', time() + 86400) . ' ' . $testing_time, false,
+ gmdate('Y-m-d', time() + 86400) . ' ' . $testing_time, false,
'Tomorrow ' . $testing_time,
),
array(
- date('Y-m-d', time() + 86400) . ' ' . $testing_time, true,
- date('Y-m-d', time() + 86400) . ' ' . $testing_time,
+ gmdate('Y-m-d', time() + 86400) . ' ' . $testing_time, true,
+ gmdate('Y-m-d', time() + 86400) . ' ' . $testing_time,
),
array(
- date('Y-m-d') . ' ' . $testing_time, false,
+ gmdate('Y-m-d') . ' ' . $testing_time, false,
'Today ' . $testing_time,
),
array(
- date('Y-m-d') . ' ' . $testing_time, true,
- date('Y-m-d') . ' ' . $testing_time,
+ gmdate('Y-m-d') . ' ' . $testing_time, true,
+ gmdate('Y-m-d') . ' ' . $testing_time,
),
array(
- date('Y-m-d', time() - 86400) . ' ' . $testing_time, false,
+ gmdate('Y-m-d', time() - 86400) . ' ' . $testing_time, false,
'Yesterday ' . $testing_time,
),
array(
- date('Y-m-d', time() - 86400) . ' ' . $testing_time, true,
- date('Y-m-d', time() - 86400) . ' ' . $testing_time,
+ gmdate('Y-m-d', time() - 86400) . ' ' . $testing_time, true,
+ gmdate('Y-m-d', time() - 86400) . ' ' . $testing_time,
),
array(
- date('Y-m-d', time() - 2 * 86400) . ' ' . $testing_time, false,
- date('Y-m-d', time() - 2 * 86400) . ' ' . $testing_time,
+ gmdate('Y-m-d', time() - 2 * 86400) . ' ' . $testing_time, false,
+ gmdate('Y-m-d', time() - 2 * 86400) . ' ' . $testing_time,
),
);
}
diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php
index 51f9daacfb..5832b966d8 100644
--- a/tests/dbal/db_tools_test.php
+++ b/tests/dbal/db_tools_test.php
@@ -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..4c4306888c 100644
--- a/tests/dbal/migrator_test.php
+++ b/tests/dbal/migrator_test.php
@@ -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/event/fixtures/trigger_wspace.test b/tests/event/fixtures/trigger_wspace.test
new file mode 100644
index 0000000000..0334a9c80b
--- /dev/null
+++ b/tests/event/fixtures/trigger_wspace.test
@@ -0,0 +1,15 @@
+<?php
+
+ /**
+ * Event after the post data has been assigned to the template
+ *
+ * @event core.trigger
+ * @var int start Start item of this page
+ * @var int current_row_number Number of the post on this page
+ * @var int end Number of posts on this page
+ * @var array row Array with original post and user data
+ * @var array cp_row Custom profile field data of the poster
+ * @since 3.1.0-a3
+ */
+ $vars = array('start', 'current_row_number', 'end', 'row', 'cp_row');
+ extract($phpbb_dispatcher->trigger_event('core.trigger', compact($vars)));
diff --git a/tests/event/php_exporter_test.php b/tests/event/php_exporter_test.php
index b52d68e305..692a57f93c 100644
--- a/tests/event/php_exporter_test.php
+++ b/tests/event/php_exporter_test.php
@@ -62,6 +62,18 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
),
),
array(
+ 'trigger_wspace.test',
+ array(
+ 'core.trigger' => array(
+ 'event' => 'core.trigger',
+ 'file' => 'trigger_wspace.test',
+ 'arguments' => array('cp_row', 'current_row_number', 'end', 'row', 'start'),
+ 'since' => '3.1.0-a3',
+ 'description' => 'Event after the post data has been assigned to the template',
+ ),
+ ),
+ ),
+ array(
'trigger_many_vars.test',
array(
'core.posting_modify_template_vars' => array(
@@ -119,6 +131,7 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
array('* @since 3.1.0-b3', '3.1.0-b3'),
array(' * @since 3.1.0-b3', '3.1.0-b3'),
array('* @since 3.1.0-RC2', '3.1.0-RC2'),
+ array(' * @since 3.1.0-a1', '3.1.0-a1'),
);
}
@@ -133,7 +146,6 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
static public function validate_since_throws_data()
{
return array(
- array(' * @since 3.1.0-a1'),
array('* @since 3.1.0-a1 '),
array('* @since 3.1.0-a1 bertie is cool'),
array('bertie* @since 3.1.0-a1'),
@@ -156,6 +168,7 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
return array(
array('test.event', '* @event test.event', 'test.event'),
array('test.event2', ' * @event test.event2', 'test.event2'),
+ array('test.event', ' * @event test.event', 'test.event'),
);
}
@@ -170,7 +183,6 @@ class phpbb_event_php_exporter_test extends phpbb_test_case
static public function validate_event_throws_data()
{
return array(
- array('test.event', ' * @event test.event', 1),
array('test.event', '* @event test.event bertie is cool', 2),
array('test.event', 'bertie* @event test.event', 2),
);
diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php
index 5c7cad89f6..0eeb060936 100644
--- a/tests/extension/manager_test.php
+++ b/tests/extension/manager_test.php
@@ -156,7 +156,10 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
$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 8e27b39459..2a746d3792 100644
--- a/tests/extension/metadata_manager_test.php
+++ b/tests/extension/metadata_manager_test.php
@@ -62,7 +62,10 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
new \phpbb\template\context()
);
+ $container = new phpbb_mock_container_builder();
+
$this->migrator = new \phpbb\db\migrator(
+ $container,
$this->config,
$this->db,
$this->db_tools,
@@ -73,7 +76,6 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
array(),
new \phpbb\db\migration\helper()
);
- $container = new phpbb_mock_container_builder();
$container->set('migrator', $this->migrator);
$this->extension_manager = new \phpbb\extension\manager(
@@ -123,6 +125,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_attachments_test.php b/tests/functional/acp_attachments_test.php
new file mode 100644
index 0000000000..8e810a508a
--- /dev/null
+++ b/tests/functional/acp_attachments_test.php
@@ -0,0 +1,78 @@
+<?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_attachments_test extends phpbb_functional_test_case
+{
+ public function data_imagick_path_linux()
+ {
+ return array(
+ array('/usr/bin', 'Configuration updated successfully'),
+ array('/usr/foobar', 'The entered path “/usr/foobar” does not exist.'),
+ array('/usr/bin/which', 'The entered path “/usr/bin/which” is not a directory.'),
+ );
+ }
+
+ /**
+ * @dataProvider data_imagick_path_linux
+ */
+ public function test_imagick_path_linux($imagick_path, $expected)
+ {
+ if (strtolower(substr(PHP_OS, 0, 5)) !== 'linux')
+ {
+ $this->markTestSkipped('Unable to test linux specific paths on other OS.');
+ }
+
+ $this->login();
+ $this->admin_login();
+
+ $crawler = self::request('GET', 'adm/index.php?i=attachments&mode=attach&sid=' . $this->sid);
+
+ $form = $crawler->selectButton('Submit')->form(array('config[img_imagick]' => $imagick_path));
+
+ $crawler = self::submit($form);
+ $this->assertContains($expected, $crawler->filter('#main')->text());
+ }
+
+ public function data_imagick_path_windows()
+ {
+ return array(
+ array('C:\Windows', 'Configuration updated successfully'),
+ array('C:\Windows\foobar1', 'The entered path “C:\Windows\foobar1” does not exist.'),
+ array('C:\Windows\explorer.exe', 'The entered path “C:\Windows\explorer.exe” is not a directory.'),
+ );
+ }
+
+ /**
+ * @dataProvider data_imagick_path_windows
+ */
+ public function test_imagick_path_windows($imagick_path, $expected)
+ {
+ if (strtolower(substr(PHP_OS, 0, 3)) !== 'win')
+ {
+ $this->markTestSkipped('Unable to test windows specific paths on other OS.');
+ }
+
+ $this->login();
+ $this->admin_login();
+
+ $crawler = self::request('GET', 'adm/index.php?i=attachments&mode=attach&sid=' . $this->sid);
+
+ $form = $crawler->selectButton('Submit')->form(array('config[img_imagick]' => $imagick_path));
+
+ $crawler = self::submit($form);
+ $this->assertContains($expected, $crawler->filter('#main')->text());
+ }
+}
diff --git a/tests/functional/acp_groups_test.php b/tests/functional/acp_groups_test.php
index 4eb4747572..9dfdc93474 100644
--- a/tests/functional/acp_groups_test.php
+++ b/tests/functional/acp_groups_test.php
@@ -11,12 +11,12 @@
*
*/
-require_once dirname(__FILE__) . '/common_groups_test.php';
+require_once dirname(__FILE__) . '/common_groups_test_case.php';
/**
* @group functional
*/
-class phpbb_functional_acp_groups_test extends phpbb_functional_common_groups_test
+class phpbb_functional_acp_groups_test extends phpbb_functional_common_groups_test_case
{
protected $form_data;
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/acp_registration_test.php b/tests/functional/acp_registration_test.php
new file mode 100644
index 0000000000..ef9843679e
--- /dev/null
+++ b/tests/functional/acp_registration_test.php
@@ -0,0 +1,55 @@
+<?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_registration_test extends phpbb_functional_test_case
+{
+ protected function set_email_enable($db, $status)
+ {
+ $sql = "UPDATE phpbb_config
+ SET config_value = '" . (($status) ? '1' : '0') . "'
+ WHERE config_name = 'email_enable'";
+ $db->sql_query($sql);
+
+ $this->purge_cache();
+ }
+
+ public function test_submitting_activation_method()
+ {
+ $db = $this->get_db();
+
+ $this->set_email_enable($db, false);
+
+ $this->add_lang('acp/board');
+ $this->login();
+ $this->admin_login();
+
+ $crawler = self::request('GET', 'adm/index.php?i=acp_board&mode=registration&sid=' . $this->sid);
+ $this->assertContainsLang('ACP_REGISTER_SETTINGS_EXPLAIN', $this->get_content());
+
+ $form = $crawler->selectButton($this->lang('SUBMIT'))->form();
+ $form['config[require_activation]']->select(USER_ACTIVATION_ADMIN);
+ $crawler = self::submit($form);
+ $this->assertContainsLang('ACC_ACTIVATION_WARNING', $crawler->filter('div.main')->text());
+
+ $crawler = self::request('GET', 'adm/index.php?i=acp_board&mode=registration&sid=' . $this->sid);
+ $form = $crawler->selectButton($this->lang('SUBMIT'))->form();
+ $form['config[require_activation]']->select(USER_ACTIVATION_NONE);
+ $crawler = self::submit($form);
+ $this->assertNotContainsLang('ACC_ACTIVATION_WARNING', $crawler->filter('div.main')->text());
+
+ $this->set_email_enable($db, true);
+ }
+}
diff --git a/tests/functional/auth_test.php b/tests/functional/auth_test.php
index b4b4279bf1..76e1709afb 100644
--- a/tests/functional/auth_test.php
+++ b/tests/functional/auth_test.php
@@ -34,6 +34,25 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case
}
/**
+ * @dependsOn test_login_other
+ */
+ public function test_login_ucp_other_auth_provider()
+ {
+ global $cache, $config;
+ $cache = new phpbb_mock_null_cache;
+ $db = $this->get_db();
+ $sql = 'UPDATE ' . CONFIG_TABLE . " SET config_value = 'foobar' WHERE config_name = 'auth_method'";
+ $db->sql_query($sql);
+ $config['auth_method'] = 'foobar';
+ $this->login('anothertestuser');
+ $crawler = self::request('GET', 'index.php');
+ $this->assertContains('anothertestuser', $crawler->filter('#username_logged_in')->text());
+ $sql = 'UPDATE ' . CONFIG_TABLE . " SET config_value = 'db' WHERE config_name = 'auth_method'";
+ $db->sql_query($sql);
+ $config['auth_method'] = 'db';
+ }
+
+ /**
* @depends test_login
*/
public function test_logout()
diff --git a/tests/functional/avatar_acp_groups_test.php b/tests/functional/avatar_acp_groups_test.php
index 925335a2f7..ca8c84ab2e 100644
--- a/tests/functional/avatar_acp_groups_test.php
+++ b/tests/functional/avatar_acp_groups_test.php
@@ -11,12 +11,12 @@
*
*/
-require_once dirname(__FILE__) . '/common_avatar_test.php';
+require_once dirname(__FILE__) . '/common_avatar_test_case.php';
/**
* @group functional
*/
-class phpbb_functional_avatar_acp_groups_test extends phpbb_functional_common_avatar_test
+class phpbb_functional_avatar_acp_groups_test extends phpbb_functional_common_avatar_test_case
{
public function get_url()
{
diff --git a/tests/functional/avatar_acp_users_test.php b/tests/functional/avatar_acp_users_test.php
index 5eca473157..8b05a28658 100644
--- a/tests/functional/avatar_acp_users_test.php
+++ b/tests/functional/avatar_acp_users_test.php
@@ -11,12 +11,12 @@
*
*/
-require_once dirname(__FILE__) . '/common_avatar_test.php';
+require_once dirname(__FILE__) . '/common_avatar_test_case.php';
/**
* @group functional
*/
-class phpbb_functional_avatar_acp_users_test extends phpbb_functional_common_avatar_test
+class phpbb_functional_avatar_acp_users_test extends phpbb_functional_common_avatar_test_case
{
public function get_url()
{
diff --git a/tests/functional/avatar_ucp_groups_test.php b/tests/functional/avatar_ucp_groups_test.php
index 1e8ca911c6..52ef67543e 100644
--- a/tests/functional/avatar_ucp_groups_test.php
+++ b/tests/functional/avatar_ucp_groups_test.php
@@ -10,12 +10,12 @@
* the docs/CREDITS.txt file.
*
*/
-require_once dirname(__FILE__) . '/common_avatar_test.php';
+require_once dirname(__FILE__) . '/common_avatar_test_case.php';
/**
* @group functional
*/
-class phpbb_functional_avatar_ucp_groups_test extends phpbb_functional_common_avatar_test
+class phpbb_functional_avatar_ucp_groups_test extends phpbb_functional_common_avatar_test_case
{
public function get_url()
{
diff --git a/tests/functional/avatar_ucp_users_test.php b/tests/functional/avatar_ucp_users_test.php
index 972bfa0fb2..2f0832e092 100644
--- a/tests/functional/avatar_ucp_users_test.php
+++ b/tests/functional/avatar_ucp_users_test.php
@@ -11,12 +11,12 @@
*
*/
-require_once dirname(__FILE__) . '/common_avatar_test.php';
+require_once dirname(__FILE__) . '/common_avatar_test_case.php';
/**
* @group functional
*/
-class phpbb_functional_avatar_ucp_users_test extends phpbb_functional_common_avatar_test
+class phpbb_functional_avatar_ucp_users_test extends phpbb_functional_common_avatar_test_case
{
public function get_url()
{
diff --git a/tests/functional/common_avatar_test.php b/tests/functional/common_avatar_test_case.php
index 82d7136c98..924eb1273c 100644
--- a/tests/functional/common_avatar_test.php
+++ b/tests/functional/common_avatar_test_case.php
@@ -14,7 +14,7 @@
/**
* @group functional
*/
-abstract class phpbb_functional_common_avatar_test extends phpbb_functional_test_case
+abstract class phpbb_functional_common_avatar_test_case extends phpbb_functional_test_case
{
private $path;
private $form_content;
@@ -62,7 +62,7 @@ abstract class phpbb_functional_common_avatar_test extends phpbb_functional_test
{
if (is_array($value))
{
- $form[$key]->$value[0]($value[1]);
+ $form[$key]->{$value[0]}($value[1]);
}
else
{
diff --git a/tests/functional/common_groups_test.php b/tests/functional/common_groups_test_case.php
index 748d4d5e0a..521b7c84d2 100644
--- a/tests/functional/common_groups_test.php
+++ b/tests/functional/common_groups_test_case.php
@@ -14,7 +14,7 @@
/**
* @group functional
*/
-abstract class phpbb_functional_common_groups_test extends phpbb_functional_test_case
+abstract class phpbb_functional_common_groups_test_case extends phpbb_functional_test_case
{
abstract protected function get_url();
diff --git a/tests/functional/download_test.php b/tests/functional/download_test.php
index 4e4995c21e..1e863210e6 100644
--- a/tests/functional/download_test.php
+++ b/tests/functional/download_test.php
@@ -66,6 +66,11 @@ class phpbb_functional_download_test extends phpbb_functional_test_case
public function test_download_accessible()
{
+ if (!class_exists('finfo'))
+ {
+ $this->markTestSkipped('Unable to run test with fileinfo disabled');
+ }
+
$this->load_ids(array(
'forums' => array(
'Download #1',
@@ -118,6 +123,11 @@ class phpbb_functional_download_test extends phpbb_functional_test_case
public function test_download_softdeleted_post()
{
+ if (!class_exists('finfo'))
+ {
+ $this->markTestSkipped('Unable to run test with fileinfo disabled');
+ }
+
$this->load_ids(array(
'forums' => array(
'Download #1',
@@ -180,6 +190,11 @@ class phpbb_functional_download_test extends phpbb_functional_test_case
public function test_download_softdeleted_topic()
{
+ if (!class_exists('finfo'))
+ {
+ $this->markTestSkipped('Unable to run test with fileinfo disabled');
+ }
+
$this->load_ids(array(
'forums' => array(
'Download #1',
diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php
index 7aa2d0da7d..9041c8dc69 100644
--- a/tests/functional/feed_test.php
+++ b/tests/functional/feed_test.php
@@ -322,15 +322,9 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
$post = $this->create_topic($this->data['forums']['Feeds #news'], 'Feeds #news - Topic #1', 'This is a test topic posted by the testing framework.');
$this->data['topics']['Feeds #news - Topic #1'] = (int) $post['topic_id'];
- // Travis is too fast, so we have to wait
- sleep(1);
-
$post = $this->create_topic($this->data['forums']['Feeds #news'], 'Feeds #news - Topic #2', 'This is a test topic posted by the testing framework.');
$crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
- // Travis is too fast, so we have to wait
- sleep(1);
-
$this->assertContains('Feeds #news - Topic #2', $crawler->filter('html')->text());
$this->data['topics']['Feeds #news - Topic #2'] = (int) $post['topic_id'];
$this->data['posts']['Feeds #news - Topic #2'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p');
@@ -456,9 +450,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
$post = $this->create_topic($this->data['forums']['Feeds #1'], 'Feeds #1 - Topic #1', 'This is a test topic posted by the testing framework.');
$this->data['topics']['Feeds #1 - Topic #1'] = (int) $post['topic_id'];
- // Travis is too fast, so we have to wait
- sleep(1);
-
$post = $this->create_topic($this->data['forums']['Feeds #1.1'], 'Feeds #1.1 - Topic #1', 'This is a test topic posted by the testing framework.');
$this->data['topics']['Feeds #1.1 - Topic #1'] = (int) $post['topic_id'];
}
@@ -494,9 +485,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
$post = $this->create_topic($this->data['forums']['Feeds #1'], 'Feeds #1 - Topic #2', 'This is a test topic posted by the testing framework.');
$this->data['topics']['Feeds #1 - Topic #2'] = (int) $post['topic_id'];
- // Travis is too fast, so we have to wait
- sleep(1);
-
// Test creating a reply
$post2 = $this->create_post($this->data['forums']['Feeds #1'], $post['topic_id'], 'Re: Feeds #1 - Topic #2', 'This is a test post posted by the testing framework.');
$crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}");
@@ -852,9 +840,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
'Feeds #1.1',
),
));
-
- // We have to wait because of the flood interval.
- sleep(15);
+ $this->set_flood_interval(0);
$this->login('disapprove_user');
$post = $this->create_topic($this->data['forums']['Feeds #1.1'], 'Feeds #1.1 - Topic #3', 'This is a test topic posted by the testing framework.', array(), 'POST_STORED_MOD');
@@ -862,6 +848,27 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
$crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Feeds #1.1']}&sid={$this->sid}");
$this->assertNotContains('Feeds #1.1 - Topic #3', $crawler->filter('html')->text());
+
+ $this->logout();
+ $this->set_flood_interval(15);
+ }
+
+ protected function set_flood_interval($flood_interval)
+ {
+ $this->login();
+ $this->admin_login();
+
+ $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());
+
+ $this->logout();
}
public function test_feeds_unapproved_topic_admin()
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/memberlist_test.php b/tests/functional/memberlist_test.php
index c76ba6e37d..1da5c39401 100644
--- a/tests/functional/memberlist_test.php
+++ b/tests/functional/memberlist_test.php
@@ -106,4 +106,32 @@ class phpbb_functional_memberlist_test extends phpbb_functional_test_case
$this->assertContains('admin', $crawler->eq(0)->text());
$this->assertNotContains('admin', $crawler->eq(1)->text());
}
+
+ public function test_group_rank()
+ {
+ copy(__DIR__ . '/fixtures/files/valid.jpg', __DIR__ . '/../../phpBB/images/ranks/valid.jpg');
+
+ $this->login();
+ $this->admin_login();
+ $this->add_lang(array('acp/groups', 'acp/posting'));
+
+ // Set a group rank to the registered users
+ $crawler = self::request('GET', "adm/index.php?sid={$this->sid}&i=acp_groups&mode=manage&action=edit&g=2");
+ $form = $crawler->selectButton('Submit')->form();
+ $form['group_rank']->select('1');
+ $crawler = self::submit($form);
+ $this->assertContainsLang('GROUP_UPDATED', $crawler->filter('.successbox')->text());
+
+ // Set a rank image for site_admin
+ $crawler = self::request('GET', "adm/index.php?sid={$this->sid}&i=acp_ranks&mode=ranks&action=edit&id=1");
+ $form = $crawler->selectButton('Submit')->form();
+ $form['rank_image']->select('valid.jpg');
+ $crawler = self::submit($form);
+ $this->assertContainsLang('RANK_UPDATED', $crawler->filter('.successbox')->text());
+
+ $crawler = self::request('GET', 'memberlist.php?mode=group&g=2');
+ $this->assertContains('memberlist-test-user', $crawler->text());
+
+ unlink(__DIR__ . '/../../phpBB/images/ranks/valid.jpg');
+ }
}
diff --git a/tests/functional/notification_test.php b/tests/functional/notification_test.php
index 667d268b1e..ec03f7a6a4 100644
--- a/tests/functional/notification_test.php
+++ b/tests/functional/notification_test.php
@@ -82,8 +82,6 @@ class phpbb_functional_notification_test extends phpbb_functional_test_case
// Get form token
$link = $crawler->selectLink($this->lang('NOTIFICATIONS_MARK_ALL_READ'))->link()->getUri();
$crawler = self::request('GET', substr($link, strpos($link, 'ucp.')));
- $form = $crawler->selectButton($this->lang('YES'))->form();
- $crawler = self::submit($form);
$this->assertEquals(0, $crawler->filter('#notification_list_button strong')->text());
}
}
diff --git a/tests/functional/prune_shadow_topic_test.php b/tests/functional/prune_shadow_topic_test.php
index 84f07e9802..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(
@@ -129,8 +129,8 @@ class phpbb_functional_prune_shadow_topic_test extends phpbb_functional_test_cas
$result = $this->db->sql_query($sql);
$crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Prune Shadow']}&sid={$this->sid}");
- $cron_link = $crawler->filter('img')->last()->attr('src');
- $crawler = self::request('GET', $cron_link . "&sid={$this->sid}", array(), false);
+ $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);
$this->assert_forum_details($this->data['forums']['Prune Shadow'], array(
'forum_posts_approved' => 0,
diff --git a/tests/functional/registration_test.php b/tests/functional/registration_test.php
index 45a684db19..690f4ae9f2 100644
--- a/tests/functional/registration_test.php
+++ b/tests/functional/registration_test.php
@@ -45,12 +45,23 @@ class phpbb_functional_registration_test extends phpbb_functional_test_case
$form = $crawler->selectButton('Submit')->form(array(
'username' => 'user-reg-test',
'email' => 'user-reg-test@phpbb.com',
- 'new_password' => 'testtest',
- 'password_confirm' => 'testtest',
+ 'new_password' => 'user-reg-testuser-reg-test',
+ 'password_confirm' => 'user-reg-testuser-reg-test',
));
$form['tz']->select('Europe/Berlin');
$crawler = self::submit($form);
$this->assertContainsLang('ACCOUNT_ADDED', $crawler->filter('#message')->text());
}
+
+ /**
+ * @depends test_register_new_account
+ */
+ public function test_default_subscription_options()
+ {
+ $this->login('user-reg-test');
+ $crawler = self::request('GET', 'ucp.php?i=ucp_notifications&mode=notification_options&sid=' . $this->sid);
+ $this->assert_checkbox_is_checked($crawler, 'notification.type.post_notification.method.email');
+ $this->assert_checkbox_is_checked($crawler, 'notification.type.topic_notification.method.email');
+ }
}
diff --git a/tests/functional/ucp_groups_test.php b/tests/functional/ucp_groups_test.php
index 2b075b37a5..cd18a0fcae 100644
--- a/tests/functional/ucp_groups_test.php
+++ b/tests/functional/ucp_groups_test.php
@@ -11,12 +11,12 @@
*
*/
-require_once dirname(__FILE__) . '/common_groups_test.php';
+require_once dirname(__FILE__) . '/common_groups_test_case.php';
/**
* @group functional
*/
-class phpbb_functional_ucp_groups_test extends phpbb_functional_common_groups_test
+class phpbb_functional_ucp_groups_test extends phpbb_functional_common_groups_test_case
{
protected $db;
diff --git a/tests/functional/viewforum_paging_test.php b/tests/functional/viewforum_paging_test.php
new file mode 100644
index 0000000000..4a574bebbb
--- /dev/null
+++ b/tests/functional/viewforum_paging_test.php
@@ -0,0 +1,256 @@
+<?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 viewforum_paging_test extends phpbb_functional_test_case
+{
+ protected $data = array();
+
+ 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(array(
+ 'forum_name' => 'Viewforum Pagination Test #1',
+ ));
+ $crawler = self::submit($form);
+ $form = $crawler->selectButton('update')->form(array(
+ 'forum_perm_from' => 2,
+ ));
+ self::submit($form);
+
+ $crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}");
+ $form = $crawler->selectButton('addforum')->form(array(
+ 'forum_name' => 'Viewforum Pagination Test #2',
+ ));
+ $crawler = self::submit($form);
+ $form = $crawler->selectButton('update')->form(array(
+ 'forum_perm_from' => 2,
+ ));
+ self::submit($form);
+
+ $this->set_post_settings(array(
+ 'flood_interval' => 0,
+ 'topics_per_page' => 3,
+ ));
+ }
+
+ public function test_create_posts()
+ {
+ $this->login();
+ $this->load_ids(array(
+ 'forums' => array(
+ 'Viewforum Pagination Test #1',
+ 'Viewforum Pagination Test #2',
+ ),
+ ));
+
+ $this->assert_forum_details($this->data['forums']['Viewforum Pagination Test #1'], array(
+ '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');
+
+ for ($topic_id = 1; $topic_id <= 6; $topic_id++)
+ {
+ $this->create_topic($this->data['forums']['Viewforum Pagination Test #1'], 'Viewforum Pagination TestTopic #' . $topic_id, 'This is a test topic posted by the testing framework.');
+ }
+
+ $this->create_topic($this->data['forums']['Viewforum Pagination Test #2'], 'Viewforum Pagination TestTopic #GA1', 'This is a test topic posted by the testing framework.', array(
+ 'topic_type' => POST_GLOBAL,
+ ));
+
+ $this->assert_forum_details($this->data['forums']['Viewforum Pagination Test #1'], array(
+ 'forum_posts_approved' => 6,
+ 'forum_posts_unapproved' => 0,
+ 'forum_posts_softdeleted' => 0,
+ 'forum_topics_approved' => 6,
+ 'forum_topics_unapproved' => 0,
+ 'forum_topics_softdeleted' => 0,
+ ), 'after creating topics');
+
+ $this->assert_forum_details($this->data['forums']['Viewforum Pagination Test #2'], array(
+ 'forum_posts_approved' => 1,
+ 'forum_posts_unapproved' => 0,
+ 'forum_posts_softdeleted' => 0,
+ 'forum_topics_approved' => 1,
+ 'forum_topics_unapproved' => 0,
+ 'forum_topics_softdeleted' => 0,
+ ), 'after creating GA');
+
+ // Set flood interval back to 15
+ $this->admin_login();
+ $this->set_post_settings(array(
+ 'flood_interval' => 15,
+ ));
+ }
+
+ public function test_viewforum_first_page()
+ {
+ $this->load_ids(array(
+ 'forums' => array(
+ 'Viewforum Pagination Test #1',
+ 'Viewforum Pagination Test #2',
+ ),
+ ));
+ $crawler = self::request('GET', 'viewforum.php?f=' . $this->data['forums']['Viewforum Pagination Test #1']);
+
+ // Test the topics that are displayed
+ $topiclists = $crawler->filter('.forumbg .topics');
+ $this->assertEquals(2, $topiclists->count());
+ $topiclist = $topiclists->eq(0)->filter('li');
+ $this->assertStringEndsWith('TestTopic #GA1', $topiclist->eq(0)->filter('.topictitle')->text());
+ $topiclist = $topiclists->eq(1)->filter('li');
+ $this->assertStringEndsWith('TestTopic #6', $topiclist->eq(0)->filter('.topictitle')->text());
+ $this->assertStringEndsWith('TestTopic #5', $topiclist->eq(1)->filter('.topictitle')->text());
+ $this->assertStringEndsWith('TestTopic #4', $topiclist->eq(2)->filter('.topictitle')->text());
+
+ // Test the pagination, should only have: 1 - 2 - Next
+ $this->assertEquals(2, $crawler->filter('div.pagination')->count());
+ $top_pagination = $crawler->filter('div.pagination')->eq(0);
+ $this->assertEquals(3, $top_pagination->filter('li')->count(), 'Number of pagination items on page 1 does not match');
+ $this->assertContains('1', $top_pagination->filter('li')->eq(0)->text());
+ $this->assertContains('2', $top_pagination->filter('li')->eq(1)->text());
+ $this->assertContainsLang('NEXT', $top_pagination->filter('li')->eq(2)->text());
+ }
+
+ public function test_viewforum_second_page()
+ {
+ $this->load_ids(array(
+ 'forums' => array(
+ 'Viewforum Pagination Test #1',
+ 'Viewforum Pagination Test #2',
+ ),
+ ));
+ $crawler = self::request('GET', 'viewforum.php?f=' . $this->data['forums']['Viewforum Pagination Test #1'] . '&start=3');
+
+ // Test the topics that are displayed
+ $topiclists = $crawler->filter('.forumbg .topics');
+ $this->assertEquals(2, $topiclists->count());
+ $topiclist = $topiclists->eq(0)->filter('li');
+ $this->assertStringEndsWith('TestTopic #GA1', $topiclist->eq(0)->filter('.topictitle')->text());
+ $topiclist = $topiclists->eq(1)->filter('li');
+ $this->assertStringEndsWith('TestTopic #3', $topiclist->eq(0)->filter('.topictitle')->text());
+ $this->assertStringEndsWith('TestTopic #2', $topiclist->eq(1)->filter('.topictitle')->text());
+ $this->assertStringEndsWith('TestTopic #1', $topiclist->eq(2)->filter('.topictitle')->text());
+
+ // Test the pagination, should only have: Previous - 1 - 2
+ $this->assertEquals(2, $crawler->filter('div.pagination')->count());
+ $top_pagination = $crawler->filter('div.pagination')->eq(0);
+ $this->assertEquals(3, $top_pagination->filter('li')->count(), 'Number of pagination items on page 2 does not match');
+ $this->assertContainsLang('PREVIOUS', $top_pagination->filter('li')->eq(0)->text());
+ $this->assertContains('1', $top_pagination->filter('li')->eq(1)->text());
+ $this->assertContains('2', $top_pagination->filter('li')->eq(2)->text());
+ }
+
+ 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}");
+ }
+
+ /**
+ * Sets the post setting via the ACP page
+ *
+ * @param array $settings
+ */
+ protected function set_post_settings($settings)
+ {
+ $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_board&mode=post');
+
+ $form = $crawler->selectButton('Submit')->form();
+ $values = $form->getValues();
+
+ foreach ($settings as $setting => $value)
+ {
+ $values["config[{$setting}]"] = $value;
+ }
+ $form->setValues($values);
+ $crawler = self::submit($form);
+ $this->assertGreaterThan(0, $crawler->filter('.successbox')->count());
+ }
+
+ /**
+ * Loads forum, topic and post IDs
+ *
+ * @param array $data
+ */
+ protected function load_ids($data)
+ {
+ $this->db = $this->get_db();
+
+ if (!empty($data['forums']))
+ {
+ $sql = 'SELECT *
+ 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);
+ }
+ }
+}
diff --git a/tests/functions/build_url_test.php b/tests/functions/build_url_test.php
index 06415a424e..a59b94c744 100644
--- a/tests/functions/build_url_test.php
+++ b/tests/functions/build_url_test.php
@@ -69,6 +69,11 @@ class phpbb_build_url_test extends phpbb_test_case
array('f', 'style', 't'),
'http://test.phpbb.com/viewtopic.php?',
),
+ array(
+ 'posting.php?f=2&mode=delete&p=20%22%3Cscript%3Ealert%281%29%3B%3C%2Fscript%3E',
+ false,
+ 'phpBB/posting.php?f=2&amp;mode=delete&amp;p=20%22%3Cscript%3Ealert%281%29%3B%3C%2Fscript%3E',
+ )
);
}
diff --git a/tests/functions/get_remote_file_test.php b/tests/functions/get_remote_file_test.php
index d412dce164..612d82273e 100644
--- a/tests/functions/get_remote_file_test.php
+++ b/tests/functions/get_remote_file_test.php
@@ -21,6 +21,10 @@ class phpbb_functions_get_remote_file extends phpbb_test_case
{
public function test_version_phpbb_com()
{
+ global $phpbb_container;
+ $phpbb_container = new phpbb_mock_container_builder();
+ $phpbb_container->set('file_downloader', new \phpbb\file_downloader());
+
$hostname = 'version.phpbb.com';
if (!phpbb_checkdnsrr($hostname, 'A'))
diff --git a/tests/functions/make_clickable_email_test.php b/tests/functions/make_clickable_email_test.php
new file mode 100644
index 0000000000..4c802d0487
--- /dev/null
+++ b/tests/functions/make_clickable_email_test.php
@@ -0,0 +1,222 @@
+<?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';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php';
+
+class phpbb_functions_make_clickable_email_test extends phpbb_test_case
+{
+ protected function setUp()
+ {
+ parent::setUp();
+
+ global $config, $user, $request;
+ $user = new phpbb_mock_user();
+ $request = new phpbb_mock_request();
+ }
+
+ /**
+ * 'e' tag for email addresses html
+ **/
+ public function data_test_make_clickable_email_positive()
+ {
+ return array(
+ array(
+ 'nobody@phpbb.com',
+ '<!-- e --><a href="mailto:nobody@phpbb.com">nobody@phpbb.com</a><!-- e -->'
+ ),
+ array(
+ 'Nobody@sub.phpbb.com',
+ '<!-- e --><a href="mailto:Nobody@sub.phpbb.com">Nobody@sub.phpbb.com</a><!-- e -->'
+ ),
+ array(
+ 'alice.bob@foo.phpbb.com',
+ '<!-- e --><a href="mailto:alice.bob@foo.phpbb.com">alice.bob@foo.phpbb.com</a><!-- e -->'
+ ),
+ array(
+ 'alice-foo@bar.phpbb.com',
+ '<!-- e --><a href="mailto:alice-foo@bar.phpbb.com">alice-foo@bar.phpbb.com</a><!-- e -->'
+ ),
+ array(
+ 'alice_foo@bar.phpbb.com',
+ '<!-- e --><a href="mailto:alice_foo@bar.phpbb.com">alice_foo@bar.phpbb.com</a><!-- e -->'
+ ),
+ array(
+ 'alice+tag@foo.phpbb.com',
+ '<!-- e --><a href="mailto:alice+tag@foo.phpbb.com">alice+tag@foo.phpbb.com</a><!-- e -->'
+ ),
+ array(
+ 'alice&amp;tag@foo.phpbb.com',
+ '<!-- e --><a href="mailto:alice&amp;tag@foo.phpbb.com">alice&amp;tag@foo.phpbb.com</a><!-- e -->'
+ ),
+ array(
+ 'alice@phpbb.australia',
+ '<!-- e --><a href="mailto:alice@phpbb.australia">alice@phpbb.australia</a><!-- e -->'
+ ),
+
+ // Test shortened text for email > 55 characters long
+ // Email text should be turned into: first 39 chars + ' ... ' + last 10 chars
+ array(
+ 'alice@phpbb.topZlevelZdomainZnamesZcanZbeZupZtoZsixtyZthreeZcharactersZlong',
+ '<!-- e --><a href="mailto:alice@phpbb.topZlevelZdomainZnamesZcanZbeZupZtoZsixtyZthreeZcharactersZlong">alice@phpbb.topZlevelZdomainZnamesZcanZ ... ctersZlong</a><!-- e -->'
+ ),
+ array(
+ 'l3tt3rsAndNumb3rs@domain.com',
+ '<!-- e --><a href="mailto:l3tt3rsAndNumb3rs@domain.com">l3tt3rsAndNumb3rs@domain.com</a><!-- e -->'
+ ),
+ array(
+ 'has-dash@domain.com',
+ '<!-- e --><a href="mailto:has-dash@domain.com">has-dash@domain.com</a><!-- e -->'
+ ),
+ array(
+ 'hasApostrophe.o\'leary@domain.org',
+ '<!-- e --><a href="mailto:hasApostrophe.o\'leary@domain.org">hasApostrophe.o\'leary@domain.org</a><!-- e -->'
+ ),
+ array(
+ 'uncommonTLD@domain.museum',
+ '<!-- e --><a href="mailto:uncommonTLD@domain.museum">uncommonTLD@domain.museum</a><!-- e -->'
+ ),
+ array(
+ 'uncommonTLD@domain.travel',
+ '<!-- e --><a href="mailto:uncommonTLD@domain.travel">uncommonTLD@domain.travel</a><!-- e -->'
+ ),
+ array(
+ 'uncommonTLD@domain.mobi',
+ '<!-- e --><a href="mailto:uncommonTLD@domain.mobi">uncommonTLD@domain.mobi</a><!-- e -->'
+ ),
+ array(
+ 'countryCodeTLD@domain.uk',
+ '<!-- e --><a href="mailto:countryCodeTLD@domain.uk">countryCodeTLD@domain.uk</a><!-- e -->'
+ ),
+ array(
+ 'countryCodeTLD@domain.rw',
+ '<!-- e --><a href="mailto:countryCodeTLD@domain.rw">countryCodeTLD@domain.rw</a><!-- e -->'
+ ),
+ array(
+ 'numbersInDomain@911.com',
+ '<!-- e --><a href="mailto:numbersInDomain@911.com">numbersInDomain@911.com</a><!-- e -->'
+ ),
+ array(
+ 'underscore_inLocal@domain.net',
+ '<!-- e --><a href="mailto:underscore_inLocal@domain.net">underscore_inLocal@domain.net</a><!-- e -->'
+ ),
+ array(
+ 'IPInsteadOfDomain@127.0.0.1',
+ '<!-- e --><a href="mailto:IPInsteadOfDomain@127.0.0.1">IPInsteadOfDomain@127.0.0.1</a><!-- e -->'
+ ),
+ array(
+ 'IPAndPort@127.0.0.1:25',
+ '<!-- e --><a href="mailto:IPAndPort@127.0.0.1:25">IPAndPort@127.0.0.1:25</a><!-- e -->'
+ ),
+ array(
+ 'subdomain@sub.domain.com',
+ '<!-- e --><a href="mailto:subdomain@sub.domain.com">subdomain@sub.domain.com</a><!-- e -->'
+ ),
+ array(
+ 'local@dash-inDomain.com',
+ '<!-- e --><a href="mailto:local@dash-inDomain.com">local@dash-inDomain.com</a><!-- e -->'
+ ),
+ array(
+ 'dot.inLocal@foo.com',
+ '<!-- e --><a href="mailto:dot.inLocal@foo.com">dot.inLocal@foo.com</a><!-- e -->'
+ ),
+ array(
+ 'a@singleLetterLocal.org',
+ '<!-- e --><a href="mailto:a@singleLetterLocal.org">a@singleLetterLocal.org</a><!-- e -->'
+ ),
+ array(
+ 'singleLetterDomain@x.org',
+ '<!-- e --><a href="mailto:singleLetterDomain@x.org">singleLetterDomain@x.org</a><!-- e -->'
+ ),
+ array(
+ '&amp;*=?^+{}\'~@validCharsInLocal.net',
+ '<!-- e --><a href="mailto:&amp;*=?^+{}\'~@validCharsInLocal.net">&amp;*=?^+{}\'~@validCharsInLocal.net</a><!-- e -->'
+ ),
+ array(
+ 'foor@bar.newTLD',
+ '<!-- e --><a href="mailto:foor@bar.newTLD">foor@bar.newTLD</a><!-- e -->'
+ ),
+ );
+ }
+
+ public function data_test_make_clickable_email_negative()
+ {
+ return array(
+ array('foo.example.com'), // @ is missing
+ array('.foo.example.com'), // . as first character
+ array('Foo.@example.com'), // . is last in local part
+ array('foo..123@example.com'), // . doubled
+ array('a@b@c@example.com'), // @ doubled
+
+ // Emails with invalid characters
+ // (only 'valid' pieces having localparts prepended with one of the \n \t ( > chars should parsed if any)
+ array('()[]\;:,<>@example.com'), // invalid characters
+ array('abc(def@example.com', 'abc(<!-- e --><a href="mailto:def@example.com">def@example.com</a><!-- e -->'), // invalid character (
+ array('abc)def@example.com'), // invalid character )
+ array('abc[def@example.com'), // invalid character [
+ array('abc]def@example.com'), // invalid character ]
+ array('abc\def@example.com'), // invalid character \
+ array('abc;def@example.com'), // invalid character ;
+ array('abc:def@example.com'), // invalid character :
+ array('abc,def@example.com'), // invalid character ,
+ array('abc<def@example.com'), // invalid character <
+ array('abc>def@example.com', 'abc><!-- e --><a href="mailto:def@example.com">def@example.com</a><!-- e -->'), // invalid character >
+
+ // http://fightingforalostcause.net/misc/2006/compare-email-regex.php
+ array('missingDomain@.com'),
+ array('@missingLocal.org'),
+ array('missingatSign.net'),
+ array('missingDot@com'),
+ array('two@@signs.com'),
+ // Trailing colon is ignored
+ array('colonButNoPort@127.0.0.1:', '<!-- e --><a href="mailto:colonButNoPort@127.0.0.1">colonButNoPort@127.0.0.1</a><!-- e -->:'),
+
+ array(''),
+ // Trailing part after the 3rd dot is ignored
+ array('someone-else@127.0.0.1.26', '<!-- e --><a href="mailto:someone-else@127.0.0.1">someone-else@127.0.0.1</a><!-- e -->.26'),
+
+ array('.localStartsWithDot@domain.com'),
+ array('localEndsWithDot.@domain.com'),
+ array('two..consecutiveDots@domain.com'),
+ array('domainStartsWithDash@-domain.com'),
+ array('domainEndsWithDash@domain-.com'),
+ array('numbersInTLD@domain.c0m'),
+ array('missingTLD@domain.'),
+ array('! "#$%(),/;<>[]`|@invalidCharsInLocal.org'),
+ array('invalidCharsInDomain@! "#$%(),/;<>_[]`|.org'),
+ array('local@SecondLevelDomainNamesAreInvalidIfTheyAreLongerThan64Charactersss.org'),
+ // The domain zone name part after the 63rd char is ignored
+ array(
+ 'alice@phpbb.topZlevelZdomainZnamesZcanZbeZupZtoZsixtyZthreeZcharactersZlongZ',
+ '<!-- e --><a href="mailto:alice@phpbb.topZlevelZdomainZnamesZcanZbeZupZtoZsixtyZthreeZcharactersZlong">alice@phpbb.topZlevelZdomainZnamesZcanZ ... ctersZlong</a><!-- e -->Z'
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider data_test_make_clickable_email_positive
+ */
+ public function test_email_matching_positive($email, $expected)
+ {
+ $this->assertSame($expected, make_clickable($email));
+ }
+
+ /**
+ * @dataProvider data_test_make_clickable_email_negative
+ */
+ public function test_email_matching_negative($email, $expected = null)
+ {
+ $expected = ($expected) ?: $email;
+ $this->assertSame($expected, make_clickable($email));
+ }
+}
diff --git a/tests/functions/make_clickable_test.php b/tests/functions/make_clickable_test.php
new file mode 100644
index 0000000000..63beeb06b2
--- /dev/null
+++ b/tests/functions/make_clickable_test.php
@@ -0,0 +1,180 @@
+<?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';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php';
+
+class phpbb_functions_make_clickable_test extends phpbb_test_case
+{
+ /**
+ * Tags:
+ * 'm' - full URL like xxxx://aaaaa.bbb.cccc.
+ * 'l' - local relative board URL like http://domain.tld/path/to/board/index.php
+ * 'w' - URL without http/https protocol like www.xxxx.yyyy[/zzzz] aka 'lazy' URLs
+ * 'e' - email@domain type address
+ *
+ * Classes:
+ * "postlink-local" for 'l' URLs
+ * "postlink" for the rest of URLs
+ * empty for email addresses
+ **/
+ public function data_test_make_clickable_url_positive()
+ {
+ return array(
+ array(
+ 'http://www.phpbb.com/community/',
+ '<!-- m --><a class="postlink" href="http://www.phpbb.com/community/">http://www.phpbb.com/community/</a><!-- m -->'
+ ),
+ array(
+ 'http://www.phpbb.com/path/file.ext#section',
+ '<!-- m --><a class="postlink" href="http://www.phpbb.com/path/file.ext#section">http://www.phpbb.com/path/file.ext#section</a><!-- m -->'
+ ),
+ array(
+ 'ftp://ftp.phpbb.com/',
+ '<!-- m --><a class="postlink" href="ftp://ftp.phpbb.com/">ftp://ftp.phpbb.com/</a><!-- m -->'
+ ),
+ array(
+ 'sip://bantu@phpbb.com',
+ '<!-- m --><a class="postlink" href="sip://bantu@phpbb.com">sip://bantu@phpbb.com</a><!-- m -->'
+ ),
+ array(
+ 'www.phpbb.com/community/',
+ '<!-- w --><a class="postlink" href="http://www.phpbb.com/community/">www.phpbb.com/community/</a><!-- w -->'
+ ),
+ array(
+ 'http://testhost/viewtopic.php?t=1',
+ '<!-- l --><a class="postlink-local" href="http://testhost/viewtopic.php?t=1">viewtopic.php?t=1</a><!-- l -->'
+ ),
+ array(
+ 'email@domain.com',
+ '<!-- e --><a href="mailto:email@domain.com">email@domain.com</a><!-- e -->'
+ ),
+ // Test appending punctuation mark to the URL
+ array(
+ 'http://testhost/viewtopic.php?t=1!',
+ '<!-- l --><a class="postlink-local" href="http://testhost/viewtopic.php?t=1">viewtopic.php?t=1</a><!-- l -->!'
+ ),
+ array(
+ 'www.phpbb.com/community/?',
+ '<!-- w --><a class="postlink" href="http://www.phpbb.com/community/">www.phpbb.com/community/</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.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 -->'
+ ),
+ );
+ }
+
+ 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();
+
+ global $config, $user, $request;
+ $user = new phpbb_mock_user();
+ $request = new phpbb_mock_request();
+ }
+
+ /**
+ * @dataProvider data_test_make_clickable_url_positive
+ */
+ public function test_urls_matching_positive($url, $expected)
+ {
+ $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/functions/validate_username_test.php b/tests/functions/validate_username_test.php
index dc9f685f04..4fa5af7ff3 100644
--- a/tests/functions/validate_username_test.php
+++ b/tests/functions/validate_username_test.php
@@ -11,6 +11,7 @@
*
*/
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php';
require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
require_once dirname(__FILE__) . '/../mock/cache.php';
diff --git a/tests/functions/insert_config_array_test.php b/tests/functions_acp/insert_config_array_test.php
index bfcb05862e..1264b35bf4 100644
--- a/tests/functions/insert_config_array_test.php
+++ b/tests/functions_acp/insert_config_array_test.php
@@ -11,6 +11,8 @@
*
*/
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_acp.php';
+
class phpbb_functions_insert_config_array_test extends phpbb_test_case
{
public function config_display_vars()
diff --git a/tests/functions_acp/validate_config_vars_test.php b/tests/functions_acp/validate_config_vars_test.php
index 3c9af4a889..4bf6ba3984 100644
--- a/tests/functions_acp/validate_config_vars_test.php
+++ b/tests/functions_acp/validate_config_vars_test.php
@@ -162,4 +162,91 @@ class phpbb_functions_acp_validate_config_vars_test extends phpbb_test_case
$this->assertEquals($expected, $phpbb_error);
}
+
+ public function data_validate_path_linux()
+ {
+ return array(
+ array('/usr/bin', 'absolute_path', true),
+ array('/usr/bin/', 'absolute_path:50:200', true),
+ array('/usr/bin/which', 'absolute_path', 'DIRECTORY_NOT_DIR'),
+ array('/foo/bar', 'absolute_path', 'DIRECTORY_DOES_NOT_EXIST'),
+ array('C:\Windows', 'absolute_path', 'DIRECTORY_DOES_NOT_EXIST'),
+ array('.', 'absolute_path', true),
+ array('', 'absolute_path', true),
+ array('mkdir /foo/bar', 'absolute_path', 'DIRECTORY_DOES_NOT_EXIST'),
+ // Make sure above command didn't do anything
+ array('/foo/bar', 'absolute_path', 'DIRECTORY_DOES_NOT_EXIST'),
+ );
+ }
+
+ /**
+ * @dataProvider data_validate_path_linux
+ */
+ public function test_validate_path_linux($path, $validation_type, $expected)
+ {
+ if (strtolower(substr(PHP_OS, 0, 5)) !== 'linux')
+ {
+ $this->markTestSkipped('Unable to test linux specific paths on other OS.');
+ }
+
+ $error = array();
+ $config_ary = array(
+ 'path' => $path,
+ );
+
+ validate_config_vars(array(
+ 'path' => array('lang' => 'FOOBAR', 'validate' => $validation_type),
+ ),
+ $config_ary,
+ $error
+ );
+ }
+
+ public function data_validate_path_windows()
+ {
+ return array(
+ array('C:\Windows', 'absolute_path', true),
+ array('C:\Windows\\', 'absolute_path:50:200', true),
+ array('C:\Windows\explorer.exe', 'absolute_path', 'DIRECTORY_NOT_DIR'),
+ array('C:\foobar', 'absolute_path', 'DIRECTORY_DOES_NOT_EXIST'),
+ array('/usr/bin', 'absolute_path', 'DIRECTORY_DOES_NOT_EXIST'),
+ array('.', 'absolute_path', true),
+ array('', 'absolute_path', true),
+ array('mkdir C:\Windows\foobar', 'absolute_path', 'DIRECTORY_DOES_NOT_EXIST'),
+ // Make sure above command didn't do anything
+ array('C:\Windows\foobar', 'absolute_path', 'DIRECTORY_DOES_NOT_EXIST'),
+ );
+ }
+
+ /**
+ * @dataProvider data_validate_path_windows
+ */
+ public function test_validate_path_windows($path, $validation_type, $expected)
+ {
+ if (strtolower(substr(PHP_OS, 0, 3)) !== 'win')
+ {
+ $this->markTestSkipped('Unable to test windows specific paths on other OS.');
+ }
+
+ $error = array();
+ $config_ary = array(
+ 'path' => $path,
+ );
+
+ validate_config_vars(array(
+ 'path' => array('lang' => 'FOOBAR', 'validate' => $validation_type),
+ ),
+ $config_ary,
+ $error
+ );
+
+ if ($expected === true)
+ {
+ $this->assertEmpty($error);
+ }
+ else
+ {
+ $this->assertEquals(array($expected), $error);
+ }
+ }
}
diff --git a/tests/mock/controller_helper.php b/tests/mock/controller_helper.php
index 9c13c309f2..ae3e7bf432 100644
--- a/tests/mock/controller_helper.php
+++ b/tests/mock/controller_helper.php
@@ -13,12 +13,13 @@
class phpbb_mock_controller_helper extends \phpbb\controller\helper
{
- public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, \phpbb\symfony_request $symfony_request, \phpbb\filesystem $filesystem, $phpbb_root_path, $php_ext, $phpbb_root_path_ext)
+ public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, \phpbb\symfony_request $symfony_request, \phpbb\request\request_interface $request, \phpbb\filesystem $filesystem, $phpbb_root_path, $php_ext, $phpbb_root_path_ext)
{
$this->template = $template;
$this->user = $user;
$this->config = $config;
$this->symfony_request = $symfony_request;
+ $this->request = $request;
$this->filesystem = $filesystem;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
diff --git a/tests/mock/event_dispatcher.php b/tests/mock/event_dispatcher.php
index 613551bffd..fa8b4a1036 100644
--- a/tests/mock/event_dispatcher.php
+++ b/tests/mock/event_dispatcher.php
@@ -11,9 +11,18 @@
*
*/
-class phpbb_mock_event_dispatcher
+class phpbb_mock_event_dispatcher extends \phpbb\event\dispatcher
{
- public function trigger_event($eventName, $data)
+ /**
+ * Constructor.
+ *
+ * Overwrite the constructor to get rid of ContainerInterface param instance
+ */
+ public function __construct()
+ {
+ }
+
+ public function trigger_event($eventName, $data = array())
{
return array();
}
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/mock/request.php b/tests/mock/request.php
index 304fcf0eaf..e7217a94a9 100644
--- a/tests/mock/request.php
+++ b/tests/mock/request.php
@@ -114,4 +114,25 @@ class phpbb_mock_request implements \phpbb\request\request_interface
{
$this->data[$super_global] = array_merge($this->data[$super_global], $values);
}
+
+ public function escape($var, $multibyte)
+ {
+ $type_cast_helper = new \phpbb\request\type_cast_helper();
+ if (is_array($var))
+ {
+ $result = array();
+ foreach ($var as $key => $value)
+ {
+ $type_cast_helper->set_var($key, $key, gettype($key), $multibyte);
+ $result[$key] = $this->escape($value, $multibyte);
+ }
+ $var = $result;
+ }
+ else
+ {
+ $type_cast_helper->set_var($var, $var, 'string', $multibyte);
+ }
+
+ return $var;
+ }
}
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/group_request_test.php b/tests/notification/group_request_test.php
index afbc586601..0d1bda95ce 100644
--- a/tests/notification/group_request_test.php
+++ b/tests/notification/group_request_test.php
@@ -12,6 +12,7 @@
*/
require_once dirname(__FILE__) . '/base.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_notification_group_request_test extends phpbb_tests_notification_base
{
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/routing.yml b/tests/pagination/config/routing.yml
index dd667274cd..2ce082c9d1 100644
--- a/tests/pagination/config/routing.yml
+++ b/tests/pagination/config/routing.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/pagination/pagination_test.php b/tests/pagination/pagination_test.php
index 95856dd07d..ea6dd999c3 100644
--- a/tests/pagination/pagination_test.php
+++ b/tests/pagination/pagination_test.php
@@ -28,7 +28,7 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
global $phpbb_dispatcher;
- $phpbb_dispatcher = new phpbb_mock_event_dispatcher;
+ $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
$this->user->expects($this->any())
->method('lang')
@@ -57,8 +57,8 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
$request
);
- $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $provider, $manager, $symfony_request, $filesystem, '', 'php', dirname(__FILE__) . '/');
- $this->pagination = new \phpbb\pagination($this->template, $this->user, $this->helper);
+ $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $provider, $manager, $symfony_request, $request, $filesystem, '', 'php', dirname(__FILE__) . '/');
+ $this->pagination = new \phpbb\pagination($this->template, $this->user, $this->helper, $phpbb_dispatcher);
}
public function generate_template_pagination_data()
@@ -172,6 +172,42 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
$this->assertEquals(str_replace("\t", '', $expect), $this->display('test'));
}
+ /**
+ * @dataProvider generate_template_pagination_data
+ */
+ public function test_generate_template_pagination_sub($base_url, $start_name, $num_items, $per_page, $start_item, $expect)
+ {
+ // Block needs to be assigned before pagination
+ $this->template->assign_block_vars('sub', array(
+ 'FOO' => 'bar',
+ ));
+
+ $this->pagination->generate_template_pagination($base_url, 'sub.pagination', $start_name, $num_items, $per_page, $start_item);
+ $this->template->set_filenames(array('test' => 'pagination_sub.html'));
+
+ $this->assertEquals(str_replace("\t", '', $expect), $this->display('test'));
+ }
+
+ /**
+ * @dataProvider generate_template_pagination_data
+ */
+ public function test_generate_template_pagination_double_nested($base_url, $start_name, $num_items, $per_page, $start_item, $expect)
+ {
+ // Block needs to be assigned before pagination
+ $this->template->assign_block_vars('sub', array(
+ 'FOO' => 'bar',
+ ));
+
+ $this->template->assign_block_vars('sub.level2', array(
+ 'BAR' => 'foo',
+ ));
+
+ $this->pagination->generate_template_pagination($base_url, 'sub.level2.pagination', $start_name, $num_items, $per_page, $start_item);
+ $this->template->set_filenames(array('test' => 'pagination_double_nested.html'));
+
+ $this->assertEquals(str_replace("\t", '', $expect), $this->display('test'));
+ }
+
public function on_page_data()
{
return array(
diff --git a/tests/pagination/templates/pagination_double_nested.html b/tests/pagination/templates/pagination_double_nested.html
new file mode 100644
index 0000000000..c179248233
--- /dev/null
+++ b/tests/pagination/templates/pagination_double_nested.html
@@ -0,0 +1,19 @@
+pagination
+<!-- BEGIN sub -->
+<!-- BEGIN level2 -->
+:per_page:{sub.level2.PER_PAGE}
+:current_page:{sub.level2.CURRENT_PAGE}
+:base_url:{sub.level2.BASE_URL}
+<!-- BEGIN pagination -->
+<!-- IF sub.level2.pagination.S_IS_PREV -->:previous:{sub.level2.pagination.PAGE_NUMBER}:{sub.level2.pagination.PAGE_URL}
+<!-- ELSEIF sub.level2.pagination.S_IS_CURRENT -->:current:{sub.level2.pagination.PAGE_NUMBER}:{sub.level2.pagination.PAGE_URL}
+<!-- ELSEIF sub.level2.pagination.S_IS_ELLIPSIS -->:ellipsis:{sub.level2.pagination.PAGE_NUMBER}:{sub.level2.pagination.PAGE_URL}
+<!-- ELSEIF sub.level2.pagination.S_IS_NEXT -->:next:{sub.level2.pagination.PAGE_NUMBER}:{sub.level2.pagination.PAGE_URL}
+<!-- ELSE -->:else:{sub.level2.pagination.PAGE_NUMBER}:{sub.level2.pagination.PAGE_URL}
+<!-- ENDIF -->
+<!-- END pagination -->
+<!-- IF sub.level2.U_PREVIOUS_PAGE -->:u_prev:{sub.level2.U_PREVIOUS_PAGE}<!-- ENDIF -->
+
+<!-- IF sub.level2.U_NEXT_PAGE -->:u_next:{sub.level2.U_NEXT_PAGE}<!-- ENDIF -->
+<!-- END level2 -->
+<!-- END sub -->
diff --git a/tests/pagination/templates/pagination_sub.html b/tests/pagination/templates/pagination_sub.html
new file mode 100644
index 0000000000..4ec14039e0
--- /dev/null
+++ b/tests/pagination/templates/pagination_sub.html
@@ -0,0 +1,17 @@
+pagination
+<!-- BEGIN sub -->
+:per_page:{sub.PER_PAGE}
+:current_page:{sub.CURRENT_PAGE}
+:base_url:{sub.BASE_URL}
+<!-- BEGIN pagination -->
+<!-- IF sub.pagination.S_IS_PREV -->:previous:{sub.pagination.PAGE_NUMBER}:{sub.pagination.PAGE_URL}
+<!-- ELSEIF sub.pagination.S_IS_CURRENT -->:current:{sub.pagination.PAGE_NUMBER}:{sub.pagination.PAGE_URL}
+<!-- ELSEIF sub.pagination.S_IS_ELLIPSIS -->:ellipsis:{sub.pagination.PAGE_NUMBER}:{sub.pagination.PAGE_URL}
+<!-- ELSEIF sub.pagination.S_IS_NEXT -->:next:{sub.pagination.PAGE_NUMBER}:{sub.pagination.PAGE_URL}
+<!-- ELSE -->:else:{sub.pagination.PAGE_NUMBER}:{sub.pagination.PAGE_URL}
+<!-- ENDIF -->
+<!-- END pagination -->
+<!-- IF sub.U_PREVIOUS_PAGE -->:u_prev:{sub.U_PREVIOUS_PAGE}<!-- ENDIF -->
+
+<!-- IF sub.U_NEXT_PAGE -->:u_next:{sub.U_NEXT_PAGE}<!-- ENDIF -->
+<!-- END sub -->
diff --git a/tests/passwords/drivers_test.php b/tests/passwords/drivers_test.php
index ccfb05c40f..5f9fd523c9 100644
--- a/tests/passwords/drivers_test.php
+++ b/tests/passwords/drivers_test.php
@@ -35,7 +35,7 @@ class phpbb_passwords_helper_test extends \phpbb_test_case
'passwords.driver.md5_vb' => new \phpbb\passwords\driver\md5_vb($config, $this->driver_helper),
'passwords.driver.sha_xf1' => new \phpbb\passwords\driver\sha_xf1($config, $this->driver_helper),
);
- $this->passwords_drivers['passwords.driver.md5_phpbb2'] = new \phpbb\passwords\driver\md5_phpbb2($request, $this->passwords_drivers['passwords.driver.salted_md5'], $phpbb_root_path, $php_ext);
+ $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);
}
diff --git a/tests/passwords/manager_test.php b/tests/passwords/manager_test.php
index e46cf820f2..333834ee07 100644
--- a/tests/passwords/manager_test.php
+++ b/tests/passwords/manager_test.php
@@ -41,7 +41,7 @@ class phpbb_passwords_manager_test extends \phpbb_test_case
'passwords.driver.md5_vb' => new \phpbb\passwords\driver\md5_vb($config, $this->driver_helper),
'passwords.driver.sha_xf1' => new \phpbb\passwords\driver\sha_xf1($config, $this->driver_helper),
);
- $this->passwords_drivers['passwords.driver.md5_phpbb2'] = new \phpbb\passwords\driver\md5_phpbb2($request, $this->passwords_drivers['passwords.driver.salted_md5'], $phpbb_root_path, $php_ext);
+ $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);
$this->helper = new \phpbb\passwords\helper;
@@ -326,4 +326,22 @@ class phpbb_passwords_manager_test extends \phpbb_test_case
$this->assertFalse($this->manager->hash(str_repeat('a', 1024 * 1024 * 16)));
$this->assertLessThanOrEqual(5, time() - $start_time);
}
+
+ public function data_test_string_compare()
+ {
+ return array(
+ array('foo', 'bar', false),
+ array(1, '1', false),
+ array('one', 'one', true),
+ array('foobar', 'foobaf', false),
+ );
+ }
+
+ /**
+ * @dataProvider data_test_string_compare
+ */
+ public function test_string_compare($a, $b, $expected)
+ {
+ $this->assertSame($expected, $this->driver_helper->string_compare($a, $b));
+ }
}
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/search/fixtures/posts.xml b/tests/search/fixtures/posts.xml
index 7b249ee303..16232b8f39 100644
--- a/tests/search/fixtures/posts.xml
+++ b/tests/search/fixtures/posts.xml
@@ -19,6 +19,11 @@
<value>commonword</value>
<value>commonword</value>
</row>
+ <row>
+ <value>baaz</value>
+ <value>baaz</value>
+ <value>baaz</value>
+ </row>
</table>
<table name="phpbb_search_wordlist">
<column>word_id</column>
@@ -39,5 +44,10 @@
<value>commonword</value>
<value>1</value>
</row>
+ <row>
+ <value>4</value>
+ <value>baaz</value>
+ <value>0</value>
+ </row>
</table>
</dataset>
diff --git a/tests/search/native_test.php b/tests/search/native_test.php
index f681a62fce..61fde7d098 100644
--- a/tests/search/native_test.php
+++ b/tests/search/native_test.php
@@ -35,6 +35,8 @@ class phpbb_search_native_test extends phpbb_search_test_case
$this->db = $this->new_dbal();
$error = null;
$class = self::get_search_wrapper('\phpbb\search\fulltext_native');
+ $config['fulltext_native_min_chars'] = 2;
+ $config['fulltext_native_max_chars'] = 14;
$this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $user);
}
@@ -56,6 +58,54 @@ class phpbb_search_native_test extends phpbb_search_test_case
array(),
),
array(
+ 'baaz*',
+ 'all',
+ true,
+ array('\'baaz%\''),
+ array(),
+ array(),
+ ),
+ array(
+ 'ba*az',
+ 'all',
+ true,
+ array('\'ba%az\''),
+ array(),
+ array(),
+ ),
+ array(
+ 'ba*z',
+ 'all',
+ true,
+ array('\'ba%z\''),
+ array(),
+ array(),
+ ),
+ array(
+ 'baa* baaz*',
+ 'all',
+ true,
+ array('\'baa%\'', '\'baaz%\''),
+ array(),
+ array(),
+ ),
+ array(
+ 'ba*z baa*',
+ 'all',
+ true,
+ array('\'ba%z\'', '\'baa%\''),
+ array(),
+ array(),
+ ),
+ array(
+ 'baaz* commonword',
+ 'all',
+ true,
+ array('\'baaz%\''),
+ array(),
+ array('commonword'),
+ ),
+ array(
'foo bar',
'all',
true,
diff --git a/tests/security/base.php b/tests/security/base.php
index 5519cac441..330408b448 100644
--- a/tests/security/base.php
+++ b/tests/security/base.php
@@ -13,6 +13,8 @@
abstract class phpbb_security_test_base extends phpbb_test_case
{
+ protected $server = array();
+
/**
* Set up the required user object and server variables for the suites
*/
@@ -21,17 +23,18 @@ abstract class phpbb_security_test_base extends phpbb_test_case
global $user, $phpbb_root_path, $phpEx, $request, $symfony_request, $phpbb_filesystem;
// Put this into a global function being run by every test to init a proper user session
- $server['HTTP_HOST'] = 'localhost';
- $server['SERVER_NAME'] = 'localhost';
- $server['SERVER_ADDR'] = '127.0.0.1';
- $server['SERVER_PORT'] = 80;
- $server['REMOTE_ADDR'] = '127.0.0.1';
- $server['QUERY_STRING'] = '';
- $server['REQUEST_URI'] = '/tests/';
- $server['SCRIPT_NAME'] = '/tests/index.php';
- $server['PHP_SELF'] = '/tests/index.php';
- $server['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14';
- $server['HTTP_ACCEPT_LANGUAGE'] = 'de-de,de;q=0.8,en-us;q=0.5,en;q=0.3';
+ $this->server['HTTP_HOST'] = 'localhost';
+ $this->server['SERVER_NAME'] = 'localhost';
+ $this->server['SERVER_ADDR'] = '127.0.0.1';
+ $this->server['SERVER_PORT'] = 80;
+ $this->server['REMOTE_ADDR'] = '127.0.0.1';
+ $this->server['QUERY_STRING'] = '';
+ $this->server['REQUEST_URI'] = '/tests/';
+ $this->server['SCRIPT_NAME'] = '/tests/index.php';
+ $this->server['SCRIPT_FILENAME'] = '/var/www/tests/index.php';
+ $this->server['PHP_SELF'] = '/tests/index.php';
+ $this->server['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14';
+ $this->server['HTTP_ACCEPT_LANGUAGE'] = 'de-de,de;q=0.8,en-us;q=0.5,en;q=0.3';
/*
[HTTP_ACCEPT_ENCODING] => gzip,deflate
@@ -40,31 +43,18 @@ abstract class phpbb_security_test_base extends phpbb_test_case
[SCRIPT_FILENAME] => /var/www/tests/index.php
*/
- $request = new phpbb_mock_request(array(), array(), array(), $server);
- $symfony_request = $this->getMock("\phpbb\symfony_request", array(), array(
- $request,
- ));
- $symfony_request->expects($this->any())
- ->method('getScriptName')
- ->will($this->returnValue($server['SCRIPT_NAME']));
- $symfony_request->expects($this->any())
- ->method('getQueryString')
- ->will($this->returnValue($server['QUERY_STRING']));
- $symfony_request->expects($this->any())
- ->method('getBasePath')
- ->will($this->returnValue($server['REQUEST_URI']));
- $symfony_request->expects($this->any())
- ->method('getPathInfo')
- ->will($this->returnValue('/'));
- $phpbb_filesystem = new \phpbb\filesystem($symfony_request, $phpbb_root_path, $phpEx);
+ $request = new phpbb_mock_request(array(), array(), array(), $this->server);
+ $symfony_request = new \phpbb\symfony_request($request);
+
+ $phpbb_filesystem = new \phpbb\filesystem();
// Set no user and trick a bit to circumvent errors
$user = new \phpbb\user('\phpbb\datetime');
$user->lang = true;
- $user->browser = $server['HTTP_USER_AGENT'];
+ $user->browser = $this->server['HTTP_USER_AGENT'];
$user->referer = '';
$user->forwarded_for = '';
- $user->host = $server['HTTP_HOST'];
+ $user->host = $this->server['HTTP_HOST'];
$user->page = \phpbb\session::extract_current_page($phpbb_root_path);
}
diff --git a/tests/security/extract_current_page_test.php b/tests/security/extract_current_page_test.php
index 58dea68dc8..767b901a43 100644
--- a/tests/security/extract_current_page_test.php
+++ b/tests/security/extract_current_page_test.php
@@ -20,33 +20,25 @@ class phpbb_security_extract_current_page_test extends phpbb_security_test_base
public function security_variables()
{
return array(
- array('http://localhost/phpBB/index.php', 'mark=forums&x="><script>alert(/XSS/);</script>', 'mark=forums&x=%22%3E%3Cscript%3Ealert(/XSS/);%3C/script%3E'),
- array('http://localhost/phpBB/index.php', 'mark=forums&x=%22%3E%3Cscript%3Ealert(/XSS/);%3C/script%3E', 'mark=forums&x=%22%3E%3Cscript%3Ealert(/XSS/);%3C/script%3E'),
+ array('mark=forums&x="><script>alert(/XSS/);</script>', 'mark=forums&x=%22%3E%3Cscript%3Ealert%28%2FXSS%2F%29%3B%3C%2Fscript%3E'),
+ array('mark=forums&x=%22%3E%3Cscript%3Ealert(/XSS/);%3C/script%3E', 'mark=forums&x=%22%3E%3Cscript%3Ealert%28%2FXSS%2F%29%3B%3C%2Fscript%3E'),
+ array('mark=forums&x=%22%3E%3Cscript%3Ealert%28%2FXSS%2F%29%3B%3C%2Fscript%3E', 'mark=forums&x=%22%3E%3Cscript%3Ealert%28%2FXSS%2F%29%3B%3C%2Fscript%3E'),
);
}
/**
* @dataProvider security_variables
*/
- public function test_query_string_php_self($url, $query_string, $expected)
+ public function test_query_string_php_self($query_string, $expected)
{
global $symfony_request, $request;
- $symfony_request = $this->getMock("\phpbb\symfony_request", array(), array(
- $request,
- ));
- $symfony_request->expects($this->any())
- ->method('getScriptName')
- ->will($this->returnValue($url));
- $symfony_request->expects($this->any())
- ->method('getQueryString')
- ->will($this->returnValue($query_string));
- $symfony_request->expects($this->any())
- ->method('getBasePath')
- ->will($this->returnValue($server['REQUEST_URI']));
- $symfony_request->expects($this->any())
- ->method('getPathInfo')
- ->will($this->returnValue('/'));
+ $this->server['REQUEST_URI'] = '';
+ $this->server['QUERY_STRING'] = $query_string;
+
+ $request = new phpbb_mock_request(array(), array(), array(), $this->server);
+ $symfony_request = new \phpbb\symfony_request($request);
+
$result = \phpbb\session::extract_current_page('./');
$label = 'Running extract_current_page on ' . $query_string . ' with PHP_SELF filled.';
@@ -56,25 +48,14 @@ class phpbb_security_extract_current_page_test extends phpbb_security_test_base
/**
* @dataProvider security_variables
*/
- public function test_query_string_request_uri($url, $query_string, $expected)
+ public function test_query_string_request_uri($query_string, $expected)
{
global $symfony_request, $request;
- $symfony_request = $this->getMock("\phpbb\symfony_request", array(), array(
- $request,
- ));
- $symfony_request->expects($this->any())
- ->method('getScriptName')
- ->will($this->returnValue($url));
- $symfony_request->expects($this->any())
- ->method('getQueryString')
- ->will($this->returnValue($query_string));
- $symfony_request->expects($this->any())
- ->method('getBasePath')
- ->will($this->returnValue($server['REQUEST_URI']));
- $symfony_request->expects($this->any())
- ->method('getPathInfo')
- ->will($this->returnValue('/'));
+ $this->server['QUERY_STRING'] = $query_string;
+
+ $request = new phpbb_mock_request(array(), array(), array(), $this->server);
+ $symfony_request = new \phpbb\symfony_request($request);
$result = \phpbb\session::extract_current_page('./');
diff --git a/tests/security/redirect_test.php b/tests/security/redirect_test.php
index 3961c2781e..21fb103ed1 100644
--- a/tests/security/redirect_test.php
+++ b/tests/security/redirect_test.php
@@ -73,6 +73,8 @@ class phpbb_security_redirect_test extends phpbb_security_test_base
protected function setUp()
{
+ global $phpbb_dispatcher;
+
parent::setUp();
$GLOBALS['config'] = array(
@@ -80,6 +82,8 @@ class phpbb_security_redirect_test extends phpbb_security_test_base
);
$this->path_helper = $this->get_path_helper();
+
+ $phpbb_dispatcher = new phpbb_mock_event_dispatcher();
}
/**
diff --git a/tests/session/extract_page_test.php b/tests/session/extract_page_test.php
index f314d35f87..f0d1cdb60e 100644
--- a/tests/session/extract_page_test.php
+++ b/tests/session/extract_page_test.php
@@ -12,6 +12,7 @@
*/
require_once dirname(__FILE__) . '/../test_framework/phpbb_session_test_case.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_session_extract_page_test extends phpbb_session_test_case
{
@@ -99,7 +100,7 @@ class phpbb_session_extract_page_test extends phpbb_session_test_case
// ^-- Ignored because .. returns different directory in live vs testing
'query_string' => '',
'script_path' => '/phpBB/adm/',
- //'root_script_path' => '/phpBB/',
+ //'root_script_path' => '/phpBB/adm/',
//'page' => 'adm/index.php',
'forum' => 0,
),
@@ -108,15 +109,15 @@ class phpbb_session_extract_page_test extends phpbb_session_test_case
'./',
'/phpBB/adm/app.php',
'page=1&test=2',
- '/phpBB/',
+ '/phpBB/adm/',
'/foo/bar',
array(
'page_name' => 'app.php/foo/bar',
- 'page_dir' => '',
+ //'page_dir' => '',
'query_string' => 'page=1&test=2',
- 'script_path' => '/phpBB/',
- 'root_script_path' => '/phpBB/',
- 'page' => 'app.php/foo/bar?page=1&test=2',
+ 'script_path' => '/phpBB/adm/',
+ //'root_script_path' => '/phpBB/adm/',
+ //'page' => 'app.php/foo/bar?page=1&test=2',
'forum' => 0,
),
),
@@ -142,23 +143,25 @@ class phpbb_session_extract_page_test extends phpbb_session_test_case
/** @dataProvider extract_current_page_data */
function test_extract_current_page($root_path, $getScriptName, $getQueryString, $getBasePath, $getPathInfo, $expected)
{
- global $symfony_request;
+ global $symfony_request, $request, $phpbb_filesystem;
+
+ $phpbb_filesystem = new \phpbb\filesystem();
+
+ $server['HTTP_HOST'] = 'localhost';
+ $server['SERVER_NAME'] = 'localhost';
+ $server['SERVER_ADDR'] = '127.0.0.1';
+ $server['SERVER_PORT'] = 80;
+ $server['REMOTE_ADDR'] = '127.0.0.1';
+ $server['QUERY_STRING'] = $getQueryString;
+ $server['REQUEST_URI'] = $getScriptName . $getPathInfo . ($getQueryString === '' ? '' : '?' . $getQueryString);
+ $server['SCRIPT_NAME'] = $getScriptName;
+ $server['SCRIPT_FILENAME'] = '/var/www/' . $getScriptName;
+ $server['PHP_SELF'] = $getScriptName;
+ $server['HTTP_USER_AGENT'] = 'Mozilla/5.0 (Windows; U; Windows NT 6.0; de; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14';
+ $server['HTTP_ACCEPT_LANGUAGE'] = 'de-de,de;q=0.8,en-us;q=0.5,en;q=0.3';
- $symfony_request = $this->getMock("\phpbb\symfony_request", array(), array(
- new phpbb_mock_request(),
- ));
- $symfony_request->expects($this->any())
- ->method('getScriptName')
- ->will($this->returnValue($getScriptName));
- $symfony_request->expects($this->any())
- ->method('getQueryString')
- ->will($this->returnValue($getQueryString));
- $symfony_request->expects($this->any())
- ->method('getBasePath')
- ->will($this->returnValue($getBasePath));
- $symfony_request->expects($this->any())
- ->method('getPathInfo')
- ->will($this->returnValue($getPathInfo));
+ $request = new phpbb_mock_request(array(), array(), array(), $server);
+ $symfony_request = new \phpbb\symfony_request($request);
$output = \phpbb\session::extract_current_page($root_path);
diff --git a/tests/session/session_key_test.php b/tests/session/session_key_test.php
index 31a470615c..bf3dfcaa3c 100644
--- a/tests/session/session_key_test.php
+++ b/tests/session/session_key_test.php
@@ -11,6 +11,7 @@
*
*/
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
require_once dirname(__FILE__) . '/../test_framework/phpbb_session_test_case.php';
class phpbb_session_login_keys_test extends phpbb_session_test_case
@@ -28,13 +29,14 @@ class phpbb_session_login_keys_test extends phpbb_session_test_case
// With AutoLogin setup
$this->session_factory->merge_config_data(array('allow_autologin' => true));
$session = $this->session_factory->get_session($this->db);
+
// Using a user_id and key that is already in the database
$session->cookie_data['u'] = $this->user_id;
$session->cookie_data['k'] = $this->key_id;
- // Try to access session
- $session->session_create($this->user_id, false, $this->user_id);
- $this->assertEquals($this->user_id, $session->data['user_id'], "session should automatically login");
+ // Try to access session with the session key
+ $session->session_create(false, false, false);
+ $this->assertEquals($this->user_id, $session->data['user_id'], 'User should be logged in by the session key');
}
public function test_reset_keys()
@@ -42,14 +44,19 @@ class phpbb_session_login_keys_test extends phpbb_session_test_case
// With AutoLogin setup
$this->session_factory->merge_config_data(array('allow_autologin' => true));
$session = $this->session_factory->get_session($this->db);
+
// Reset of the keys for this user
$session->reset_login_keys($this->user_id);
+
// Using a user_id and key that was in the database (before reset)
$session->cookie_data['u'] = $this->user_id;
$session->cookie_data['k'] = $this->key_id;
- // Try to access session
- $session->session_create($this->user_id, false, $this->user_id);
- $this->assertNotEquals($this->user_id, $session->data['user_id'], "session should be cleared");
+ // Try to access session with the session key
+ $session->session_create(false, false, $this->user_id);
+ $this->assertNotEquals($this->user_id, $session->data['user_id'], 'User is not logged in because the session key is invalid');
+
+ $session->session_create($this->user_id, false, false);
+ $this->assertEquals($this->user_id, $session->data['user_id'], 'User should be logged in because we create a new session');
}
}
diff --git a/tests/template/ext/include/css/styles/all/theme/child_only.css b/tests/template/ext/include/css/styles/all/theme/child_only.css
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/template/ext/include/css/styles/all/theme/child_only.css
diff --git a/tests/template/ext/include/css/styles/all/theme/test.css b/tests/template/ext/include/css/styles/all/theme/test.css
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/template/ext/include/css/styles/all/theme/test.css
diff --git a/tests/template/template_includecss_test.php b/tests/template/template_includecss_test.php
index ab91dd7a49..49bd9dec8b 100644
--- a/tests/template/template_includecss_test.php
+++ b/tests/template/template_includecss_test.php
@@ -15,18 +15,90 @@ require_once dirname(__FILE__) . '/template_test_case_with_tree.php';
class phpbb_template_template_includecss_test extends phpbb_template_template_test_case_with_tree
{
- public function test_includecss_compilation()
+ protected function setup_engine(array $new_config = array())
+ {
+ global $phpbb_root_path, $phpEx, $user;
+
+ $defaults = $this->config_defaults();
+ $config = new \phpbb\config\config(array_merge($defaults, $new_config));
+
+ $this->phpbb_path_helper = new \phpbb\path_helper(
+ new \phpbb\symfony_request(
+ new phpbb_mock_request()
+ ),
+ new \phpbb\filesystem(),
+ $this->getMock('\phpbb\request\request'),
+ $phpbb_root_path,
+ $phpEx
+ );
+
+ $this->template_path = $this->test_path . '/templates';
+ $this->parent_template_path = $this->test_path . '/parent_templates';
+ $this->template = new phpbb\template\twig\twig(
+ $this->phpbb_path_helper,
+ $config,
+ $user,
+ new phpbb\template\context(),
+ new phpbb_mock_extension_manager(
+ dirname(__FILE__) . '/',
+ array(
+ 'include/css' => array(
+ 'ext_name' => 'include/css',
+ 'ext_active' => '1',
+ 'ext_path' => 'ext/include/css/',
+ ),
+ )
+ )
+ );
+ $this->template->set_custom_style('tests', array($this->template_path, $this->parent_template_path));
+ }
+
+ public function template_data()
+ {
+ $url_base = explode('/', dirname(__FILE__));
+ foreach ($url_base as &$dir)
+ {
+ $dir = rawurlencode($dir);
+ }
+ $url_base = implode('/', $url_base);
+
+ return array(
+ /*
+ array(
+ // vars
+ // expected
+ ),
+ */
+ array(
+ array('TEST' => 1),
+ '<link href="tests/template/templates/child_only.css?assets_version=1" rel="stylesheet" type="text/css" media="screen, projection" />',
+ ),
+ array(
+ array('TEST' => 2),
+ '<link href="tests/template/parent_templates/parent_only.css?assets_version=1" rel="stylesheet" type="text/css" media="screen, projection" />',
+ ),
+ array(
+ array('TEST' => 3),
+ '<link href="' . $url_base . '/ext/include/css/styles/all/theme/test.css?assets_version=1" rel="stylesheet" type="text/css" media="screen, projection" />',
+ ),
+ array(
+ array('TEST' => 4),
+ '<link href="' . $url_base . '/ext/include/css/styles/all/theme/child_only.css?assets_version=1" rel="stylesheet" type="text/css" media="screen, projection" />',
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider template_data
+ */
+ public function test_includecss_compilation($vars, $expected)
{
// Reset the engine state
$this->setup_engine(array('assets_version' => 1));
- // Prepare correct result
- $scripts = array(
- '<link href="tests/template/templates/child_only.css?assets_version=1" rel="stylesheet" type="text/css" media="screen, projection" />',
- '<link href="tests/template/parent_templates/parent_only.css?assets_version=1" rel="stylesheet" type="text/css" media="screen, projection" />',
- );
+ $this->template->assign_vars($vars);
// Run test
- $this->run_template('includecss.html', array(), array(), array(), implode('', $scripts));
+ $this->run_template('includecss.html', array(), array(), array(), $expected);
}
}
diff --git a/tests/template/templates/includecss.html b/tests/template/templates/includecss.html
index a09e44f240..23e3c426d7 100644
--- a/tests/template/templates/includecss.html
+++ b/tests/template/templates/includecss.html
@@ -1,3 +1,10 @@
-<!-- INCLUDECSS child_only.css -->
-<!-- INCLUDECSS parent_only.css -->
+<!-- IF TEST === 1 -->
+ <!-- INCLUDECSS child_only.css -->
+<!-- ELSEIF TEST === 2 -->
+ <!-- INCLUDECSS parent_only.css -->
+<!-- ELSEIF TEST === 3 -->
+ <!-- INCLUDECSS @include_css/test.css -->
+<!-- ELSEIF TEST === 4 -->
+ <!-- INCLUDECSS @include_css/child_only.css -->
+<!-- ENDIF -->
{$STYLESHEETS}
diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php
index 9dbb7150f1..fc1a3632f4 100644
--- a/tests/test_framework/phpbb_database_test_case.php
+++ b/tests/test_framework/phpbb_database_test_case.php
@@ -54,46 +54,43 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
static public function setUpBeforeClass()
{
+ global $phpbb_root_path, $phpEx;
+
$setup_extensions = static::setup_extensions();
- self::$schema_file = '';
+
+ $finder = new \phpbb\finder(new \phpbb\filesystem(), $phpbb_root_path, null, $phpEx);
+ $finder->core_path('phpbb/db/migration/data/');
if (!empty($setup_extensions))
{
- $schema_md5 = md5(serialize($setup_extensions));
-
- self::$schema_file = __DIR__ . '/../tmp/' . $schema_md5 . '.json';
- self::$phpbb_schema_copy = __DIR__ . '/../tmp/schema_phpbb_copy.json';
- self::$install_schema_file = __DIR__ . '/../../phpBB/install/schemas/schema.json';
-
- if (!file_exists(self::$schema_file))
- {
- global $phpbb_root_path, $phpEx, $table_prefix;
+ $finder->set_extensions($setup_extensions)
+ ->extension_directory('/migrations');
+ }
+ $classes = $finder->get_classes();
- $finder = new \phpbb\finder(new \phpbb\filesystem(), $phpbb_root_path, null, $phpEx);
- $classes = $finder->core_path('phpbb/db/migration/data/')
- ->set_extensions($setup_extensions)
- ->extension_directory('/migrations')
- ->get_classes();
+ $schema_sha1 = sha1(serialize($classes));
+ self::$schema_file = __DIR__ . '/../tmp/' . $schema_sha1 . '.json';
+ self::$install_schema_file = __DIR__ . '/../../phpBB/install/schemas/schema.json';
- $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_data = $schema_generator->get_schema();
+ if (!file_exists(self::$schema_file))
+ {
- file_put_contents(self::$schema_file, json_encode($schema_data));
- }
+ global $table_prefix;
- copy(self::$install_schema_file, self::$phpbb_schema_copy);
- copy(self::$schema_file, self::$install_schema_file);
+ $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);
+ file_put_contents(self::$schema_file, json_encode($schema_generator->get_schema()));
}
+ copy(self::$schema_file, self::$install_schema_file);
+
parent::setUpBeforeClass();
}
static public function tearDownAfterClass()
{
- if (self::$schema_file !== '')
+ if (file_exists(self::$install_schema_file))
{
- copy(self::$phpbb_schema_copy, self::$install_schema_file);
- unlink(self::$schema_file);
+ unlink(self::$install_schema_file);
}
parent::tearDownAfterClass();
diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php
index 92e2080dba..5d643e43e2 100644
--- a/tests/test_framework/phpbb_database_test_connection_manager.php
+++ b/tests/test_framework/phpbb_database_test_connection_manager.php
@@ -356,8 +356,23 @@ class phpbb_database_test_connection_manager
}
// Ok we have the db info go ahead and work on building the table
- $db_table_schema = file_get_contents($directory . 'schema.json');
- $db_table_schema = json_decode($db_table_schema, true);
+ if (file_exists($directory . 'schema.json'))
+ {
+ $db_table_schema = file_get_contents($directory . 'schema.json');
+ $db_table_schema = json_decode($db_table_schema, true);
+ }
+ else
+ {
+ global $phpbb_root_path, $phpEx, $table_prefix;
+
+ $finder = new \phpbb\finder(new \phpbb\filesystem(), $phpbb_root_path, null, $phpEx);
+ $classes = $finder->core_path('phpbb/db/migration/data/')
+ ->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);
+ $db_table_schema = $schema_generator->get_schema();
+ }
$db_tools = new \phpbb\db\tools($db, true);
foreach ($db_table_schema as $table_name => $table_data)
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index 49cc72363e..844caa8f54 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -38,6 +38,7 @@ class phpbb_functional_test_case extends phpbb_test_case
static protected $config = array();
static protected $already_installed = false;
+ static protected $last_post_timestamp = 0;
static public function setUpBeforeClass()
{
@@ -226,7 +227,9 @@ class phpbb_functional_test_case extends phpbb_test_case
$db = $this->get_db();
$db_tools = new \phpbb\db\tools($db);
+ $container = new phpbb_mock_container_builder();
$migrator = new \phpbb\db\migrator(
+ $container,
$config,
$db,
$db_tools,
@@ -237,8 +240,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(
@@ -407,6 +410,18 @@ class phpbb_functional_test_case extends phpbb_test_case
$form = $crawler->selectButton('Enable')->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 (sizeof($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_ENABLE_SUCCESS', $crawler->filter('div.successbox')->text());
$this->logout();
@@ -556,12 +571,10 @@ class phpbb_functional_test_case extends phpbb_test_case
$cache = new phpbb_mock_null_cache;
$cache_driver = new \phpbb\cache\driver\null();
- $phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
- $phpbb_container
- ->expects($this->any())
- ->method('get')
- ->with('cache.driver')
- ->will($this->returnValue($cache_driver));
+ $phpbb_container = new phpbb_mock_container_builder();
+ $phpbb_container->set('cache.driver', $cache_driver);
+ $phpbb_notifications = new phpbb_mock_notification_manager();
+ $phpbb_container->set('notification_manager', $phpbb_notifications);
if (!function_exists('utf_clean_string'))
{
@@ -884,7 +897,7 @@ class phpbb_functional_test_case extends phpbb_test_case
*/
static public function assert_response_status_code($status_code = 200)
{
- self::assertEquals($status_code, self::$client->getResponse()->getStatus());
+ self::assertEquals($status_code, self::$client->getResponse()->getStatus(), 'HTTP status code does not match');
}
public function assert_filter($crawler, $expr, $msg = null)
@@ -1100,6 +1113,12 @@ class phpbb_functional_test_case extends phpbb_test_case
*/
protected function submit_message($posting_url, $posting_contains, $form_data)
{
+ if (time() == self::$last_post_timestamp)
+ {
+ // Travis is too fast, so we have to wait to not mix up the post/topic order
+ sleep(1);
+ }
+ self::$last_post_timestamp = time();
$crawler = self::request('GET', $posting_url);
$this->assertContains($this->lang($posting_contains), $crawler->filter('html')->text());
diff --git a/tests/test_framework/phpbb_session_test_case.php b/tests/test_framework/phpbb_session_test_case.php
index d4fc174a12..1bf0277fe0 100644
--- a/tests/test_framework/phpbb_session_test_case.php
+++ b/tests/test_framework/phpbb_session_test_case.php
@@ -11,13 +11,19 @@
*
*/
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
require_once dirname(__FILE__) . '/../session/testable_factory.php';
require_once dirname(__FILE__) . '/../session/testable_facade.php';
abstract class phpbb_session_test_case extends phpbb_database_test_case
{
+ /** @var phpbb_session_testable_factory */
protected $session_factory;
+
+ /** @var phpbb_session_testable_facade */
protected $session_facade;
+
+ /** @var \phpbb\db\driver\driver_interface */
protected $db;
function setUp()
diff --git a/tests/test_framework/phpbb_test_case.php b/tests/test_framework/phpbb_test_case.php
index c39f7835d1..01d26fb67d 100644
--- a/tests/test_framework/phpbb_test_case.php
+++ b/tests/test_framework/phpbb_test_case.php
@@ -26,7 +26,7 @@ class phpbb_test_case extends PHPUnit_Framework_TestCase
'PHP_Token_Stream' => array('customTokens'),
'PHP_Token_Stream_CachingFactory' => array('cache'),
- 'phpbb_database_test_case' => array('already_connected'),
+ 'phpbb_database_test_case' => array('already_connected', 'last_post_timestamp'),
);
}
diff --git a/tests/test_framework/phpbb_ui_test_case.php b/tests/test_framework/phpbb_ui_test_case.php
new file mode 100644
index 0000000000..c8ac492e25
--- /dev/null
+++ b/tests/test_framework/phpbb_ui_test_case.php
@@ -0,0 +1,204 @@
+<?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 __DIR__ . '/../../phpBB/includes/functions_install.php';
+
+class phpbb_ui_test_case extends phpbb_test_case
+{
+ static protected $host = '127.0.0.1';
+ static protected $port = 8910;
+
+ /**
+ * @var \RemoteWebDriver
+ */
+ static protected $webDriver;
+
+ static protected $config;
+ static protected $root_url;
+ static protected $already_installed = false;
+
+ static public function setUpBeforeClass()
+ {
+ 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('\RemoteWebDriver'))
+ {
+ self::markTestSkipped(
+ 'Could not find RemoteWebDriver class. ' .
+ 'Run "php ../composer.phar install" from the tests folder.'
+ );
+ }
+
+ self::$config = phpbb_test_case_helpers::get_test_config();
+ self::$root_url = self::$config['phpbb_functional_url'];
+
+ // Important: this is used both for installation and by
+ // test cases for querying the tables.
+ // Therefore table prefix must be set before a board is
+ // installed, and also before each test case is run.
+ self::$config['table_prefix'] = 'phpbb_';
+
+ if (!isset(self::$config['phpbb_functional_url']))
+ {
+ self::markTestSkipped('phpbb_functional_url was not set in test_config and wasn\'t set as PHPBB_FUNCTIONAL_URL environment variable either.');
+ }
+
+ if (!self::$webDriver)
+ {
+ try {
+ $capabilities = array(\WebDriverCapabilityType::BROWSER_NAME => 'firefox');
+ self::$webDriver = RemoteWebDriver::create(self::$host . ':' . self::$port, $capabilities);
+ } catch (WebDriverCurlException $e) {
+ self::markTestSkipped('PhantomJS webserver is not running.');
+ }
+ }
+
+ if (!self::$already_installed)
+ {
+ self::install_board();
+ self::$already_installed = true;
+ }
+ }
+
+ static public function visit($path)
+ {
+ self::$webDriver->get(self::$root_url . $path);
+ }
+
+ static protected function recreate_database($config)
+ {
+ $db_conn_mgr = new phpbb_database_test_connection_manager($config);
+ $db_conn_mgr->recreate_db();
+ }
+
+ static public function find_element($type, $value)
+ {
+ return self::$webDriver->findElement(WebDriverBy::$type($value));
+ }
+
+ static public function submit($type = 'id', $value = 'submit')
+ {
+ $element = self::find_element($type, $value);
+ $element->click();
+ }
+
+ static public function install_board()
+ {
+ global $phpbb_root_path, $phpEx;
+
+ self::recreate_database(self::$config);
+
+ $config_file = $phpbb_root_path . "config.$phpEx";
+ $config_file_dev = $phpbb_root_path . "config_dev.$phpEx";
+ $config_file_test = $phpbb_root_path . "config_test.$phpEx";
+
+ if (file_exists($config_file))
+ {
+ if (!file_exists($config_file_dev))
+ {
+ rename($config_file, $config_file_dev);
+ }
+ else
+ {
+ unlink($config_file);
+ }
+ }
+
+ $parseURL = parse_url(self::$config['phpbb_functional_url']);
+
+ self::visit('install/index.php?mode=install&language=en');
+ self::assertContains('Welcome to Installation', self::find_element('id', 'main')->getText());
+
+ // install/index.php?mode=install&sub=requirements
+ self::submit();
+ self::assertContains('Installation compatibility', self::find_element('id', 'main')->getText());
+
+ // install/index.php?mode=install&sub=database
+ self::submit();
+ self::assertContains('Database configuration', self::find_element('id', 'main')->getText());
+
+ self::find_element('id','dbms')->sendKeys(str_replace('phpbb\db\driver\\', '', self::$config['dbms']));
+ self::find_element('id','dbhost')->sendKeys(self::$config['dbhost']);
+ self::find_element('id','dbport')->sendKeys(self::$config['dbport']);
+ self::find_element('id','dbname')->sendKeys(self::$config['dbname']);
+ self::find_element('id','dbuser')->sendKeys(self::$config['dbuser']);
+ self::find_element('id','dbpasswd')->sendKeys(self::$config['dbpasswd']);
+
+ // Need to clear default phpbb_ prefix
+ self::find_element('id','table_prefix')->clear();
+ self::find_element('id','table_prefix')->sendKeys(self::$config['table_prefix']);
+
+ // install/index.php?mode=install&sub=database
+ self::submit();
+ self::assertContains('Successful connection', self::find_element('id','main')->getText());
+
+ // install/index.php?mode=install&sub=administrator
+ self::submit();
+ self::assertContains('Administrator configuration', self::find_element('id','main')->getText());
+
+ self::find_element('id','admin_name')->sendKeys('admin');
+ self::find_element('id','admin_pass1')->sendKeys('adminadmin');
+ self::find_element('id','admin_pass2')->sendKeys('adminadmin');
+ self::find_element('id','board_email')->sendKeys('nobody@example.com');
+
+ // install/index.php?mode=install&sub=administrator
+ self::submit();
+ self::assertContains('Tests passed', self::find_element('id','main')->getText());
+
+ // install/index.php?mode=install&sub=config_file
+ self::submit();
+
+ // Installer has created a config.php file, we will overwrite it with a
+ // config file of our own in order to get the DEBUG constants defined
+ $config_php_data = phpbb_create_config_file_data(self::$config, self::$config['dbms'], true, false, true);
+ $config_created = file_put_contents($config_file, $config_php_data) !== false;
+ if (!$config_created)
+ {
+ self::markTestSkipped("Could not write $config_file file.");
+ }
+
+ if (strpos(self::find_element('id','main')->getText(), 'The configuration file has been written') === false)
+ {
+ self::submit('id', 'dldone');
+ }
+ self::assertContains('The configuration file has been written', self::find_element('id','main')->getText());
+
+ // install/index.php?mode=install&sub=advanced
+ self::submit();
+ self::assertContains('The settings on this page are only necessary to set if you know that you require something different from the default.', self::find_element('id','main')->getText());
+
+ self::find_element('id','smtp_delivery')->sendKeys('1');
+ self::find_element('id','smtp_host')->sendKeys('nxdomain.phpbb.com');
+ self::find_element('id','smtp_user')->sendKeys('nxuser');
+ self::find_element('id','smtp_pass')->sendKeys('nxpass');
+ self::find_element('id','server_protocol')->sendKeys($parseURL['scheme'] . '://');
+ self::find_element('id','server_name')->sendKeys('localhost');
+ self::find_element('id','server_port')->sendKeys(isset($parseURL['port']) ? $parseURL['port'] : 80);
+ self::find_element('id','script_path')->sendKeys($parseURL['path']);
+
+ // install/index.php?mode=install&sub=create_table
+ self::submit();
+ self::assertContains('The database tables used by phpBB', self::find_element('id','main')->getText());
+ self::assertContains('have been created and populated with some initial data.', self::find_element('id','main')->getText());
+
+ // install/index.php?mode=install&sub=final
+ self::submit();
+ self::assertContains('You have successfully installed', self::find_element('id', 'main')->getText());
+
+ copy($config_file, $config_file_test);
+ }
+}
diff --git a/tests/tree/nestedset_forum_base.php b/tests/tree/nestedset_forum_base.php
index 449b2e5ca8..c56be1f81e 100644
--- a/tests/tree/nestedset_forum_base.php
+++ b/tests/tree/nestedset_forum_base.php
@@ -11,6 +11,8 @@
*
*/
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+
class phpbb_tests_tree_nestedset_forum_base extends phpbb_database_test_case
{
public function getDataSet()
diff --git a/tests/ui/quick_links_test.php b/tests/ui/quick_links_test.php
new file mode 100644
index 0000000000..5bddb44a8b
--- /dev/null
+++ b/tests/ui/quick_links_test.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.
+*
+*/
+
+/**
+* @group ui
+*/
+class quick_links_test extends phpbb_ui_test_case
+{
+
+ public function test_quick_links()
+ {
+ $this->visit('index.php');
+ $this->assertEmpty(self::find_element('className', 'dropdown')->getText());
+ self::find_element('className', 'dropdown-toggle')->click();
+ $this->assertNotNull(self::find_element('className', 'dropdown')->getText());
+ }
+}
diff --git a/tests/upload/filespec_test.php b/tests/upload/filespec_test.php
index d8fa82e2b5..05547dcd00 100644
--- a/tests/upload/filespec_test.php
+++ b/tests/upload/filespec_test.php
@@ -266,6 +266,11 @@ class phpbb_filespec_test extends phpbb_test_case
*/
public function test_is_image_get_mimetype($filename, $mimetype, $expected)
{
+ if (!class_exists('finfo') && strtolower(substr(PHP_OS, 0, 3)) === 'win')
+ {
+ $this->markTestSkipped('Unable to test mimetype guessing without fileinfo support on Windows');
+ }
+
$filespec = $this->get_filespec(array('tmp_name' => $this->path . $filename, 'type' => $mimetype));
$filespec->get_mimetype($this->path . $filename);
$this->assertEquals($expected, $filespec->is_image());
diff --git a/tests/version/version_fetch_test.php b/tests/version/version_fetch_test.php
index 05eac58a52..cfc87183cf 100644
--- a/tests/version/version_fetch_test.php
+++ b/tests/version/version_fetch_test.php
@@ -33,6 +33,7 @@ class phpbb_version_helper_fetch_test extends phpbb_test_case
new \phpbb\config\config(array(
'version' => '3.1.0',
)),
+ new \phpbb\file_downloader(),
new \phpbb\user('\phpbb\datetime')
);
}
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);
+ }
+}
diff --git a/tests/version/version_test.php b/tests/version/version_test.php
index ba31c79a79..528f1602d6 100644
--- a/tests/version/version_test.php
+++ b/tests/version/version_test.php
@@ -30,6 +30,7 @@ class phpbb_version_helper_test extends phpbb_test_case
new \phpbb\config\config(array(
'version' => '3.1.0',
)),
+ new \phpbb\file_downloader(),
new \phpbb\user('\phpbb\datetime')
);
}
@@ -208,6 +209,7 @@ class phpbb_version_helper_test extends phpbb_test_case
new \phpbb\config\config(array(
'version' => $current_version,
)),
+ new \phpbb\file_downloader(),
new \phpbb\user('\phpbb\datetime'),
))
->getMock()
@@ -318,6 +320,7 @@ class phpbb_version_helper_test extends phpbb_test_case
new \phpbb\config\config(array(
'version' => $current_version,
)),
+ new \phpbb\file_downloader(),
new \phpbb\user('\phpbb\datetime'),
))
->getMock()
diff --git a/tests/wrapper/gmgetdate_test.php b/tests/wrapper/gmgetdate_test.php
index dc0e38544d..2e55a78d21 100644
--- a/tests/wrapper/gmgetdate_test.php
+++ b/tests/wrapper/gmgetdate_test.php
@@ -50,7 +50,18 @@ class phpbb_wrapper_gmgetdate_test extends phpbb_test_case
$date_array['year']
);
- $this->assertEquals($expected, $actual);
+ // Calling second-granularity time functions twice isn't guaranteed to
+ // give the same results. As long as they're in the right order, allow
+ // a 1 second difference.
+ $this->assertGreaterThanOrEqual(
+ $expected, $actual,
+ 'Expected second time to be after (or equal to) the previous one'
+ );
+ $this->assertLessThanOrEqual(
+ 1,
+ abs($actual - $expected),
+ "Expected $actual to be within 1 second of $expected."
+ );
if (isset($current_timezone))
{