aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/bbcode/parser_test.php2
-rw-r--r--tests/bbcode/url_bbcode_test.php2
-rw-r--r--tests/bootstrap.php33
-rw-r--r--tests/cache/cache_test.php2
-rw-r--r--tests/class_loader/class_loader_test.php43
-rw-r--r--tests/config/config_test.php2
-rw-r--r--tests/config/db_test.php2
-rw-r--r--tests/cron/ext/testext/cron/dummy_task.php (renamed from tests/cron/task/testmod/second_dummy_task.php)4
-rw-r--r--tests/cron/includes/cron/task/core/dummy_task.php (renamed from tests/cron/task/testmod/dummy_task.php)4
-rw-r--r--tests/cron/includes/cron/task/core/second_dummy_task.php23
-rw-r--r--tests/cron/manager_test.php48
-rw-r--r--tests/cron/task2/testmod/simple_ready.php8
-rw-r--r--tests/cron/task_provider_test.php43
-rw-r--r--tests/cron/tasks/simple_not_runnable.php (renamed from tests/cron/task2/testmod/simple_not_runnable.php)2
-rw-r--r--tests/cron/tasks/simple_ready.php8
-rw-r--r--tests/cron/tasks/simple_should_not_run.php (renamed from tests/cron/task2/testmod/simple_should_not_run.php)2
-rw-r--r--tests/dbal/cross_join_test.php55
-rw-r--r--tests/dbal/db_tools_test.php28
-rw-r--r--tests/dbal/fixtures/massmail_crossjoin.xml59
-rw-r--r--tests/dbal/fixtures/styles.xml35
-rw-r--r--tests/dbal/fixtures/three_users.xml16
-rw-r--r--tests/dbal/order_lower_test.php59
-rw-r--r--tests/dbal/schema_test.php2
-rw-r--r--tests/dbal/select_test.php20
-rw-r--r--tests/dbal/write_test.php2
-rw-r--r--tests/download/http_byte_range_test.php2
-rw-r--r--tests/error_collector_test.php2
-rw-r--r--tests/extension/ext/bar/ext.php24
-rw-r--r--tests/extension/ext/bar/my/hidden_class.php5
-rw-r--r--tests/extension/ext/foo/a_class.php5
-rw-r--r--tests/extension/ext/foo/b_class.php5
-rw-r--r--tests/extension/ext/foo/ext.php13
-rw-r--r--tests/extension/ext/foo/sub/type/alternative.php5
-rw-r--r--tests/extension/ext/foo/type/alternative.php5
-rw-r--r--tests/extension/ext/foo/typewrong/error.php5
-rw-r--r--tests/extension/ext/vendor/moo/ext.php13
-rw-r--r--tests/extension/ext/vendor/moo/feature_class.php5
-rw-r--r--tests/extension/finder_test.php206
-rw-r--r--tests/extension/fixtures/extensions.xml15
-rw-r--r--tests/extension/includes/default/implementation.php5
-rw-r--r--tests/extension/manager_test.php102
-rw-r--r--tests/functional/browse_test.php26
-rw-r--r--tests/functions_acp/build_cfg_template_test.php2
-rw-r--r--tests/functions_acp/build_select_test.php2
-rw-r--r--tests/functions_acp/h_radio_test.php2
-rw-r--r--tests/functions_acp/validate_config_vars_test.php2
-rw-r--r--tests/functions_acp/validate_range_test.php2
-rw-r--r--tests/group_positions/group_positions_test.php2
-rw-r--r--tests/lock/db_test.php2
-rw-r--r--tests/mock/cache.php17
-rw-r--r--tests/mock/extension_manager.php18
-rw-r--r--tests/mock/lang.php2
-rw-r--r--tests/mock/request.php2
-rw-r--r--tests/mock/session_testable.php2
-rw-r--r--tests/mock_user.php2
-rw-r--r--tests/network/checkdnsrr_test.php2
-rw-r--r--tests/network/ftp_fsock_pasv_epsv_test.php2
-rw-r--r--tests/network/inet_ntop_pton_test.php2
-rw-r--r--tests/network/ip_normalise_test.php2
-rw-r--r--tests/profile/custom_test.php4
-rw-r--r--tests/random/gen_rand_string_test.php2
-rw-r--r--tests/regex/censor_test.php2
-rw-r--r--tests/regex/email_test.php2
-rw-r--r--tests/regex/ipv4_test.php2
-rw-r--r--tests/regex/ipv6_test.php2
-rw-r--r--tests/regex/password_complexity_test.php2
-rw-r--r--tests/regex/table_prefix_test.php35
-rw-r--r--tests/regex/url_test.php2
-rw-r--r--tests/request/deactivated_super_global_test.php2
-rw-r--r--tests/request/request_test.php2
-rw-r--r--tests/request/request_var_test.php2
-rw-r--r--tests/request/type_cast_helper_test.php2
-rw-r--r--tests/security/base.php2
-rw-r--r--tests/security/extract_current_page_test.php2
-rw-r--r--tests/security/hash_test.php2
-rw-r--r--tests/security/redirect_test.php2
-rw-r--r--tests/session/append_sid_test.php2
-rw-r--r--tests/session/continue_test.php2
-rw-r--r--tests/session/fixtures/sessions_empty.xml16
-rw-r--r--tests/session/fixtures/sessions_full.xml16
-rw-r--r--tests/session/init_test.php2
-rw-r--r--tests/session/testable_factory.php2
-rw-r--r--tests/template/includephp_test.php2
-rw-r--r--tests/template/renderer_eval_test.php2
-rw-r--r--tests/template/subdir/includephp_from_subdir_test.php2
-rw-r--r--tests/template/template_compile_test.php2
-rw-r--r--tests/template/template_inheritance_test.php5
-rw-r--r--tests/template/template_test.php16
-rw-r--r--tests/template/template_test_case.php7
-rw-r--r--tests/template/templates/lang.html2
-rw-r--r--tests/template/templates/loop_nested_deep_multilevel_ref.html3
-rw-r--r--tests/test_framework/phpbb_database_test_case.php44
-rw-r--r--tests/test_framework/phpbb_database_test_connection_manager.php52
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php164
-rw-r--r--tests/test_framework/phpbb_test_case.php2
-rw-r--r--tests/test_framework/phpbb_test_case_helpers.php59
-rw-r--r--tests/text_processing/censor_text_test.php2
-rw-r--r--tests/text_processing/make_clickable_test.php2
-rw-r--r--tests/user/lang_test.php61
-rw-r--r--tests/utf/normalizer_test.php6
-rw-r--r--tests/utf/utf8_clean_string_test.php2
-rw-r--r--tests/utf/utf8_wordwrap_test.php2
-rw-r--r--tests/wrapper/gmgetdate_test.php2
-rw-r--r--tests/wrapper/mt_rand_test.php2
-rw-r--r--tests/wrapper/version_compare_test.php2
105 files changed, 1333 insertions, 231 deletions
diff --git a/tests/bbcode/parser_test.php b/tests/bbcode/parser_test.php
index 9423383938..8c7fbc7128 100644
--- a/tests/bbcode/parser_test.php
+++ b/tests/bbcode/parser_test.php
@@ -4,7 +4,7 @@
* @package testing
* @version $Id$
* @copyright (c) 2008 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/bbcode/url_bbcode_test.php b/tests/bbcode/url_bbcode_test.php
index 68c97ede50..b944b6135d 100644
--- a/tests/bbcode/url_bbcode_test.php
+++ b/tests/bbcode/url_bbcode_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index b7c3534cde..302701e3b3 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -3,39 +3,30 @@
*
* @package testing
* @copyright (c) 2008 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
define('IN_PHPBB', true);
$phpbb_root_path = 'phpBB/';
$phpEx = 'php';
-$table_prefix = 'phpbb_';
-
-if (!defined('E_DEPRECATED'))
-{
- define('E_DEPRECATED', 8192);
-}
-error_reporting(E_ALL & ~E_DEPRECATED);
-
-// If we are on PHP >= 6.0.0 we do not need some code
-if (version_compare(PHP_VERSION, '6.0.0-dev', '>='))
-{
- define('STRIP', false);
-}
-else
-{
- @set_magic_quotes_runtime(0);
- define('STRIP', (get_magic_quotes_gpc()) ? true : false);
-}
+require_once $phpbb_root_path . 'includes/startup.php';
+$table_prefix = 'phpbb_';
require_once $phpbb_root_path . 'includes/constants.php';
require_once $phpbb_root_path . 'includes/class_loader.' . $phpEx;
-$class_loader = new phpbb_class_loader($phpbb_root_path, '.php');
-$class_loader->register();
+$phpbb_class_loader_ext = new phpbb_class_loader('phpbb_ext_', $phpbb_root_path . 'ext/', ".php");
+$phpbb_class_loader_ext->register();
+$phpbb_class_loader = new phpbb_class_loader('phpbb_', $phpbb_root_path . 'includes/', ".php");
+$phpbb_class_loader->register();
require_once 'test_framework/phpbb_test_case_helpers.php';
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';
+
+if (version_compare(PHP_VERSION, '5.3.0-dev', '>='))
+{
+ require_once 'test_framework/phpbb_functional_test_case.php';
+}
diff --git a/tests/cache/cache_test.php b/tests/cache/cache_test.php
index b127c507f0..564bd35863 100644
--- a/tests/cache/cache_test.php
+++ b/tests/cache/cache_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/class_loader/class_loader_test.php b/tests/class_loader/class_loader_test.php
index 0c7fe3f97a..80f0b38095 100644
--- a/tests/class_loader/class_loader_test.php
+++ b/tests/class_loader/class_loader_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
@@ -13,20 +13,26 @@ class phpbb_class_loader_test extends PHPUnit_Framework_TestCase
{
public function setUp()
{
- global $class_loader;
- $class_loader->unregister();
+ global $phpbb_class_loader;
+ $phpbb_class_loader->unregister();
+
+ global $phpbb_class_loader_ext;
+ $phpbb_class_loader_ext->unregister();
}
public function tearDown()
{
- global $class_loader;
- $class_loader->register();
+ global $phpbb_class_loader_ext;
+ $phpbb_class_loader_ext->register();
+
+ global $phpbb_class_loader;
+ $phpbb_class_loader->register();
}
public function test_resolve_path()
{
$prefix = dirname(__FILE__) . '/';
- $class_loader = new phpbb_class_loader($prefix);
+ $class_loader = new phpbb_class_loader('phpbb_', $prefix . 'includes/');
$prefix .= 'includes/';
@@ -60,11 +66,15 @@ class phpbb_class_loader_test extends PHPUnit_Framework_TestCase
public function test_resolve_cached()
{
- $cacheMap = array('class_loader' => array('phpbb_a_cached_name' => 'a/cached_name'));
- $cache = new phpbb_mock_cache($cacheMap);
+ $cache_map = array(
+ 'class_loader_phpbb_' => array('phpbb_a_cached_name' => 'a/cached_name'),
+ 'class_loader_phpbb_ext_' => array('phpbb_ext_foo' => 'foo'),
+ );
+ $cache = new phpbb_mock_cache($cache_map);
$prefix = dirname(__FILE__) . '/';
- $class_loader = new phpbb_class_loader($prefix, '.php', $cache);
+ $class_loader = new phpbb_class_loader('phpbb_', $prefix . 'includes/', '.php', $cache);
+ $class_loader_ext = new phpbb_class_loader('phpbb_ext_', $prefix . 'includes/', '.php', $cache);
$prefix .= 'includes/';
@@ -74,13 +84,22 @@ class phpbb_class_loader_test extends PHPUnit_Framework_TestCase
'Class in a directory'
);
+ $this->assertFalse($class_loader->resolve_path('phpbb_ext_foo'));
+ $this->assertFalse($class_loader_ext->resolve_path('phpbb_a_cached_name'));
+
$this->assertEquals(
$prefix . 'a/cached_name.php',
$class_loader->resolve_path('phpbb_a_cached_name'),
- 'Class in a directory'
+ 'Cached class found'
+ );
+
+ $this->assertEquals(
+ $prefix . 'foo.php',
+ $class_loader_ext->resolve_path('phpbb_ext_foo'),
+ 'Cached class found in alternative loader'
);
- $cacheMap['class_loader']['phpbb_dir_class_name'] = 'dir/class_name';
- $cache->check($this, $cacheMap);
+ $cache_map['class_loader_phpbb_']['phpbb_dir_class_name'] = 'dir/class_name';
+ $cache->check($this, $cache_map);
}
}
diff --git a/tests/config/config_test.php b/tests/config/config_test.php
index 9c91d9eb87..5845cc4590 100644
--- a/tests/config/config_test.php
+++ b/tests/config/config_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/config/db_test.php b/tests/config/db_test.php
index e817545a54..a9a53541a5 100644
--- a/tests/config/db_test.php
+++ b/tests/config/db_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/cron/task/testmod/second_dummy_task.php b/tests/cron/ext/testext/cron/dummy_task.php
index 7118b2ebe7..996f5b39cf 100644
--- a/tests/cron/task/testmod/second_dummy_task.php
+++ b/tests/cron/ext/testext/cron/dummy_task.php
@@ -3,11 +3,11 @@
*
* @package testing
* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
-class phpbb_cron_task_testmod_second_dummy_task extends phpbb_cron_task_base
+class phpbb_ext_testext_cron_dummy_task extends phpbb_cron_task_base
{
public static $was_run = 0;
diff --git a/tests/cron/task/testmod/dummy_task.php b/tests/cron/includes/cron/task/core/dummy_task.php
index 5941157589..6e2e2db636 100644
--- a/tests/cron/task/testmod/dummy_task.php
+++ b/tests/cron/includes/cron/task/core/dummy_task.php
@@ -3,11 +3,11 @@
*
* @package testing
* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
-class phpbb_cron_task_testmod_dummy_task extends phpbb_cron_task_base
+class phpbb_cron_task_core_dummy_task extends phpbb_cron_task_base
{
public static $was_run = 0;
diff --git a/tests/cron/includes/cron/task/core/second_dummy_task.php b/tests/cron/includes/cron/task/core/second_dummy_task.php
new file mode 100644
index 0000000000..8cd0bddfc0
--- /dev/null
+++ b/tests/cron/includes/cron/task/core/second_dummy_task.php
@@ -0,0 +1,23 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2010 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+class phpbb_cron_task_core_second_dummy_task extends phpbb_cron_task_base
+{
+ public static $was_run = 0;
+
+ public function run()
+ {
+ self::$was_run++;
+ }
+
+ public function should_run()
+ {
+ return true;
+ }
+}
diff --git a/tests/cron/manager_test.php b/tests/cron/manager_test.php
index 65d8360fbb..f433fc9a9b 100644
--- a/tests/cron/manager_test.php
+++ b/tests/cron/manager_test.php
@@ -3,29 +3,28 @@
*
* @package testing
* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
-require_once dirname(__FILE__) . '/../mock/cache.php';
-require_once dirname(__FILE__) . '/task/testmod/dummy_task.php';
-require_once dirname(__FILE__) . '/task/testmod/second_dummy_task.php';
-require_once dirname(__FILE__) . '/task2/testmod/simple_ready.php';
-require_once dirname(__FILE__) . '/task2/testmod/simple_not_runnable.php';
-require_once dirname(__FILE__) . '/task2/testmod/simple_should_not_run.php';
+require_once dirname(__FILE__) . '/../mock/extension_manager.php';
+require_once dirname(__FILE__) . '/includes/cron/task/core/dummy_task.php';
+require_once dirname(__FILE__) . '/includes/cron/task/core/second_dummy_task.php';
+require_once dirname(__FILE__) . '/ext/testext/cron/dummy_task.php';
+require_once dirname(__FILE__) . '/tasks/simple_ready.php';
+require_once dirname(__FILE__) . '/tasks/simple_not_runnable.php';
+require_once dirname(__FILE__) . '/tasks/simple_should_not_run.php';
class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase
{
public function setUp()
{
- $this->manager = new phpbb_cron_manager(dirname(__FILE__) . '/task/', 'php');
- $this->task_name = 'phpbb_cron_task_testmod_dummy_task';
- }
-
- public function test_manager_finds_shipped_tasks()
- {
- $tasks = $this->manager->find_cron_task_names();
- $this->assertEquals(2, sizeof($tasks));
+ $this->manager = new phpbb_cron_manager(array(
+ 'phpbb_cron_task_core_dummy_task',
+ 'phpbb_cron_task_core_second_dummy_task',
+ 'phpbb_ext_testext_cron_dummy_task',
+ ));
+ $this->task_name = 'phpbb_cron_task_core_dummy_task';
}
public function test_manager_finds_shipped_task_by_name()
@@ -45,7 +44,7 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase
public function test_manager_finds_all_ready_tasks()
{
$tasks = $this->manager->find_all_ready_tasks();
- $this->assertEquals(2, sizeof($tasks));
+ $this->assertEquals(3, sizeof($tasks));
}
public function test_manager_finds_one_ready_task()
@@ -54,21 +53,16 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase
$this->assertInstanceOf('phpbb_cron_task_wrapper', $task);
}
- public function test_manager_finds_all_ready_tasks_cached()
- {
- $cache = new phpbb_mock_cache(array('_cron_tasks' => array($this->task_name)));
- $manager = new phpbb_cron_manager(dirname(__FILE__) . '/../../phpBB/', 'php', $cache);
-
- $tasks = $manager->find_all_ready_tasks();
- $this->assertEquals(1, sizeof($tasks));
- }
-
public function test_manager_finds_only_ready_tasks()
{
- $manager = new phpbb_cron_manager(dirname(__FILE__) . '/task2/', 'php');
+ $manager = new phpbb_cron_manager(array(
+ 'phpbb_cron_task_core_simple_ready',
+ 'phpbb_cron_task_core_simple_not_runnable',
+ 'phpbb_cron_task_core_simple_should_not_run',
+ ));
$tasks = $manager->find_all_ready_tasks();
$task_names = $this->tasks_to_names($tasks);
- $this->assertEquals(array('phpbb_cron_task_testmod_simple_ready'), $task_names);
+ $this->assertEquals(array('phpbb_cron_task_core_simple_ready'), $task_names);
}
private function tasks_to_names($tasks)
diff --git a/tests/cron/task2/testmod/simple_ready.php b/tests/cron/task2/testmod/simple_ready.php
deleted file mode 100644
index e407441e90..0000000000
--- a/tests/cron/task2/testmod/simple_ready.php
+++ /dev/null
@@ -1,8 +0,0 @@
-<?php
-
-class phpbb_cron_task_testmod_simple_ready extends phpbb_cron_task_base
-{
- public function run()
- {
- }
-}
diff --git a/tests/cron/task_provider_test.php b/tests/cron/task_provider_test.php
new file mode 100644
index 0000000000..4547c61a55
--- /dev/null
+++ b/tests/cron/task_provider_test.php
@@ -0,0 +1,43 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2010 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+require_once dirname(__FILE__) . '/../mock/extension_manager.php';
+
+class phpbb_cron_task_provider_test extends PHPUnit_Framework_TestCase
+{
+ public function setUp()
+ {
+ $this->extension_manager = new phpbb_mock_extension_manager(
+ dirname(__FILE__) . '/',
+ array(
+ 'testext' => array(
+ 'ext_name' => 'testext',
+ 'ext_active' => true,
+ 'ext_path' => 'ext/testext/'
+ ),
+ ));
+ $this->provider = new phpbb_cron_task_provider($this->extension_manager);
+ }
+
+ public function test_manager_finds_shipped_tasks()
+ {
+ $tasks = array();
+ foreach ($this->provider as $task)
+ {
+ $tasks[] = $task;
+ }
+ sort($tasks);
+
+ $this->assertEquals(array(
+ 'phpbb_cron_task_core_dummy_task',
+ 'phpbb_cron_task_core_second_dummy_task',
+ 'phpbb_ext_testext_cron_dummy_task',
+ ), $tasks);
+ }
+}
diff --git a/tests/cron/task2/testmod/simple_not_runnable.php b/tests/cron/tasks/simple_not_runnable.php
index 54869fa1cc..837f28f1c0 100644
--- a/tests/cron/task2/testmod/simple_not_runnable.php
+++ b/tests/cron/tasks/simple_not_runnable.php
@@ -1,6 +1,6 @@
<?php
-class phpbb_cron_task_testmod_simple_not_runnable extends phpbb_cron_task_base
+class phpbb_cron_task_core_simple_not_runnable extends phpbb_cron_task_base
{
public function run()
{
diff --git a/tests/cron/tasks/simple_ready.php b/tests/cron/tasks/simple_ready.php
new file mode 100644
index 0000000000..de5f10e491
--- /dev/null
+++ b/tests/cron/tasks/simple_ready.php
@@ -0,0 +1,8 @@
+<?php
+
+class phpbb_cron_task_core_simple_ready extends phpbb_cron_task_base
+{
+ public function run()
+ {
+ }
+}
diff --git a/tests/cron/task2/testmod/simple_should_not_run.php b/tests/cron/tasks/simple_should_not_run.php
index 14ba4cdbd3..c2a41616f6 100644
--- a/tests/cron/task2/testmod/simple_should_not_run.php
+++ b/tests/cron/tasks/simple_should_not_run.php
@@ -1,6 +1,6 @@
<?php
-class phpbb_cron_task_testmod_simple_should_not_run extends phpbb_cron_task_base
+class phpbb_cron_task_core_simple_should_not_run extends phpbb_cron_task_base
{
public function run()
{
diff --git a/tests/dbal/cross_join_test.php b/tests/dbal/cross_join_test.php
new file mode 100644
index 0000000000..6c6b8a8449
--- /dev/null
+++ b/tests/dbal/cross_join_test.php
@@ -0,0 +1,55 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
+
+class phpbb_dbal_cross_join_test extends phpbb_database_test_case
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/massmail_crossjoin.xml');
+ }
+
+ public function test_cross_join()
+ {
+ $db = $this->new_dbal();
+
+ // http://tracker.phpbb.com/browse/PHPBB3-10296
+ // Test CROSS JOIN with INNER JOIN
+ // Failed on Postgres, MSSQL and Oracle
+ $db->sql_return_on_error(true);
+
+ $sql_ary = array(
+ 'SELECT' => 'u.username',
+ 'FROM' => array(
+ 'phpbb_users' => 'u',
+ 'phpbb_user_group' => 'ug',
+ ),
+ 'LEFT_JOIN' => array(
+ array(
+ 'FROM' => array(
+ 'phpbb_banlist' => 'b',
+ ),
+ 'ON' => 'u.user_id = b.ban_userid',
+ ),
+ ),
+ 'WHERE' => 'ug.group_id = 1
+ AND u.user_id = ug.user_id
+ AND b.ban_id IS NULL',
+ 'ORDER_BY' => 'u.username',
+ );
+ $sql = $db->sql_build_query('SELECT', $sql_ary);
+ $result = $db->sql_query($sql);
+
+ $db->sql_return_on_error(false);
+
+ $this->assertEquals(array(array('username' => 'mass email')), $db->sql_fetchrowset($result));
+ }
+}
diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php
index 753cc08fc5..fbde636b58 100644
--- a/tests/dbal/db_tools_test.php
+++ b/tests/dbal/db_tools_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
@@ -234,6 +234,14 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
$this->assertEquals($row2, $row_actual);
}
+ public function test_list_columns()
+ {
+ $this->assertEquals(
+ array_keys($this->table_data['COLUMNS']),
+ array_values($this->tools->sql_list_columns('prefix_table_name'))
+ );
+ }
+
public function test_column_exists()
{
$this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_id'));
@@ -258,6 +266,13 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
$this->assertFalse($this->tools->sql_column_exists('prefix_table_name', 'c_id'));
}
+ public function test_list_tables()
+ {
+ $tables = $this->tools->sql_list_tables();
+ $this->assertTrue(isset($tables['prefix_table_name']));
+ $this->assertFalse(isset($tables['prefix_does_not_exist']));
+ }
+
public function test_table_exists()
{
$this->assertTrue($this->tools->sql_table_exists('prefix_table_name'));
@@ -333,4 +348,15 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
),
));
}
+
+ public function test_index_exists()
+ {
+ $this->assertTrue($this->tools->sql_index_exists('prefix_table_name', 'i_simple'));
+ }
+
+ public function test_create_index_against_index_exists()
+ {
+ $this->tools->sql_create_index('prefix_table_name', 'fookey', array('c_timestamp', 'c_decimal'));
+ $this->assertTrue($this->tools->sql_index_exists('prefix_table_name', 'fookey'));
+ }
}
diff --git a/tests/dbal/fixtures/massmail_crossjoin.xml b/tests/dbal/fixtures/massmail_crossjoin.xml
new file mode 100644
index 0000000000..ef0a2b7149
--- /dev/null
+++ b/tests/dbal/fixtures/massmail_crossjoin.xml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_banlist">
+ <column>ban_id</column>
+ <column>ban_userid</column>
+ <row>
+ <value>1</value>
+ <value>2</value>
+ </row>
+ </table>
+ <table name="phpbb_users">
+ <column>user_id</column>
+ <column>username</column>
+ <column>username_clean</column>
+ <column>user_permissions</column>
+ <column>user_sig</column>
+ <column>user_occ</column>
+ <column>user_interests</column>
+ <row>
+ <value>1</value>
+ <value>mass email</value>
+ <value>mass email</value>
+ <value></value>
+ <value></value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>banned</value>
+ <value>banned</value>
+ <value></value>
+ <value></value>
+ <value></value>
+ <value></value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>not in group</value>
+ <value>not in group</value>
+ <value></value>
+ <value></value>
+ <value></value>
+ <value></value>
+ </row>
+ </table>
+ <table name="phpbb_user_group">
+ <column>user_id</column>
+ <column>group_id</column>
+ <row>
+ <value>1</value>
+ <value>1</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>1</value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/dbal/fixtures/styles.xml b/tests/dbal/fixtures/styles.xml
new file mode 100644
index 0000000000..36fc22a48f
--- /dev/null
+++ b/tests/dbal/fixtures/styles.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_styles">
+ <column>style_id</column>
+ <column>style_name</column>
+ <column>style_copyright</column>
+ <column>style_active</column>
+ <column>template_id</column>
+ <column>theme_id</column>
+ <row>
+ <value>1</value>
+ <value>prosilver</value>
+ <value>&amp;copy; phpBB Group</value>
+ <value>1</value>
+ <value>1</value>
+ <value>1</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>prosilver2</value>
+ <value>&amp;copy; phpBB Group</value>
+ <value>0</value>
+ <value>2</value>
+ <value>2</value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>Prosilver1</value>
+ <value>&amp;copy; phpBB Group</value>
+ <value>0</value>
+ <value>3</value>
+ <value>3</value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/dbal/fixtures/three_users.xml b/tests/dbal/fixtures/three_users.xml
index a6789f4a01..a50e3e8634 100644
--- a/tests/dbal/fixtures/three_users.xml
+++ b/tests/dbal/fixtures/three_users.xml
@@ -3,17 +3,33 @@
<table name="phpbb_users">
<column>user_id</column>
<column>username_clean</column>
+ <column>user_permissions</column>
+ <column>user_sig</column>
+ <column>user_occ</column>
+ <column>user_interests</column>
<row>
<value>1</value>
<value>barfoo</value>
+ <value></value>
+ <value></value>
+ <value></value>
+ <value></value>
</row>
<row>
<value>2</value>
<value>foobar</value>
+ <value></value>
+ <value></value>
+ <value></value>
+ <value></value>
</row>
<row>
<value>3</value>
<value>bertie</value>
+ <value></value>
+ <value></value>
+ <value></value>
+ <value></value>
</row>
</table>
</dataset>
diff --git a/tests/dbal/order_lower_test.php b/tests/dbal/order_lower_test.php
new file mode 100644
index 0000000000..eaf5211508
--- /dev/null
+++ b/tests/dbal/order_lower_test.php
@@ -0,0 +1,59 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+class phpbb_dbal_order_lower_test extends phpbb_database_test_case
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/styles.xml');
+ }
+
+ public function test_cross_join()
+ {
+ $db = $this->new_dbal();
+
+ // http://tracker.phpbb.com/browse/PHPBB3-10507
+ // Test ORDER BY LOWER(style_name)
+ $db->sql_return_on_error(true);
+
+ $sql = 'SELECT * FROM phpbb_styles ORDER BY LOWER(style_name)';
+ $result = $db->sql_query($sql);
+
+ $db->sql_return_on_error(false);
+
+ $this->assertEquals(array(
+ array(
+ 'style_id' => 1,
+ 'style_name' => 'prosilver',
+ 'style_copyright' => '&copy; phpBB Group',
+ 'style_active' => 1,
+ 'template_id' => 1,
+ 'theme_id' => 1,
+ ),
+ array(
+ 'style_id' => 3,
+ 'style_name' => 'Prosilver1',
+ 'style_copyright' => '&copy; phpBB Group',
+ 'style_active' => 0,
+ 'template_id' => 3,
+ 'theme_id' => 3,
+ ),
+ array(
+ 'style_id' => 2,
+ 'style_name' => 'prosilver2',
+ 'style_copyright' => '&copy; phpBB Group',
+ 'style_active' => 0,
+ 'template_id' => 2,
+ 'theme_id' => 2,
+ )
+ ),
+ $db->sql_fetchrowset($result)
+ );
+ }
+}
diff --git a/tests/dbal/schema_test.php b/tests/dbal/schema_test.php
index 2475a85708..2a332fddba 100644
--- a/tests/dbal/schema_test.php
+++ b/tests/dbal/schema_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/dbal/select_test.php b/tests/dbal/select_test.php
index e0d08d9306..05b0e68e29 100644
--- a/tests/dbal/select_test.php
+++ b/tests/dbal/select_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2008 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
@@ -319,7 +319,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
$db->sql_freeresult($result);
}
- function test_nested_transactions()
+ public function test_nested_transactions()
{
$db = $this->new_dbal();
@@ -341,4 +341,20 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
$this->assertEquals('1', $row['user_id']);
}
+
+ /**
+ * fix for PHPBB3-10307
+ */
+ public function test_sql_fetchrow_returns_false_when_empty()
+ {
+ $db = $this->new_dbal();
+
+ $sql = 'SELECT * FROM (SELECT 1) AS TBL WHERE 1 = 0';
+ $result = $db->sql_query($sql);
+
+ $row = $db->sql_fetchrow($result);
+ $db->sql_freeresult($result);
+
+ $this->assertSame(false, $row);
+ }
}
diff --git a/tests/dbal/write_test.php b/tests/dbal/write_test.php
index 4709d45fa5..596c50a220 100644
--- a/tests/dbal/write_test.php
+++ b/tests/dbal/write_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2008 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/download/http_byte_range_test.php b/tests/download/http_byte_range_test.php
index 36cbcab0b0..b93c1b630c 100644
--- a/tests/download/http_byte_range_test.php
+++ b/tests/download/http_byte_range_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/error_collector_test.php b/tests/error_collector_test.php
index e1ac32f5ac..d67dea3719 100644
--- a/tests/error_collector_test.php
+++ b/tests/error_collector_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/extension/ext/bar/ext.php b/tests/extension/ext/bar/ext.php
new file mode 100644
index 0000000000..5585edf9ac
--- /dev/null
+++ b/tests/extension/ext/bar/ext.php
@@ -0,0 +1,24 @@
+<?php
+
+class phpbb_ext_bar_ext extends phpbb_extension_base
+{
+ static public $state;
+
+ public function enable_step($old_state)
+ {
+ // run 4 steps, then quit
+ if ($old_state === 4)
+ {
+ return false;
+ }
+
+ if ($old_state === false)
+ {
+ $old_state = 0;
+ }
+
+ self::$state = ++$old_state;
+
+ return self::$state;
+ }
+}
diff --git a/tests/extension/ext/bar/my/hidden_class.php b/tests/extension/ext/bar/my/hidden_class.php
new file mode 100644
index 0000000000..0261d7c59a
--- /dev/null
+++ b/tests/extension/ext/bar/my/hidden_class.php
@@ -0,0 +1,5 @@
+<?php
+
+class phpbb_ext_bar_my_hidden_class
+{
+}
diff --git a/tests/extension/ext/foo/a_class.php b/tests/extension/ext/foo/a_class.php
new file mode 100644
index 0000000000..b7be1ad654
--- /dev/null
+++ b/tests/extension/ext/foo/a_class.php
@@ -0,0 +1,5 @@
+<?php
+
+class phpbb_ext_foo_a_class
+{
+}
diff --git a/tests/extension/ext/foo/b_class.php b/tests/extension/ext/foo/b_class.php
new file mode 100644
index 0000000000..4645266122
--- /dev/null
+++ b/tests/extension/ext/foo/b_class.php
@@ -0,0 +1,5 @@
+<?php
+
+class phpbb_ext_foo_b_class
+{
+}
diff --git a/tests/extension/ext/foo/ext.php b/tests/extension/ext/foo/ext.php
new file mode 100644
index 0000000000..60b3ad1f16
--- /dev/null
+++ b/tests/extension/ext/foo/ext.php
@@ -0,0 +1,13 @@
+<?php
+
+class phpbb_ext_foo_ext extends phpbb_extension_base
+{
+ static public $disabled;
+
+ public function disable_step($old_state)
+ {
+ self::$disabled = true;
+
+ return false;
+ }
+}
diff --git a/tests/extension/ext/foo/sub/type/alternative.php b/tests/extension/ext/foo/sub/type/alternative.php
new file mode 100644
index 0000000000..2ea7353f4b
--- /dev/null
+++ b/tests/extension/ext/foo/sub/type/alternative.php
@@ -0,0 +1,5 @@
+<?php
+
+class phpbb_ext_foo_sub_type_alternative
+{
+}
diff --git a/tests/extension/ext/foo/type/alternative.php b/tests/extension/ext/foo/type/alternative.php
new file mode 100644
index 0000000000..404b66b965
--- /dev/null
+++ b/tests/extension/ext/foo/type/alternative.php
@@ -0,0 +1,5 @@
+<?php
+
+class phpbb_ext_foo_type_alternative
+{
+}
diff --git a/tests/extension/ext/foo/typewrong/error.php b/tests/extension/ext/foo/typewrong/error.php
new file mode 100644
index 0000000000..ba22cfae9a
--- /dev/null
+++ b/tests/extension/ext/foo/typewrong/error.php
@@ -0,0 +1,5 @@
+<?php
+
+class phpbb_ext_foo_typewrong_error
+{
+}
diff --git a/tests/extension/ext/vendor/moo/ext.php b/tests/extension/ext/vendor/moo/ext.php
new file mode 100644
index 0000000000..e0ac1a22cc
--- /dev/null
+++ b/tests/extension/ext/vendor/moo/ext.php
@@ -0,0 +1,13 @@
+<?php
+
+class phpbb_ext_vendor_moo_ext extends phpbb_extension_base
+{
+ static public $purged;
+
+ public function purge_step($old_state)
+ {
+ self::$purged = true;
+
+ return false;
+ }
+}
diff --git a/tests/extension/ext/vendor/moo/feature_class.php b/tests/extension/ext/vendor/moo/feature_class.php
new file mode 100644
index 0000000000..c3bcc4451c
--- /dev/null
+++ b/tests/extension/ext/vendor/moo/feature_class.php
@@ -0,0 +1,5 @@
+<?php
+
+class phpbb_ext_vendor_moo_feature_class
+{
+}
diff --git a/tests/extension/finder_test.php b/tests/extension/finder_test.php
new file mode 100644
index 0000000000..f7e9bd57bb
--- /dev/null
+++ b/tests/extension/finder_test.php
@@ -0,0 +1,206 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+require_once dirname(__FILE__) . '/../mock/cache.php';
+require_once dirname(__FILE__) . '/../mock/extension_manager.php';
+
+class phpbb_extension_finder_test extends phpbb_test_case
+{
+ protected $extension_manager;
+ protected $finder;
+
+ public function setUp()
+ {
+ $this->extension_manager = new phpbb_mock_extension_manager(
+ dirname(__FILE__) . '/',
+ array(
+ 'foo' => array(
+ 'ext_name' => 'foo',
+ 'ext_active' => '1',
+ 'ext_path' => 'ext/foo/',
+ ),
+ 'bar' => array(
+ 'ext_name' => 'bar',
+ 'ext_active' => '1',
+ 'ext_path' => 'ext/bar/',
+ ),
+ ));
+
+ $this->finder = $this->extension_manager->get_finder();
+ }
+
+ public function test_suffix_get_classes()
+ {
+ $classes = $this->finder
+ ->core_path('includes/default/')
+ ->extension_suffix('_class')
+ ->get_classes();
+
+ sort($classes);
+ $this->assertEquals(
+ array(
+ 'phpbb_default_implementation',
+ 'phpbb_ext_bar_my_hidden_class',
+ 'phpbb_ext_foo_a_class',
+ 'phpbb_ext_foo_b_class',
+ ),
+ $classes
+ );
+ }
+
+ public function test_get_directories()
+ {
+ $dirs = $this->finder
+ ->directory('/type')
+ ->get_directories();
+
+ sort($dirs);
+ $this->assertEquals(array(
+ dirname(__FILE__) . '/ext/foo/type/',
+ ), $dirs);
+ }
+
+ public function test_prefix_get_directories()
+ {
+ $dirs = $this->finder
+ ->prefix('t')
+ ->get_directories();
+
+ sort($dirs);
+ $this->assertEquals(array(
+ dirname(__FILE__) . '/ext/foo/sub/type/',
+ dirname(__FILE__) . '/ext/foo/type/',
+ dirname(__FILE__) . '/ext/foo/typewrong/',
+ ), $dirs);
+ }
+
+ public function test_prefix_get_classes()
+ {
+ $classes = $this->finder
+ ->core_path('includes/default/')
+ ->extension_prefix('hidden_')
+ ->get_classes();
+
+ sort($classes);
+ $this->assertEquals(
+ array(
+ 'phpbb_default_implementation',
+ 'phpbb_ext_bar_my_hidden_class',
+ ),
+ $classes
+ );
+ }
+
+ public function test_directory_get_classes()
+ {
+ $classes = $this->finder
+ ->core_path('includes/default/')
+ ->extension_directory('type')
+ ->get_classes();
+
+ sort($classes);
+ $this->assertEquals(
+ array(
+ 'phpbb_default_implementation',
+ 'phpbb_ext_foo_sub_type_alternative',
+ 'phpbb_ext_foo_type_alternative',
+ ),
+ $classes
+ );
+ }
+
+ public function test_absolute_directory_get_classes()
+ {
+ $classes = $this->finder
+ ->directory('/type/')
+ ->get_classes();
+
+ sort($classes);
+ $this->assertEquals(
+ array(
+ 'phpbb_ext_foo_type_alternative',
+ ),
+ $classes
+ );
+ }
+
+ public function test_sub_directory_get_classes()
+ {
+ $classes = $this->finder
+ ->directory('/sub/type')
+ ->get_classes();
+
+ sort($classes);
+ $this->assertEquals(
+ array(
+ 'phpbb_ext_foo_sub_type_alternative',
+ ),
+ $classes
+ );
+ }
+
+ public function test_get_classes_create_cache()
+ {
+ $cache = new phpbb_mock_cache;
+ $finder = new phpbb_extension_finder($this->extension_manager, dirname(__FILE__) . '/', $cache, '.php', '_custom_cache_name');
+ $files = $finder->suffix('_class.php')->get_files();
+
+ $expected_files = array(
+ 'ext/bar/my/hidden_class.php' => 'bar',
+ 'ext/foo/a_class.php' => 'foo',
+ 'ext/foo/b_class.php' => 'foo',
+ );
+
+ $query = array(
+ 'core_path' => false,
+ 'core_suffix' => '_class.php',
+ 'core_prefix' => false,
+ 'core_directory' => false,
+ 'extension_suffix' => '_class.php',
+ 'extension_prefix' => false,
+ 'extension_directory' => false,
+ 'is_dir' => false,
+ );
+
+ $cache->checkAssociativeVar($this, '_custom_cache_name', array(
+ md5(serialize($query)) => $expected_files,
+ ), false);
+ }
+
+ public function test_cached_get_files()
+ {
+ $query = array(
+ 'core_path' => 'includes/foo',
+ 'core_suffix' => false,
+ 'core_prefix' => false,
+ 'core_directory' => 'bar',
+ 'extension_suffix' => false,
+ 'extension_prefix' => false,
+ 'extension_directory' => false,
+ 'is_dir' => false,
+ );
+
+ $finder = new phpbb_extension_finder($this->extension_manager, dirname(__FILE__) . '/', new phpbb_mock_cache(array(
+ '_ext_finder' => array(
+ md5(serialize($query)) => array('file_name' => 'extension'),
+ ),
+ )));
+
+ $classes = $finder
+ ->core_path($query['core_path'])
+ ->core_directory($query['core_directory'])
+ ->get_files();
+
+ sort($classes);
+ $this->assertEquals(
+ array(dirname(__FILE__) . '/file_name'),
+ $classes
+ );
+ }
+}
diff --git a/tests/extension/fixtures/extensions.xml b/tests/extension/fixtures/extensions.xml
new file mode 100644
index 0000000000..65cb71c7a4
--- /dev/null
+++ b/tests/extension/fixtures/extensions.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_ext">
+ <column>ext_name</column>
+ <column>ext_active</column>
+ <row>
+ <value>foo</value>
+ <value>1</value>
+ </row>
+ <row>
+ <value>vendor/moo</value>
+ <value>0</value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/extension/includes/default/implementation.php b/tests/extension/includes/default/implementation.php
new file mode 100644
index 0000000000..91d5f8aa2f
--- /dev/null
+++ b/tests/extension/includes/default/implementation.php
@@ -0,0 +1,5 @@
+<?php
+
+class phpbb_default_impl_class implements phpbb_default_interface
+{
+}
diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php
new file mode 100644
index 0000000000..0a689916c7
--- /dev/null
+++ b/tests/extension/manager_test.php
@@ -0,0 +1,102 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+require_once dirname(__FILE__) . '/../mock/cache.php';
+require_once dirname(__FILE__) . '/ext/bar/ext.php';
+require_once dirname(__FILE__) . '/ext/foo/ext.php';
+require_once dirname(__FILE__) . '/ext/vendor/moo/ext.php';
+
+class phpbb_extension_manager_test extends phpbb_database_test_case
+{
+ protected $extension_manager;
+ protected $class_loader;
+
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/extensions.xml');
+ }
+
+ protected function setUp()
+ {
+ parent::setUp();
+
+ $this->extension_manager = new phpbb_extension_manager(
+ $this->new_dbal(),
+ 'phpbb_ext',
+ dirname(__FILE__) . '/',
+ '.php',
+ new phpbb_mock_cache
+ );
+ }
+
+ public function test_available()
+ {
+ $this->assertEquals(array('bar', 'foo', 'vendor/moo'), array_keys($this->extension_manager->all_available()));
+ }
+
+ public function test_enabled()
+ {
+ $this->assertEquals(array('foo'), array_keys($this->extension_manager->all_enabled()));
+ }
+
+ public function test_configured()
+ {
+ $this->assertEquals(array('foo', 'vendor/moo'), array_keys($this->extension_manager->all_configured()));
+ }
+
+ public function test_enable()
+ {
+ phpbb_ext_bar_ext::$state = 0;
+
+ $this->assertEquals(array('foo'), array_keys($this->extension_manager->all_enabled()));
+ $this->extension_manager->enable('bar');
+ $this->assertEquals(array('bar', 'foo'), array_keys($this->extension_manager->all_enabled()));
+ $this->assertEquals(array('bar', 'foo', 'vendor/moo'), array_keys($this->extension_manager->all_configured()));
+
+ $this->assertEquals(4, phpbb_ext_bar_ext::$state);
+ }
+
+ public function test_disable()
+ {
+ phpbb_ext_foo_ext::$disabled = false;
+
+ $this->assertEquals(array('foo'), array_keys($this->extension_manager->all_enabled()));
+ $this->extension_manager->disable('foo');
+ $this->assertEquals(array(), array_keys($this->extension_manager->all_enabled()));
+ $this->assertEquals(array('foo', 'vendor/moo'), array_keys($this->extension_manager->all_configured()));
+
+ $this->assertTrue(phpbb_ext_foo_ext::$disabled);
+ }
+
+ public function test_purge()
+ {
+ phpbb_ext_vendor_moo_ext::$purged = false;
+
+ $this->assertEquals(array('foo'), array_keys($this->extension_manager->all_enabled()));
+ $this->assertEquals(array('foo', 'vendor/moo'), array_keys($this->extension_manager->all_configured()));
+ $this->extension_manager->purge('vendor/moo');
+ $this->assertEquals(array('foo'), array_keys($this->extension_manager->all_enabled()));
+ $this->assertEquals(array('foo'), array_keys($this->extension_manager->all_configured()));
+
+ $this->assertTrue(phpbb_ext_vendor_moo_ext::$purged);
+ }
+
+ public function test_enabled_no_cache()
+ {
+ $extension_manager = new phpbb_extension_manager(
+ $this->new_dbal(),
+ 'phpbb_ext',
+ dirname(__FILE__) . '/',
+ '.php'
+ );
+
+ $this->assertEquals(array('foo'), array_keys($extension_manager->all_enabled()));
+ }
+
+}
diff --git a/tests/functional/browse_test.php b/tests/functional/browse_test.php
new file mode 100644
index 0000000000..723cf93232
--- /dev/null
+++ b/tests/functional/browse_test.php
@@ -0,0 +1,26 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @group functional
+*/
+class phpbb_functional_browse_test extends phpbb_functional_test_case
+{
+ public function test_index()
+ {
+ $crawler = $this->request('GET', 'index.php');
+ $this->assertGreaterThan(0, $crawler->filter('.topiclist')->count());
+ }
+
+ public function test_viewforum()
+ {
+ $crawler = $this->request('GET', 'viewforum.php?f=2');
+ $this->assertGreaterThan(0, $crawler->filter('.topiclist')->count());
+ }
+}
diff --git a/tests/functions_acp/build_cfg_template_test.php b/tests/functions_acp/build_cfg_template_test.php
index 76e133181f..bb479ffac9 100644
--- a/tests/functions_acp/build_cfg_template_test.php
+++ b/tests/functions_acp/build_cfg_template_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/functions_acp/build_select_test.php b/tests/functions_acp/build_select_test.php
index 7079e69f12..782acae1fa 100644
--- a/tests/functions_acp/build_select_test.php
+++ b/tests/functions_acp/build_select_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/functions_acp/h_radio_test.php b/tests/functions_acp/h_radio_test.php
index 18cb5d031e..02b2444a9e 100644
--- a/tests/functions_acp/h_radio_test.php
+++ b/tests/functions_acp/h_radio_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/functions_acp/validate_config_vars_test.php b/tests/functions_acp/validate_config_vars_test.php
index 761788e264..55441561a6 100644
--- a/tests/functions_acp/validate_config_vars_test.php
+++ b/tests/functions_acp/validate_config_vars_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/functions_acp/validate_range_test.php b/tests/functions_acp/validate_range_test.php
index 11b7f87957..34ce848e76 100644
--- a/tests/functions_acp/validate_range_test.php
+++ b/tests/functions_acp/validate_range_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/group_positions/group_positions_test.php b/tests/group_positions/group_positions_test.php
index b68f205b37..fd9f57e78f 100644
--- a/tests/group_positions/group_positions_test.php
+++ b/tests/group_positions/group_positions_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/lock/db_test.php b/tests/lock/db_test.php
index ed15423314..f7b1557a0c 100644
--- a/tests/lock/db_test.php
+++ b/tests/lock/db_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/mock/cache.php b/tests/mock/cache.php
index 989180c256..c6d08afef0 100644
--- a/tests/mock/cache.php
+++ b/tests/mock/cache.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
@@ -59,6 +59,21 @@ class phpbb_mock_cache implements phpbb_cache_driver_interface
$test->assertEquals($data, $this->data[$var_name]);
}
+ public function checkAssociativeVar(PHPUnit_Framework_Assert $test, $var_name, $data, $sort = true)
+ {
+ $test->assertTrue(isset($this->data[$var_name]));
+
+ if ($sort)
+ {
+ foreach ($this->data[$var_name] as &$content)
+ {
+ sort($content);
+ }
+ }
+
+ $test->assertEquals($data, $this->data[$var_name]);
+ }
+
public function checkVarUnset(PHPUnit_Framework_Assert $test, $var_name)
{
$test->assertFalse(isset($this->data[$var_name]));
diff --git a/tests/mock/extension_manager.php b/tests/mock/extension_manager.php
new file mode 100644
index 0000000000..77f799dd3b
--- /dev/null
+++ b/tests/mock/extension_manager.php
@@ -0,0 +1,18 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+class phpbb_mock_extension_manager extends phpbb_extension_manager
+{
+ public function __construct($phpbb_root_path, $extensions = array())
+ {
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->phpEx = '.php';
+ $this->extensions = $extensions;
+ }
+}
diff --git a/tests/mock/lang.php b/tests/mock/lang.php
index 17a39629c1..781b3d060e 100644
--- a/tests/mock/lang.php
+++ b/tests/mock/lang.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/mock/request.php b/tests/mock/request.php
index 8b2708304c..946dfdada9 100644
--- a/tests/mock/request.php
+++ b/tests/mock/request.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/mock/session_testable.php b/tests/mock/session_testable.php
index 47089cb94b..70a58fb6cc 100644
--- a/tests/mock/session_testable.php
+++ b/tests/mock/session_testable.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2008 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/mock_user.php b/tests/mock_user.php
index 5b89ea3e19..ec14ce430e 100644
--- a/tests/mock_user.php
+++ b/tests/mock_user.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/network/checkdnsrr_test.php b/tests/network/checkdnsrr_test.php
index 5a756dcef8..1942a50f06 100644
--- a/tests/network/checkdnsrr_test.php
+++ b/tests/network/checkdnsrr_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/network/ftp_fsock_pasv_epsv_test.php b/tests/network/ftp_fsock_pasv_epsv_test.php
index 6ad811e3ca..22f17785b8 100644
--- a/tests/network/ftp_fsock_pasv_epsv_test.php
+++ b/tests/network/ftp_fsock_pasv_epsv_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/network/inet_ntop_pton_test.php b/tests/network/inet_ntop_pton_test.php
index d3332f20c0..a59c2103bd 100644
--- a/tests/network/inet_ntop_pton_test.php
+++ b/tests/network/inet_ntop_pton_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/network/ip_normalise_test.php b/tests/network/ip_normalise_test.php
index dce0774d85..28059f376a 100644
--- a/tests/network/ip_normalise_test.php
+++ b/tests/network/ip_normalise_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/profile/custom_test.php b/tests/profile/custom_test.php
index 0e0a851243..1f33b45ba9 100644
--- a/tests/profile/custom_test.php
+++ b/tests/profile/custom_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
@@ -48,7 +48,7 @@ class phpbb_profile_custom_test extends phpbb_database_test_case
);
$cp = new custom_profile;
- $result = $cp->validate_profile_field(FIELD_DROPDOWN, &$field_value, $field_data);
+ $result = $cp->validate_profile_field(FIELD_DROPDOWN, $field_value, $field_data);
$this->assertEquals($expected, $result, $description);
}
diff --git a/tests/random/gen_rand_string_test.php b/tests/random/gen_rand_string_test.php
index 115c55e4e2..3317c78ed9 100644
--- a/tests/random/gen_rand_string_test.php
+++ b/tests/random/gen_rand_string_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/regex/censor_test.php b/tests/regex/censor_test.php
index fa9104e71d..5929092e07 100644
--- a/tests/regex/censor_test.php
+++ b/tests/regex/censor_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/regex/email_test.php b/tests/regex/email_test.php
index 0695b801d5..17f93259c3 100644
--- a/tests/regex/email_test.php
+++ b/tests/regex/email_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/regex/ipv4_test.php b/tests/regex/ipv4_test.php
index 9829547508..38a3aa4a8e 100644
--- a/tests/regex/ipv4_test.php
+++ b/tests/regex/ipv4_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/regex/ipv6_test.php b/tests/regex/ipv6_test.php
index 1b2018403c..d24217b346 100644
--- a/tests/regex/ipv6_test.php
+++ b/tests/regex/ipv6_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/regex/password_complexity_test.php b/tests/regex/password_complexity_test.php
index 21e8d12a0a..07453555ee 100644
--- a/tests/regex/password_complexity_test.php
+++ b/tests/regex/password_complexity_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/regex/table_prefix_test.php b/tests/regex/table_prefix_test.php
new file mode 100644
index 0000000000..33bdd4ae2d
--- /dev/null
+++ b/tests/regex/table_prefix_test.php
@@ -0,0 +1,35 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+
+class phpbb_regex_table_prefix_test extends phpbb_test_case
+{
+ public function table_prefix_test_data()
+ {
+ return array(
+ array('phpbb_', 1),
+ array('phpBB3', 1),
+ array('a', 1),
+
+ array('', 0),
+ array('_', 0),
+ array('a-', 0),
+ array("'", 0),
+ );
+ }
+
+ /**
+ * @dataProvider table_prefix_test_data
+ */
+ public function test_table_prefix($prefix, $expected)
+ {
+ $this->assertEquals($expected, preg_match(get_preg_expression('table_prefix'), $prefix));
+ }
+}
diff --git a/tests/regex/url_test.php b/tests/regex/url_test.php
index c3a336063a..b395f5cae2 100644
--- a/tests/regex/url_test.php
+++ b/tests/regex/url_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2010 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/request/deactivated_super_global_test.php b/tests/request/deactivated_super_global_test.php
index 995f93443d..2e19928a5a 100644
--- a/tests/request/deactivated_super_global_test.php
+++ b/tests/request/deactivated_super_global_test.php
@@ -4,7 +4,7 @@
* @package testing
* @version $Id$
* @copyright (c) 2009 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/request/request_test.php b/tests/request/request_test.php
index e492fa5cf1..bca5125b7a 100644
--- a/tests/request/request_test.php
+++ b/tests/request/request_test.php
@@ -4,7 +4,7 @@
* @package testing
* @version $Id$
* @copyright (c) 2009 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/request/request_var_test.php b/tests/request/request_var_test.php
index 7a45ef2fee..1fa0afae13 100644
--- a/tests/request/request_var_test.php
+++ b/tests/request/request_var_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2008 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/request/type_cast_helper_test.php b/tests/request/type_cast_helper_test.php
index 06cf2e1bf6..d553d5b8cd 100644
--- a/tests/request/type_cast_helper_test.php
+++ b/tests/request/type_cast_helper_test.php
@@ -4,7 +4,7 @@
* @package testing
* @version $Id$
* @copyright (c) 2009 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/security/base.php b/tests/security/base.php
index 4b259a2aac..f7f3f9f661 100644
--- a/tests/security/base.php
+++ b/tests/security/base.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2008 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/security/extract_current_page_test.php b/tests/security/extract_current_page_test.php
index 34c7b52f49..00fc3b5841 100644
--- a/tests/security/extract_current_page_test.php
+++ b/tests/security/extract_current_page_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2008 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/security/hash_test.php b/tests/security/hash_test.php
index 19a3822145..0c2580c19b 100644
--- a/tests/security/hash_test.php
+++ b/tests/security/hash_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/security/redirect_test.php b/tests/security/redirect_test.php
index 76347d309f..634a506ab9 100644
--- a/tests/security/redirect_test.php
+++ b/tests/security/redirect_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2008 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/session/append_sid_test.php b/tests/session/append_sid_test.php
index 1a3ad633e3..88f6f0718e 100644
--- a/tests/session/append_sid_test.php
+++ b/tests/session/append_sid_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/session/continue_test.php b/tests/session/continue_test.php
index 6737562a0a..c4f7f8d75b 100644
--- a/tests/session/continue_test.php
+++ b/tests/session/continue_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/session/fixtures/sessions_empty.xml b/tests/session/fixtures/sessions_empty.xml
index f94337314e..0e6ddccd88 100644
--- a/tests/session/fixtures/sessions_empty.xml
+++ b/tests/session/fixtures/sessions_empty.xml
@@ -3,17 +3,33 @@
<table name="phpbb_users">
<column>user_id</column>
<column>username_clean</column>
+ <column>user_permissions</column>
+ <column>user_sig</column>
+ <column>user_occ</column>
+ <column>user_interests</column>
<row>
<value>1</value>
<value>anonymous</value>
+ <value></value>
+ <value></value>
+ <value></value>
+ <value></value>
</row>
<row>
<value>3</value>
<value>foo</value>
+ <value></value>
+ <value></value>
+ <value></value>
+ <value></value>
</row>
<row>
<value>4</value>
<value>bar</value>
+ <value></value>
+ <value></value>
+ <value></value>
+ <value></value>
</row>
</table>
<table name="phpbb_sessions">
diff --git a/tests/session/fixtures/sessions_full.xml b/tests/session/fixtures/sessions_full.xml
index bf6fc65997..509687f4d2 100644
--- a/tests/session/fixtures/sessions_full.xml
+++ b/tests/session/fixtures/sessions_full.xml
@@ -3,17 +3,33 @@
<table name="phpbb_users">
<column>user_id</column>
<column>username_clean</column>
+ <column>user_permissions</column>
+ <column>user_sig</column>
+ <column>user_occ</column>
+ <column>user_interests</column>
<row>
<value>1</value>
<value>anonymous</value>
+ <value></value>
+ <value></value>
+ <value></value>
+ <value></value>
</row>
<row>
<value>3</value>
<value>foo</value>
+ <value></value>
+ <value></value>
+ <value></value>
+ <value></value>
</row>
<row>
<value>4</value>
<value>bar</value>
+ <value></value>
+ <value></value>
+ <value></value>
+ <value></value>
</row>
</table>
<table name="phpbb_sessions">
diff --git a/tests/session/init_test.php b/tests/session/init_test.php
index 1181fab636..2ce6c4a4ac 100644
--- a/tests/session/init_test.php
+++ b/tests/session/init_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/session/testable_factory.php b/tests/session/testable_factory.php
index 3d4fbcc7cb..a042085908 100644
--- a/tests/session/testable_factory.php
+++ b/tests/session/testable_factory.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/template/includephp_test.php b/tests/template/includephp_test.php
index aac9cccc8a..28ea118a13 100644
--- a/tests/template/includephp_test.php
+++ b/tests/template/includephp_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/template/renderer_eval_test.php b/tests/template/renderer_eval_test.php
index c30516ba97..7ebb8b9bda 100644
--- a/tests/template/renderer_eval_test.php
+++ b/tests/template/renderer_eval_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/template/subdir/includephp_from_subdir_test.php b/tests/template/subdir/includephp_from_subdir_test.php
index 3cc632485d..517cb85a30 100644
--- a/tests/template/subdir/includephp_from_subdir_test.php
+++ b/tests/template/subdir/includephp_from_subdir_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/template/template_compile_test.php b/tests/template/template_compile_test.php
index 8c136c9985..a5e8a5e87a 100644
--- a/tests/template/template_compile_test.php
+++ b/tests/template/template_compile_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/template/template_inheritance_test.php b/tests/template/template_inheritance_test.php
index d62562ff0d..3a03de6427 100644
--- a/tests/template/template_inheritance_test.php
+++ b/tests/template/template_inheritance_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
@@ -69,7 +69,8 @@ class phpbb_template_template_inheritance_test extends phpbb_template_template_t
$this->template_path = dirname(__FILE__) . '/templates';
$this->parent_template_path = dirname(__FILE__) . '/parent_templates';
$this->template_locator = new phpbb_template_locator();
- $this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $this->template_locator);
+ $this->template_provider = new phpbb_template_path_provider();
+ $this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $this->template_locator, $this->template_provider);
$this->template->set_custom_template($this->template_path, 'tests', $this->parent_template_path);
}
}
diff --git a/tests/template/template_test.php b/tests/template/template_test.php
index 28eba05217..419c90bd2a 100644
--- a/tests/template/template_test.php
+++ b/tests/template/template_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2008 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
@@ -211,21 +211,21 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(),
array(),
array(),
- "{ VARIABLE }\n{ VARIABLE }",
+ "{ VARIABLE }\n{ 1_VARIABLE }\n{ VARIABLE }\n{ 1_VARIABLE }",
),
array(
'lang.html',
- array('L_VARIABLE' => "Value'"),
+ array('L_VARIABLE' => "Value'", 'L_1_VARIABLE' => "1 O'Clock"),
array(),
array(),
- "Value'\nValue\'",
+ "Value'\n1 O'Clock\nValue\'\n1 O\'Clock",
),
array(
'lang.html',
- array('LA_VARIABLE' => "Value'"),
+ array('LA_VARIABLE' => "Value'", 'LA_1_VARIABLE' => "1 O'Clock"),
array(),
array(),
- "{ VARIABLE }\nValue'",
+ "{ VARIABLE }\n{ 1_VARIABLE }\nValue'\n1 O'Clock",
),
array(
'loop_nested_multilevel_ref.html',
@@ -248,7 +248,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array('outer' => array(array()), 'outer.middle' => array(array()), 'outer.middle.inner' => array(array('VARIABLE' => 'z'), array('VARIABLE' => 'zz'))),
array(),
// I don't completely understand this output, hopefully it's correct
- "top-level content\nouter\n\ninner z\nfirst row\n\ninner zz",
+ "top-level content\nouter\nmiddle\ninner z\nfirst row of 2 in inner\n\ninner zz",
),
array(
'loop_size.html',
@@ -277,7 +277,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
$this->template->set_filenames(array('test' => $filename));
$this->assertFileNotExists($this->template_path . '/' . $filename, 'Testing missing file, file cannot exist');
- $expecting = sprintf('template locator: File %s does not exist', realpath($this->template_path . '/../') . '/templates/' . $filename);
+ $expecting = sprintf('template locator: File for handle test does not exist. Could not find: %s', realpath($this->template_path . '/../') . '/templates/' . $filename);
$this->setExpectedTriggerError(E_USER_ERROR, $expecting);
$this->display('test');
diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php
index 0e1f960f61..a78837516b 100644
--- a/tests/template/template_test_case.php
+++ b/tests/template/template_test_case.php
@@ -3,17 +3,19 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../mock/extension_manager.php';
class phpbb_template_template_test_case extends phpbb_test_case
{
protected $template;
protected $template_path;
protected $template_locator;
+ protected $template_provider;
// Keep the contents of the cache for debugging?
const PRESERVE_CACHE = true;
@@ -57,7 +59,8 @@ class phpbb_template_template_test_case extends phpbb_test_case
$this->template_path = dirname(__FILE__) . '/templates';
$this->template_locator = new phpbb_template_locator();
- $this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $this->template_locator);
+ $this->template_provider = new phpbb_template_path_provider();
+ $this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $this->template_locator, $this->template_provider);
$this->template->set_custom_template($this->template_path, 'tests');
}
diff --git a/tests/template/templates/lang.html b/tests/template/templates/lang.html
index 2b5ea1cafe..3eecc298cb 100644
--- a/tests/template/templates/lang.html
+++ b/tests/template/templates/lang.html
@@ -1,3 +1,5 @@
{L_VARIABLE}
+{L_1_VARIABLE}
{LA_VARIABLE}
+{LA_1_VARIABLE}
diff --git a/tests/template/templates/loop_nested_deep_multilevel_ref.html b/tests/template/templates/loop_nested_deep_multilevel_ref.html
index 60fad7b4cd..bcc2a7c07b 100644
--- a/tests/template/templates/loop_nested_deep_multilevel_ref.html
+++ b/tests/template/templates/loop_nested_deep_multilevel_ref.html
@@ -2,10 +2,11 @@ top-level content
<!-- BEGIN outer -->
outer
<!-- BEGIN middle -->
+ {outer.middle.S_BLOCK_NAME}
<!-- BEGIN inner -->
inner {inner.VARIABLE}
<!-- IF outer.middle.inner.S_FIRST_ROW -->
- first row
+ first row of {outer.middle.inner.S_NUM_ROWS} in {middle.inner.S_BLOCK_NAME}
<!-- ENDIF -->
<!-- END inner -->
<!-- END middle -->
diff --git a/tests/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php
index e1b368dcea..e742b543b0 100644
--- a/tests/test_framework/phpbb_database_test_case.php
+++ b/tests/test_framework/phpbb_database_test_case.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2008 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
@@ -40,46 +40,14 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
public function get_database_config()
{
- if (isset($_SERVER['PHPBB_TEST_DBMS']))
- {
- return array(
- 'dbms' => isset($_SERVER['PHPBB_TEST_DBMS']) ? $_SERVER['PHPBB_TEST_DBMS'] : '',
- 'dbhost' => isset($_SERVER['PHPBB_TEST_DBHOST']) ? $_SERVER['PHPBB_TEST_DBHOST'] : '',
- 'dbport' => isset($_SERVER['PHPBB_TEST_DBPORT']) ? $_SERVER['PHPBB_TEST_DBPORT'] : '',
- 'dbname' => isset($_SERVER['PHPBB_TEST_DBNAME']) ? $_SERVER['PHPBB_TEST_DBNAME'] : '',
- 'dbuser' => isset($_SERVER['PHPBB_TEST_DBUSER']) ? $_SERVER['PHPBB_TEST_DBUSER'] : '',
- 'dbpasswd' => isset($_SERVER['PHPBB_TEST_DBPASSWD']) ? $_SERVER['PHPBB_TEST_DBPASSWD'] : '',
- );
- }
- else if (file_exists(dirname(__FILE__) . '/../test_config.php'))
- {
- include(dirname(__FILE__) . '/../test_config.php');
-
- return array(
- 'dbms' => $dbms,
- 'dbhost' => $dbhost,
- 'dbport' => $dbport,
- 'dbname' => $dbname,
- 'dbuser' => $dbuser,
- 'dbpasswd' => $dbpasswd,
- );
- }
- else if (extension_loaded('sqlite') && version_compare(PHPUnit_Runner_Version::id(), '3.4.15', '>='))
- {
- // Silently use sqlite
- return array(
- 'dbms' => 'sqlite',
- 'dbhost' => dirname(__FILE__) . '/../phpbb_unit_tests.sqlite2', // filename
- 'dbport' => '',
- 'dbname' => '',
- 'dbuser' => '',
- 'dbpasswd' => '',
- );
- }
- else
+ $config = phpbb_test_case_helpers::get_test_config();
+
+ if (!isset($config['dbms']))
{
$this->markTestSkipped('Missing test_config.php: See first error.');
}
+
+ return $config;
}
public function getConnection()
diff --git a/tests/test_framework/phpbb_database_test_connection_manager.php b/tests/test_framework/phpbb_database_test_connection_manager.php
index a7559e2183..c734c90a1a 100644
--- a/tests/test_framework/phpbb_database_test_connection_manager.php
+++ b/tests/test_framework/phpbb_database_test_connection_manager.php
@@ -3,10 +3,12 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_install.php';
+
class phpbb_database_test_connection_manager
{
private $config;
@@ -69,6 +71,11 @@ class phpbb_database_test_connection_manager
default:
$dsn .= 'host=' . $this->config['dbhost'];
+ if ($this->config['dbport'])
+ {
+ $dsn .= ';port=' . $this->config['dbport'];
+ }
+
if ($use_db)
{
$dsn .= ';dbname=' . $this->config['dbname'];
@@ -234,7 +241,11 @@ class phpbb_database_test_connection_manager
}
$filename = $directory . $schema . '_schema.sql';
- $sql = $this->split_sql(file_get_contents($filename));
+
+ $queries = file_get_contents($filename);
+ $sql = remove_comments($queries);
+
+ $sql = split_sql_file($sql, $this->dbms['DELIM']);
foreach ($sql as $query)
{
@@ -243,43 +254,6 @@ class phpbb_database_test_connection_manager
}
/**
- * Split contents of an SQL file into an array of SQL statements
- *
- * Note: This method is not the same as split_sql_file from functions_install.
- *
- * @param string $sql Raw contents of an SQL file
- *
- * @return Array of runnable SQL statements
- */
- protected function split_sql($sql)
- {
- $sql = str_replace("\r" , '', $sql);
- $data = preg_split('/' . preg_quote($this->dbms['DELIM'], '/') . '$/m', $sql);
-
- $data = array_map('trim', $data);
-
- // The empty case
- $end_data = end($data);
-
- if (empty($end_data))
- {
- unset($data[key($data)]);
- }
-
- if ($this->config['dbms'] == 'sqlite')
- {
- // remove comment lines starting with # - they are not proper sqlite
- // syntax and break sqlite2
- foreach ($data as $i => $query)
- {
- $data[$i] = preg_replace('/^#.*$/m', "\n", $query);
- }
- }
-
- return $data;
- }
-
- /**
* Map a phpBB dbms driver name to dbms data array
*/
protected function get_dbms_data($dbms)
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
new file mode 100644
index 0000000000..b5e6f7e377
--- /dev/null
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -0,0 +1,164 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2011 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+require_once __DIR__ . '/../../phpBB/includes/functions_install.php';
+
+class phpbb_functional_test_case extends phpbb_test_case
+{
+ protected $client;
+ protected $root_url;
+
+ static protected $config = array();
+ static protected $already_installed = false;
+
+ static public function setUpBeforeClass()
+ {
+ if (!extension_loaded('phar'))
+ {
+ self::markTestSkipped('phar extension is not loaded');
+ }
+
+ require_once 'phar://' . __DIR__ . '/../../vendor/goutte.phar';
+ }
+
+ public function setUp()
+ {
+ if (!isset(self::$config['phpbb_functional_url']))
+ {
+ $this->markTestSkipped('phpbb_functional_url was not set in test_config and wasn\'t set as PHPBB_FUNCTIONAL_URL environment variable either.');
+ }
+
+ $this->client = new Goutte\Client();
+ $this->root_url = self::$config['phpbb_functional_url'];
+ }
+
+ public function request($method, $path)
+ {
+ return $this->client->request($method, $this->root_url . $path);
+ }
+
+ // bootstrap, called after board is set up
+ // once per test case class
+ // test cases can override this
+ protected function bootstrap()
+ {
+ }
+
+ public function __construct($name = NULL, array $data = array(), $dataName = '')
+ {
+ parent::__construct($name, $data, $dataName);
+
+ $this->backupStaticAttributesBlacklist += array(
+ 'phpbb_functional_test_case' => array('config', 'already_installed'),
+ );
+
+ if (!static::$already_installed)
+ {
+ $this->install_board();
+ $this->bootstrap();
+ static::$already_installed = true;
+ }
+ }
+
+ protected function install_board()
+ {
+ global $phpbb_root_path, $phpEx;
+
+ self::$config = phpbb_test_case_helpers::get_test_config();
+
+ if (!isset(self::$config['phpbb_functional_url']))
+ {
+ return;
+ }
+
+ self::$config['table_prefix'] = 'phpbb_';
+ $this->recreate_database(self::$config);
+
+ if (file_exists($phpbb_root_path . "config.$phpEx"))
+ {
+ if (!file_exists($phpbb_root_path . "config_dev.$phpEx"))
+ {
+ rename($phpbb_root_path . "config.$phpEx", $phpbb_root_path . "config_dev.$phpEx");
+ }
+ else
+ {
+ unlink($phpbb_root_path . "config.$phpEx");
+ }
+ }
+
+ // begin data
+ $data = array();
+
+ $data = array_merge($data, self::$config);
+
+ $data = array_merge($data, array(
+ 'default_lang' => 'en',
+ 'admin_name' => 'admin',
+ 'admin_pass1' => 'admin',
+ 'admin_pass2' => 'admin',
+ 'board_email' => 'nobody@example.com',
+ ));
+
+ $parseURL = parse_url(self::$config['phpbb_functional_url']);
+
+ $data = array_merge($data, array(
+ 'email_enable' => false,
+ 'smtp_delivery' => false,
+ 'smtp_host' => '',
+ 'smtp_auth' => '',
+ 'smtp_user' => '',
+ 'smtp_pass' => '',
+ 'cookie_secure' => false,
+ 'force_server_vars' => false,
+ 'server_protocol' => $parseURL['scheme'] . '://',
+ 'server_name' => 'localhost',
+ 'server_port' => isset($parseURL['port']) ? (int) $parseURL['port'] : 80,
+ 'script_path' => $parseURL['path'],
+ ));
+ // end data
+
+ $content = $this->do_request('install');
+ $this->assertContains('Welcome to Installation', $content);
+
+ $this->do_request('create_table', $data);
+
+ file_put_contents($phpbb_root_path . "config.$phpEx", phpbb_create_config_file_data($data, self::$config['dbms'], array(), true));
+
+ $this->do_request('config_file', $data);
+
+ copy($phpbb_root_path . "config.$phpEx", $phpbb_root_path . "config_test.$phpEx");
+
+ $this->do_request('final', $data);
+ }
+
+ private function do_request($sub, $post_data = null)
+ {
+ $context = null;
+
+ if ($post_data)
+ {
+ $context = stream_context_create(array(
+ 'http' => array(
+ 'method' => 'POST',
+ 'header' => 'Content-Type: application/x-www-form-urlencoded',
+ 'content' => http_build_query($post_data),
+ 'ignore_errors' => true,
+ ),
+ ));
+ }
+
+ return file_get_contents(self::$config['phpbb_functional_url'] . 'install/index.php?mode=install&sub=' . $sub, false, $context);
+ }
+
+ private function recreate_database($config)
+ {
+ $db_conn_mgr = new phpbb_database_test_connection_manager($config);
+ $db_conn_mgr->recreate_db();
+ }
+}
diff --git a/tests/test_framework/phpbb_test_case.php b/tests/test_framework/phpbb_test_case.php
index f189da3671..8b16f02638 100644
--- a/tests/test_framework/phpbb_test_case.php
+++ b/tests/test_framework/phpbb_test_case.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2008 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/test_framework/phpbb_test_case_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php
index 697dc93501..9c91778cb0 100644
--- a/tests/test_framework/phpbb_test_case_helpers.php
+++ b/tests/test_framework/phpbb_test_case_helpers.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2008 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
@@ -46,4 +46,61 @@ class phpbb_test_case_helpers
{
mkdir($path, 0777, true);
}
+
+ static public function get_test_config()
+ {
+ $config = array();
+
+ if (extension_loaded('sqlite') && version_compare(PHPUnit_Runner_Version::id(), '3.4.15', '>='))
+ {
+ $config = array_merge($config, array(
+ 'dbms' => 'sqlite',
+ 'dbhost' => dirname(__FILE__) . '/../phpbb_unit_tests.sqlite2', // filename
+ 'dbport' => '',
+ 'dbname' => '',
+ 'dbuser' => '',
+ 'dbpasswd' => '',
+ ));
+ }
+
+ if (file_exists(dirname(__FILE__) . '/../test_config.php'))
+ {
+ include(dirname(__FILE__) . '/../test_config.php');
+
+ $config = array_merge($config, array(
+ 'dbms' => $dbms,
+ 'dbhost' => $dbhost,
+ 'dbport' => $dbport,
+ 'dbname' => $dbname,
+ 'dbuser' => $dbuser,
+ 'dbpasswd' => $dbpasswd,
+ ));
+
+ if (isset($phpbb_functional_url))
+ {
+ $config['phpbb_functional_url'] = $phpbb_functional_url;
+ }
+ }
+
+ if (isset($_SERVER['PHPBB_TEST_DBMS']))
+ {
+ $config = array_merge($config, array(
+ 'dbms' => isset($_SERVER['PHPBB_TEST_DBMS']) ? $_SERVER['PHPBB_TEST_DBMS'] : '',
+ 'dbhost' => isset($_SERVER['PHPBB_TEST_DBHOST']) ? $_SERVER['PHPBB_TEST_DBHOST'] : '',
+ 'dbport' => isset($_SERVER['PHPBB_TEST_DBPORT']) ? $_SERVER['PHPBB_TEST_DBPORT'] : '',
+ 'dbname' => isset($_SERVER['PHPBB_TEST_DBNAME']) ? $_SERVER['PHPBB_TEST_DBNAME'] : '',
+ 'dbuser' => isset($_SERVER['PHPBB_TEST_DBUSER']) ? $_SERVER['PHPBB_TEST_DBUSER'] : '',
+ 'dbpasswd' => isset($_SERVER['PHPBB_TEST_DBPASSWD']) ? $_SERVER['PHPBB_TEST_DBPASSWD'] : ''
+ ));
+ }
+
+ if (isset($_SERVER['PHPBB_FUNCTIONAL_URL']))
+ {
+ $config = array_merge($config, array(
+ 'phpbb_functional_url' => isset($_SERVER['PHPBB_FUNCTIONAL_URL']) ? $_SERVER['PHPBB_FUNCTIONAL_URL'] : '',
+ ));
+ }
+
+ return $config;
+ }
}
diff --git a/tests/text_processing/censor_text_test.php b/tests/text_processing/censor_text_test.php
index 2843f0b20b..8fcdb7ef85 100644
--- a/tests/text_processing/censor_text_test.php
+++ b/tests/text_processing/censor_text_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/text_processing/make_clickable_test.php b/tests/text_processing/make_clickable_test.php
index 29b982d709..8697907311 100644
--- a/tests/text_processing/make_clickable_test.php
+++ b/tests/text_processing/make_clickable_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2008 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/user/lang_test.php b/tests/user/lang_test.php
index 6c60583a7b..f0ea76f342 100644
--- a/tests/user/lang_test.php
+++ b/tests/user/lang_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
@@ -26,6 +26,26 @@ class phpbb_user_lang_test extends phpbb_test_case
1 => '1 post', // 1
2 => '%d posts', // 2+
),
+ 'ARRY_NO_ZERO' => array(
+ 1 => '1 post', // 1
+ 2 => '%d posts', // 0, 2+
+ ),
+ 'ARRY_MISSING' => array(
+ 1 => '%d post', // 1
+ //Missing second plural
+ ),
+ 'ARRY_FLOAT' => array(
+ 1 => '1 post', // 1.x
+ 2 => '%1$.1f posts', // 0.x, 2+.x
+ ),
+ 'ARRY_EMPTY' => array(
+ ),
+ 'dateformat' => array(
+ 'AGO' => array(
+ 1 => '%d second',
+ 2 => '%d seconds',
+ ),
+ ),
);
// No param
@@ -51,8 +71,45 @@ class phpbb_user_lang_test extends phpbb_test_case
$this->assertEquals($user->lang('ARRY', 2), '2 posts');
$this->assertEquals($user->lang('ARRY', 123), '123 posts');
- // Bug PHPBB3-9949
+ // Empty array returns the language key
+ $this->assertEquals($user->lang('ARRY_EMPTY', 123), 'ARRY_EMPTY');
+
+ // No 0 key defined
+ $this->assertEquals($user->lang('ARRY_NO_ZERO', 0), '0 posts');
+ $this->assertEquals($user->lang('ARRY_NO_ZERO', 1), '1 post');
+ $this->assertEquals($user->lang('ARRY_NO_ZERO', 2), '2 posts');
+
+ // Array with missing keys
+ $this->assertEquals($user->lang('ARRY_MISSING', 2), '2 post');
+
+ // Floats as array key
+ $this->assertEquals($user->lang('ARRY_FLOAT', 1.3), '1 post');
+ $this->assertEquals($user->lang('ARRY_FLOAT', 2.0), '2.0 posts');
+ $this->assertEquals($user->lang('ARRY_FLOAT', 2.51), '2.5 posts');
+
+ // Use sub key, if first paramenter is an array
+ $this->assertEquals($user->lang(array('dateformat', 'AGO'), 2), '2 seconds');
+
+ // ticket PHPBB3-9949 - use first int to determinate the plural-form to use
$this->assertEquals($user->lang('ARRY', 1, 2), '1 post');
$this->assertEquals($user->lang('ARRY', 1, 's', 2), '1 post');
+
+ // ticket PHPBB3-10345 - different plural rules, not just 0/1/2+
+ $user = new user;
+ $user->lang = array(
+ 'PLURAL_RULE' => 13,
+ 'ARRY' => array(
+ 0 => '%d is 0', // 0
+ 1 => '%d is 1', // 1
+ 2 => '%d ends with 01-10', // ending with 01-10
+ 3 => '%d ends with 11-19', // ending with 11-19
+ 4 => '%d is part of the last rule', // everything else
+ ),
+ );
+ $this->assertEquals($user->lang('ARRY', 0), '0 is 0');
+ $this->assertEquals($user->lang('ARRY', 1), '1 is 1');
+ $this->assertEquals($user->lang('ARRY', 103), '103 ends with 01-10');
+ $this->assertEquals($user->lang('ARRY', 15), '15 ends with 11-19');
+ $this->assertEquals($user->lang('ARRY', 300), '300 is part of the last rule');
}
}
diff --git a/tests/utf/normalizer_test.php b/tests/utf/normalizer_test.php
index a0ba470416..92230cfcc9 100644
--- a/tests/utf/normalizer_test.php
+++ b/tests/utf/normalizer_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
@@ -102,7 +102,7 @@ class phpbb_utf_normalizer_test extends phpbb_test_case
foreach ($tests as $test)
{
$utf_result = $utf_expected;
- call_user_func(array('utf_normalizer', $form), &$utf_result);
+ call_user_func_array(array('utf_normalizer', $form), array(&$utf_result));
$hex_result = $this->utf_to_hexseq($utf_result);
$this->assertEquals($utf_expected, $utf_result, "$expected == $form($test) ($hex_expected != $hex_result)");
@@ -154,7 +154,7 @@ class phpbb_utf_normalizer_test extends phpbb_test_case
foreach (array('nfc', 'nfkc', 'nfd', 'nfkd') as $form)
{
$utf_result = $utf_expected;
- call_user_func(array('utf_normalizer', $form), &$utf_result);
+ call_user_func_array(array('utf_normalizer', $form), array(&$utf_result));
$hex_result = $this->utf_to_hexseq($utf_result);
$this->assertEquals($utf_expected, $utf_result, "$hex_expected == $form($hex_tested) ($hex_expected != $hex_result)");
diff --git a/tests/utf/utf8_clean_string_test.php b/tests/utf/utf8_clean_string_test.php
index e5a771eafa..70bd549d5b 100644
--- a/tests/utf/utf8_clean_string_test.php
+++ b/tests/utf/utf8_clean_string_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2008 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/utf/utf8_wordwrap_test.php b/tests/utf/utf8_wordwrap_test.php
index 03fa9dc38c..39fdf73308 100644
--- a/tests/utf/utf8_wordwrap_test.php
+++ b/tests/utf/utf8_wordwrap_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2008 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/wrapper/gmgetdate_test.php b/tests/wrapper/gmgetdate_test.php
index 0b4c3378a9..a838cfdba9 100644
--- a/tests/wrapper/gmgetdate_test.php
+++ b/tests/wrapper/gmgetdate_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/wrapper/mt_rand_test.php b/tests/wrapper/mt_rand_test.php
index c8bcb3d14c..eba0bf2faa 100644
--- a/tests/wrapper/mt_rand_test.php
+++ b/tests/wrapper/mt_rand_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
diff --git a/tests/wrapper/version_compare_test.php b/tests/wrapper/version_compare_test.php
index f718cfd16b..8b42eb4bee 100644
--- a/tests/wrapper/version_compare_test.php
+++ b/tests/wrapper/version_compare_test.php
@@ -3,7 +3,7 @@
*
* @package testing
* @copyright (c) 2011 phpBB Group
-* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/