aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/common.php2
-rw-r--r--phpBB/config/services.yml3
-rw-r--r--phpBB/docs/CREDITS.txt1
-rw-r--r--phpBB/download/file.php2
-rw-r--r--phpBB/includes/functions.php31
-rw-r--r--phpBB/language/en/install.php2
-rw-r--r--phpBB/phpbb/cron/task/core/prune_shadow_topics.php4
-rw-r--r--phpBB/phpbb/extension/metadata_manager.php4
-rw-r--r--phpBB/phpbb/profilefields/manager.php31
-rw-r--r--phpBB/phpbb/profilefields/type/type_bool.php18
-rw-r--r--phpBB/phpbb/profilefields/type/type_date.php13
-rw-r--r--phpBB/phpbb/profilefields/type/type_dropdown.php18
-rw-r--r--phpBB/phpbb/profilefields/type/type_int.php12
-rw-r--r--phpBB/phpbb/profilefields/type/type_interface.php9
-rw-r--r--phpBB/phpbb/profilefields/type/type_string_common.php13
-rw-r--r--phpBB/phpbb/template/twig/lexer.php2
-rw-r--r--phpBB/phpbb/viewonline_helper.php37
-rw-r--r--phpBB/viewonline.php7
-rw-r--r--tests/extension/ext/barfoo/composer.json8
-rw-r--r--tests/extension/ext/vendor/moo/composer.json8
-rw-r--r--tests/extension/ext/vendor2/bar/composer.json8
-rw-r--r--tests/extension/ext/vendor2/foo/composer.json8
-rw-r--r--tests/extension/metadata_manager_test.php324
-rw-r--r--tests/functional/fixtures/ext/foo/bar/composer.json8
-rw-r--r--tests/profilefields/type_bool_test.php56
-rw-r--r--tests/profilefields/type_date_test.php36
-rw-r--r--tests/profilefields/type_dropdown_test.php48
-rw-r--r--tests/profilefields/type_int_test.php60
-rw-r--r--tests/profilefields/type_string_test.php54
-rw-r--r--tests/profilefields/type_url_test.php30
-rw-r--r--tests/template/template_test.php7
-rw-r--r--tests/template/templates/if_nested_tags.html1
-rw-r--r--tests/viewonline/helper_test.php42
33 files changed, 648 insertions, 259 deletions
diff --git a/phpBB/common.php b/phpBB/common.php
index 4b06cd1eda..e96a34938a 100644
--- a/phpBB/common.php
+++ b/phpBB/common.php
@@ -95,6 +95,8 @@ $phpbb_class_loader->register();
$phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx);
$phpbb_class_loader_ext->register();
+phpbb_load_extensions_autoloaders($phpbb_root_path);
+
// Set up container
$phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx);
diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml
index 72eeae9b15..31f0b9ad95 100644
--- a/phpBB/config/services.yml
+++ b/phpBB/config/services.yml
@@ -354,3 +354,6 @@ services:
- @cache
- @config
- @user
+
+ viewonline_helper:
+ class: phpbb\viewonline_helper
diff --git a/phpBB/docs/CREDITS.txt b/phpBB/docs/CREDITS.txt
index a4ba4cb87c..edb6361b2a 100644
--- a/phpBB/docs/CREDITS.txt
+++ b/phpBB/docs/CREDITS.txt
@@ -28,6 +28,7 @@ phpBB Developers: bantu (Andreas Fischer)
imkingdavid (David King)
marc1706 (Marc Alexander)
nickvergessen (Joas Schilling)
+ nicofuma (Tristan Darricau)
prototech (Cesar Gallegos)
For a list of phpBB Team members, please see:
diff --git a/phpBB/download/file.php b/phpBB/download/file.php
index ce2855473b..f7636b0e1a 100644
--- a/phpBB/download/file.php
+++ b/phpBB/download/file.php
@@ -59,6 +59,8 @@ if (isset($_GET['avatar']))
$phpbb_class_loader_ext = new \phpbb\class_loader('\\', "{$phpbb_root_path}ext/", $phpEx);
$phpbb_class_loader_ext->register();
+ phpbb_load_extensions_autoloaders($phpbb_root_path);
+
// Set up container
$phpbb_container = phpbb_create_default_container($phpbb_root_path, $phpEx);
diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php
index 32acb0c9ff..0838f2008e 100644
--- a/phpBB/includes/functions.php
+++ b/phpBB/includes/functions.php
@@ -21,6 +21,37 @@ if (!defined('IN_PHPBB'))
// Common global functions
/**
+* Load the autoloaders added by the extensions.
+*
+* @param string $phpbb_root_path Path to the phpbb root directory.
+*/
+function phpbb_load_extensions_autoloaders($phpbb_root_path)
+{
+ $iterator = new \RecursiveIteratorIterator(
+ new \phpbb\recursive_dot_prefix_filter_iterator(
+ new \RecursiveDirectoryIterator(
+ $phpbb_root_path . 'ext/',
+ \FilesystemIterator::SKIP_DOTS
+ )
+ ),
+ \RecursiveIteratorIterator::SELF_FIRST
+ );
+ $iterator->setMaxDepth(2);
+
+ foreach ($iterator as $file_info)
+ {
+ if ($file_info->getFilename() === 'vendor' && $iterator->getDepth() === 2)
+ {
+ $filename = $file_info->getRealPath() . '/autoload.php';
+ if (file_exists($filename))
+ {
+ require $filename;
+ }
+ }
+ }
+}
+
+/**
* Casts a variable to the given type.
*
* @deprecated
diff --git a/phpBB/language/en/install.php b/phpBB/language/en/install.php
index 39e4a42611..65448e3299 100644
--- a/phpBB/language/en/install.php
+++ b/phpBB/language/en/install.php
@@ -345,7 +345,7 @@ $lang = array_merge($lang, array(
'SUB_LICENSE' => 'License',
'SUB_SUPPORT' => 'Support',
'SUCCESSFUL_CONNECT' => 'Successful connection',
- 'SUPPORT_BODY' => 'Full support will be provided for the current stable release of phpBB3, free of charge. This includes:</p><ul><li>installation</li><li>configuration</li><li>technical questions</li><li>problems relating to potential bugs in the software</li><li>updating from Release Candidate (RC) versions to the latest stable version</li><li>converting from phpBB 2.0.x to phpBB3</li><li>converting from other discussion board software to phpBB3 (please see the <a href="https://www.phpbb.com/community/viewforum.php?f=65">Convertors Forum</a>)</li></ul><p>We encourage users still running beta versions of phpBB3 to replace their installation with a fresh copy of the latest version.</p><h2>MODs / Styles</h2><p>For issues relating to MODs, please post in the appropriate <a href="https://www.phpbb.com/community/viewforum.php?f=81">Modifications Forum</a>.<br />For issues relating to styles, templates and themes, please post in the appropriate <a href="https://www.phpbb.com/community/viewforum.php?f=80">Styles Forum</a>.<br /><br />If your question relates to a specific package, please post directly in the topic dedicated to the package.</p><h2>Obtaining Support</h2><p><a href="https://www.phpbb.com/community/viewtopic.php?f=14&amp;t=571070">The phpBB Welcome Package</a><br /><a href="https://www.phpbb.com/support/">Support Section</a><br /><a href="https://www.phpbb.com/support/documentation/3.0/quickstart/">Quick Start Guide</a><br /><br />To ensure you stay up to date with the latest news and releases, why not <a href="https://www.phpbb.com/support/">subscribe to our mailing list</a>?<br /><br />',
+ 'SUPPORT_BODY' => 'Full support will be provided for the current stable release of phpBB3, free of charge. This includes:</p><ul><li>installation</li><li>configuration</li><li>technical questions</li><li>problems relating to potential bugs in the software</li><li>updating from Release Candidate (RC) versions to the latest stable version</li><li>converting from phpBB 2.0.x to phpBB3</li><li>converting from other discussion board software to phpBB3 (please see the <a href="https://www.phpbb.com/community/viewforum.php?f=486">Convertors Forum</a>)</li></ul><p>We encourage users still running beta versions of phpBB3 to replace their installation with a fresh copy of the latest version.</p><h2>Extensions / Styles</h2><p>For issues relating to Extensions, please post in the appropriate <a href="https://www.phpbb.com/community/viewforum.php?f=451">Extensions Forum</a>.<br />For issues relating to styles, templates and themes, please post in the appropriate <a href="https://www.phpbb.com/community/viewforum.php?f=471">Styles Forum</a>.<br /><br />If your question relates to a specific package, please post directly in the topic dedicated to the package.</p><h2>Obtaining Support</h2><p><a href="https://www.phpbb.com/community/viewtopic.php?f=14&amp;t=571070">The phpBB Welcome Package</a><br /><a href="https://www.phpbb.com/support/">Support Section</a><br /><a href="https://www.phpbb.com/support/documentation/3.1/quickstart/">Quick Start Guide</a><br /><br />To ensure you stay up to date with the latest news and releases, why not <a href="https://www.phpbb.com/support/">subscribe to our mailing list</a>?<br /><br />',
'SYNC_FORUMS' => 'Starting to synchronise forums',
'SYNC_POST_COUNT' => 'Synchronising post_counts',
'SYNC_POST_COUNT_ID' => 'Synchronising post_counts from <var>entry</var> %1$s to %2$s.',
diff --git a/phpBB/phpbb/cron/task/core/prune_shadow_topics.php b/phpBB/phpbb/cron/task/core/prune_shadow_topics.php
index 381483c798..83a2460454 100644
--- a/phpBB/phpbb/cron/task/core/prune_shadow_topics.php
+++ b/phpBB/phpbb/cron/task/core/prune_shadow_topics.php
@@ -45,11 +45,11 @@ class prune_shadow_topics extends \phpbb\cron\task\base implements \phpbb\cron\t
* @param string $phpbb_root_path The root path
* @param string $php_ext The PHP extension
* @param \phpbb\config\config $config The config
- * @param \phpbb\db\driver\driver $db The db connection
+ * @param \phpbb\db\driver\driver_interface $db The db connection
* @param \phpbb\log\log $log The phpBB log system
* @param \phpbb\user $user The phpBB user object
*/
- public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config, \phpbb\db\driver\driver $db, \phpbb\log\log $log, \phpbb\user $user)
+ public function __construct($phpbb_root_path, $php_ext, \phpbb\config\config $config, \phpbb\db\driver\driver_interface $db, \phpbb\log\log $log, \phpbb\user $user)
{
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
diff --git a/phpBB/phpbb/extension/metadata_manager.php b/phpBB/phpbb/extension/metadata_manager.php
index 014d8c79c7..1051021ea7 100644
--- a/phpBB/phpbb/extension/metadata_manager.php
+++ b/phpBB/phpbb/extension/metadata_manager.php
@@ -306,7 +306,7 @@ class metadata_manager
*/
public function validate_require_phpbb()
{
- if (!isset($this->metadata['require']['phpbb/phpbb']))
+ if (!isset($this->metadata['extra']['soft-require']['phpbb/phpbb']))
{
return false;
}
@@ -369,7 +369,7 @@ class metadata_manager
'META_REQUIRE_PHP' => (isset($this->metadata['require']['php'])) ? htmlspecialchars($this->metadata['require']['php']) : '',
'META_REQUIRE_PHP_FAIL' => !$this->validate_require_php(),
- 'META_REQUIRE_PHPBB' => (isset($this->metadata['require']['phpbb/phpbb'])) ? htmlspecialchars($this->metadata['require']['phpbb/phpbb']) : '',
+ 'META_REQUIRE_PHPBB' => (isset($this->metadata['extra']['soft-require']['phpbb/phpbb'])) ? htmlspecialchars($this->metadata['extra']['soft-require']['phpbb/phpbb']) : '',
'META_REQUIRE_PHPBB_FAIL' => !$this->validate_require_phpbb(),
'META_DISPLAY_NAME' => (isset($this->metadata['extra']['display-name'])) ? htmlspecialchars($this->metadata['extra']['display-name']) : '',
diff --git a/phpBB/phpbb/profilefields/manager.php b/phpBB/phpbb/profilefields/manager.php
index 490db0419a..26c11d9e22 100644
--- a/phpBB/phpbb/profilefields/manager.php
+++ b/phpBB/phpbb/profilefields/manager.php
@@ -389,6 +389,7 @@ class manager
{
$profile_field = $this->type_collection[$ident_ary['data']['field_type']];
$value = $profile_field->get_profile_value($ident_ary['value'], $ident_ary['data']);
+ $value_raw = $profile_field->get_profile_value_raw($ident_ary['value'], $ident_ary['data']);
if ($value === null)
{
@@ -412,26 +413,28 @@ class manager
}
$tpl_fields['row'] += array(
- 'PROFILE_' . strtoupper($ident) . '_IDENT' => $ident,
- 'PROFILE_' . strtoupper($ident) . '_VALUE' => $value,
- 'PROFILE_' . strtoupper($ident) . '_CONTACT'=> $contact_url,
- 'PROFILE_' . strtoupper($ident) . '_DESC' => $field_desc,
- 'PROFILE_' . strtoupper($ident) . '_TYPE' => $ident_ary['data']['field_type'],
- 'PROFILE_' . strtoupper($ident) . '_NAME' => $this->user->lang($ident_ary['data']['lang_name']),
- 'PROFILE_' . strtoupper($ident) . '_EXPLAIN'=> $this->user->lang($ident_ary['data']['lang_explain']),
+ 'PROFILE_' . strtoupper($ident) . '_IDENT' => $ident,
+ 'PROFILE_' . strtoupper($ident) . '_VALUE' => $value,
+ 'PROFILE_' . strtoupper($ident) . '_VALUE_RAW' => $value_raw,
+ 'PROFILE_' . strtoupper($ident) . '_CONTACT' => $contact_url,
+ 'PROFILE_' . strtoupper($ident) . '_DESC' => $field_desc,
+ 'PROFILE_' . strtoupper($ident) . '_TYPE' => $ident_ary['data']['field_type'],
+ 'PROFILE_' . strtoupper($ident) . '_NAME' => $this->user->lang($ident_ary['data']['lang_name']),
+ 'PROFILE_' . strtoupper($ident) . '_EXPLAIN' => $this->user->lang($ident_ary['data']['lang_explain']),
'S_PROFILE_' . strtoupper($ident) . '_CONTACT' => $ident_ary['data']['field_is_contact'],
'S_PROFILE_' . strtoupper($ident) => true,
);
$tpl_fields['blockrow'][] = array(
- 'PROFILE_FIELD_IDENT' => $ident,
- 'PROFILE_FIELD_VALUE' => $value,
- 'PROFILE_FIELD_CONTACT' => $contact_url,
- 'PROFILE_FIELD_DESC' => $field_desc,
- 'PROFILE_FIELD_TYPE' => $ident_ary['data']['field_type'],
- 'PROFILE_FIELD_NAME' => $this->user->lang($ident_ary['data']['lang_name']),
- 'PROFILE_FIELD_EXPLAIN' => $this->user->lang($ident_ary['data']['lang_explain']),
+ 'PROFILE_FIELD_IDENT' => $ident,
+ 'PROFILE_FIELD_VALUE' => $value,
+ 'PROFILE_FIELD_VALUE_RAW' => $value_raw,
+ 'PROFILE_FIELD_CONTACT' => $contact_url,
+ 'PROFILE_FIELD_DESC' => $field_desc,
+ 'PROFILE_FIELD_TYPE' => $ident_ary['data']['field_type'],
+ 'PROFILE_FIELD_NAME' => $this->user->lang($ident_ary['data']['lang_name']),
+ 'PROFILE_FIELD_EXPLAIN' => $this->user->lang($ident_ary['data']['lang_explain']),
'S_PROFILE_CONTACT' => $ident_ary['data']['field_is_contact'],
'S_PROFILE_' . strtoupper($ident) => true,
diff --git a/phpBB/phpbb/profilefields/type/type_bool.php b/phpBB/phpbb/profilefields/type/type_bool.php
index f67e58ee3a..0582722833 100644
--- a/phpBB/phpbb/profilefields/type/type_bool.php
+++ b/phpBB/phpbb/profilefields/type/type_bool.php
@@ -180,6 +180,24 @@ class type_bool extends type_base
/**
* {@inheritDoc}
*/
+ public function get_profile_value_raw($field_value, $field_data)
+ {
+ if ($field_value == $field_data['field_novalue'] && !$field_data['field_show_novalue'])
+ {
+ return null;
+ }
+
+ if (!$field_value && $field_data['field_show_novalue'])
+ {
+ $field_value = $field_data['field_novalue'];
+ }
+
+ return $field_value;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public function generate_field($profile_row, $preview_options = false)
{
$profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];
diff --git a/phpBB/phpbb/profilefields/type/type_date.php b/phpBB/phpbb/profilefields/type/type_date.php
index 158eec6a0c..90ac9a6703 100644
--- a/phpBB/phpbb/profilefields/type/type_date.php
+++ b/phpBB/phpbb/profilefields/type/type_date.php
@@ -208,6 +208,19 @@ class type_date extends type_base
/**
* {@inheritDoc}
*/
+ public function get_profile_value_raw($field_value, $field_data)
+ {
+ if (($field_value === '' || $field_value === null) && !$field_data['field_show_novalue'])
+ {
+ return null;
+ }
+
+ return $field_value;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public function generate_field($profile_row, $preview_options = false)
{
$profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];
diff --git a/phpBB/phpbb/profilefields/type/type_dropdown.php b/phpBB/phpbb/profilefields/type/type_dropdown.php
index 118ddf1f37..17ae89e1b2 100644
--- a/phpBB/phpbb/profilefields/type/type_dropdown.php
+++ b/phpBB/phpbb/profilefields/type/type_dropdown.php
@@ -189,6 +189,24 @@ class type_dropdown extends type_base
/**
* {@inheritDoc}
*/
+ public function get_profile_value_raw($field_value, $field_data)
+ {
+ if ($field_value == $field_data['field_novalue'] && !$field_data['field_show_novalue'])
+ {
+ return null;
+ }
+
+ if (!$field_value && $field_data['field_show_novalue'])
+ {
+ $field_value = $field_data['field_novalue'];
+ }
+
+ return $field_value;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public function generate_field($profile_row, $preview_options = false)
{
$profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];
diff --git a/phpBB/phpbb/profilefields/type/type_int.php b/phpBB/phpbb/profilefields/type/type_int.php
index 78f1c7d2c9..dd08df94c1 100644
--- a/phpBB/phpbb/profilefields/type/type_int.php
+++ b/phpBB/phpbb/profilefields/type/type_int.php
@@ -154,6 +154,18 @@ class type_int extends type_base
/**
* {@inheritDoc}
*/
+ public function get_profile_value_raw($field_value, $field_data)
+ {
+ if (($field_value === '' || $field_value === null) && !$field_data['field_show_novalue'])
+ {
+ return null;
+ }
+ return (int) $field_value;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public function generate_field($profile_row, $preview_options = false)
{
$profile_row['field_ident'] = (isset($profile_row['var_name'])) ? $profile_row['var_name'] : 'pf_' . $profile_row['field_ident'];
diff --git a/phpBB/phpbb/profilefields/type/type_interface.php b/phpBB/phpbb/profilefields/type/type_interface.php
index 489e916fd5..2dd13fa480 100644
--- a/phpBB/phpbb/profilefields/type/type_interface.php
+++ b/phpBB/phpbb/profilefields/type/type_interface.php
@@ -94,6 +94,15 @@ interface type_interface
public function get_profile_value($field_value, $field_data);
/**
+ * Get Profile Value ID for display (the raw, unprocessed user data)
+ *
+ * @param mixed $field_value Field value as stored in the database
+ * @param array $field_data Array with requirements of the field
+ * @return mixed Field value ID to display
+ */
+ public function get_profile_value_raw($field_value, $field_data);
+
+ /**
* Get Profile Value for display
*
* When displaying a contact field, we don't want to have links already parsed and more
diff --git a/phpBB/phpbb/profilefields/type/type_string_common.php b/phpBB/phpbb/profilefields/type/type_string_common.php
index b48e3c5add..c2b951b6c9 100644
--- a/phpBB/phpbb/profilefields/type/type_string_common.php
+++ b/phpBB/phpbb/profilefields/type/type_string_common.php
@@ -112,6 +112,19 @@ abstract class type_string_common extends type_base
/**
* {@inheritDoc}
*/
+ public function get_profile_value_raw($field_value, $field_data)
+ {
+ if (!$field_value && !$field_data['field_show_novalue'])
+ {
+ return null;
+ }
+
+ return $field_value;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public function get_profile_contact_value($field_value, $field_data)
{
if (!$field_value && !$field_data['field_show_novalue'])
diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php
index cceefda7ef..c5dc7273ba 100644
--- a/phpBB/phpbb/template/twig/lexer.php
+++ b/phpBB/phpbb/template/twig/lexer.php
@@ -285,7 +285,7 @@ class lexer extends \Twig_Lexer
return "<!-- {$matches[1]}IF{$inner}-->";
};
- return preg_replace_callback('#<!-- (ELSE)?IF((.*?) \(*!?[\$|\.]([^\s]+)(.*?))-->#', $callback, $code);
+ return preg_replace_callback('#<!-- (ELSE)?IF((.*?) (?:\(*!?[\$|\.]([^\s]+)(.*?))?)-->#', $callback, $code);
}
/**
diff --git a/phpBB/phpbb/viewonline_helper.php b/phpBB/phpbb/viewonline_helper.php
new file mode 100644
index 0000000000..3fc33119a3
--- /dev/null
+++ b/phpBB/phpbb/viewonline_helper.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.
+*
+*/
+
+namespace phpbb;
+
+/**
+* Class to handle viewonline related tasks
+*/
+class viewonline_helper
+{
+ /**
+ * Get user page
+ *
+ * @param string $session_page User's session page
+ * @return array Match array filled by preg_match()
+ */
+ public function get_user_page($session_page)
+ {
+ preg_match('#^([./\\]*+[a-z0-9/_-]+)#i', $session_page, $on_page);
+ if (empty($on_page))
+ {
+ $on_page[1] = '';
+ }
+
+ return $on_page;
+ }
+}
diff --git a/phpBB/viewonline.php b/phpBB/viewonline.php
index 43b5f7f001..82f990c2a2 100644
--- a/phpBB/viewonline.php
+++ b/phpBB/viewonline.php
@@ -44,6 +44,7 @@ if (!$auth->acl_gets('u_viewprofile', 'a_user', 'a_useradd', 'a_userdel'))
}
$pagination = $phpbb_container->get('pagination');
+$viewonline_helper = $phpbb_container->get('viewonline_helper');
$sort_key_text = array('a' => $user->lang['SORT_USERNAME'], 'b' => $user->lang['SORT_JOINED'], 'c' => $user->lang['SORT_LOCATION']);
$sort_key_sql = array('a' => 'u.username_clean', 'b' => 's.session_time', 'c' => 's.session_page');
@@ -213,11 +214,7 @@ while ($row = $db->sql_fetchrow($result))
continue;
}
- preg_match('#^([a-z0-9/_-]+)#i', $row['session_page'], $on_page);
- if (!sizeof($on_page))
- {
- $on_page[1] = '';
- }
+ $on_page = $viewonline_helper->get_user_page($row['session_page']);
switch ($on_page[1])
{
diff --git a/tests/extension/ext/barfoo/composer.json b/tests/extension/ext/barfoo/composer.json
index d88fd413c9..05bb099707 100644
--- a/tests/extension/ext/barfoo/composer.json
+++ b/tests/extension/ext/barfoo/composer.json
@@ -13,10 +13,12 @@
"role": "N/A"
}],
"require": {
- "php": ">=5.3",
- "phpbb/phpbb": "3.1.*@dev"
+ "php": ">=5.3"
},
"extra": {
- "display-name": "phpBB BarFoo Extension"
+ "display-name": "phpBB BarFoo Extension",
+ "soft-require": {
+ "phpbb/phpbb": "3.1.*@dev"
+ }
}
}
diff --git a/tests/extension/ext/vendor/moo/composer.json b/tests/extension/ext/vendor/moo/composer.json
index b8fc544c01..d49aab47cd 100644
--- a/tests/extension/ext/vendor/moo/composer.json
+++ b/tests/extension/ext/vendor/moo/composer.json
@@ -13,10 +13,12 @@
"role": "N/A"
}],
"require": {
- "php": ">=5.3",
- "phpbb/phpbb": "3.1.*@dev"
+ "php": ">=5.3"
},
"extra": {
- "display-name": "phpBB Moo Extension"
+ "display-name": "phpBB Moo Extension",
+ "soft-require": {
+ "phpbb/phpbb": "3.1.*@dev"
+ }
}
}
diff --git a/tests/extension/ext/vendor2/bar/composer.json b/tests/extension/ext/vendor2/bar/composer.json
index 215e7d59db..9d2ed86a0c 100644
--- a/tests/extension/ext/vendor2/bar/composer.json
+++ b/tests/extension/ext/vendor2/bar/composer.json
@@ -12,10 +12,12 @@
"role": "N/A"
}],
"require": {
- "php": ">=5.3",
- "phpbb/phpbb": "3.1.*@dev"
+ "php": ">=5.3"
},
"extra": {
- "display-name": "phpBB Bar Extension"
+ "display-name": "phpBB Bar Extension",
+ "soft-require": {
+ "phpbb/phpbb": "3.1.*@dev"
+ }
}
}
diff --git a/tests/extension/ext/vendor2/foo/composer.json b/tests/extension/ext/vendor2/foo/composer.json
index 7b2a80f5d3..efcdfc338f 100644
--- a/tests/extension/ext/vendor2/foo/composer.json
+++ b/tests/extension/ext/vendor2/foo/composer.json
@@ -12,10 +12,12 @@
"role": "N/A"
}],
"require": {
- "php": ">=5.3",
- "phpbb/phpbb": "3.1.*@dev"
+ "php": ">=5.3"
},
"extra": {
- "display-name": "phpBB Foo Extension"
+ "display-name": "phpBB Foo Extension",
+ "soft-require": {
+ "phpbb/phpbb": "3.1.*@dev"
+ }
}
}
diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php
index 3678ac0a3f..6b6ea80d82 100644
--- a/tests/extension/metadata_manager_test.php
+++ b/tests/extension/metadata_manager_test.php
@@ -19,8 +19,11 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
protected $cache;
protected $config;
protected $db;
+ protected $db_tools;
+ protected $table_prefix;
protected $phpbb_root_path;
protected $phpEx;
+ protected $migrator;
protected $template;
protected $user;
@@ -70,7 +73,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
new \phpbb\db\migration\helper()
);
$container = new phpbb_mock_container_builder();
- $container->set('migrator', $migrator);
+ $container->set('migrator', $this->migrator);
$this->extension_manager = new \phpbb\extension\manager(
$container,
@@ -96,9 +99,10 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
{
$manager->get_metadata();
}
- catch(\phpbb\extension\exception $e){}
-
- $this->assertEquals((string) $e, $this->user->lang('FILE_NOT_FOUND', $this->phpbb_root_path . $this->extension_manager->get_extension_path($ext_name) . 'composer.json'));
+ catch (\phpbb\extension\exception $e)
+ {
+ $this->assertEquals((string) $e, $this->user->lang('FILE_NOT_FOUND', $this->phpbb_root_path . $this->extension_manager->get_extension_path($ext_name) . 'composer.json'));
+ }
}
// Should be the same as a direct json_decode of the composer.json file
@@ -112,7 +116,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
{
$metadata = $manager->get_metadata();
}
- catch(\phpbb\extension\exception $e)
+ catch (\phpbb\extension\exception $e)
{
$this->fail($e);
}
@@ -122,64 +126,42 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$this->assertEquals($metadata, $json);
}
- public function test_validator_non_existant()
+ public function validator_non_existing_data()
{
- $ext_name = 'validator';
-
- $manager = $this->get_metadata_manager($ext_name);
-
- // Non-existant data
- try
- {
- $manager->validate('name');
-
- $this->fail('Exception not triggered');
- }
- catch(\phpbb\extension\exception $e)
- {
- $this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', 'name'));
- }
-
- try
- {
- $manager->validate('type');
-
- $this->fail('Exception not triggered');
- }
- catch(\phpbb\extension\exception $e)
- {
- $this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', 'type'));
- }
-
- try
- {
- $manager->validate('license');
-
- $this->fail('Exception not triggered');
- }
- catch(\phpbb\extension\exception $e)
- {
- $this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', 'license'));
- }
+ return array(
+ array('name'),
+ array('type'),
+ array('license'),
+ array('version'),
+ );
+ }
+ /**
+ * @dataProvider validator_non_existing_data
+ */
+ public function test_validator_non_existing($field_name)
+ {
+ $manager = $this->get_metadata_manager('validator');
try
{
- $manager->validate('version');
-
+ $manager->validate($field_name);
$this->fail('Exception not triggered');
}
catch(\phpbb\extension\exception $e)
{
- $this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', 'version'));
+ $this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', $field_name));
}
+ }
+ public function test_validator_non_existing_authors()
+ {
+ $manager = $this->get_metadata_manager('validator');
try
{
$manager->validate_authors();
-
$this->fail('Exception not triggered');
}
- catch(\phpbb\extension\exception $e)
+ catch (\phpbb\extension\exception $e)
{
$this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', 'authors'));
}
@@ -193,72 +175,44 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
try
{
$manager->validate_authors();
-
$this->fail('Exception not triggered');
}
- catch(\phpbb\extension\exception $e)
+ catch (\phpbb\extension\exception $e)
{
$this->assertEquals((string) $e, $this->user->lang('META_FIELD_NOT_SET', 'author name'));
}
}
-
- public function test_validator_invalid()
+ public function validator_invalid_data()
{
- $ext_name = 'validator';
+ return array(
+ array('name', 'asdf'),
+ array('type', 'asdf'),
+ array('license', ''),
+ array('version', ''),
+ );
+ }
- $manager = $this->get_metadata_manager($ext_name);
+ /**
+ * @dataProvider validator_invalid_data
+ */
+ public function test_validator_invalid($field_name, $field_value)
+ {
+ $manager = $this->get_metadata_manager('validator');
// Invalid data
$manager->set_metadata(array(
- 'name' => 'asdf',
- 'type' => 'asdf',
- 'license' => '',
- 'version' => '',
+ $field_name => $field_value,
));
try
{
- $manager->validate('name');
-
+ $manager->validate($field_name);
$this->fail('Exception not triggered');
}
catch(\phpbb\extension\exception $e)
{
- $this->assertEquals((string) $e, $this->user->lang('META_FIELD_INVALID', 'name'));
- }
-
- try
- {
- $manager->validate('type');
-
- $this->fail('Exception not triggered');
- }
- catch(\phpbb\extension\exception $e)
- {
- $this->assertEquals((string) $e, $this->user->lang('META_FIELD_INVALID', 'type'));
- }
-
- try
- {
- $manager->validate('license');
-
- $this->fail('Exception not triggered');
- }
- catch(\phpbb\extension\exception $e)
- {
- $this->assertEquals((string) $e, $this->user->lang('META_FIELD_INVALID', 'license'));
- }
-
- try
- {
- $manager->validate('version');
-
- $this->fail('Exception not triggered');
- }
- catch(\phpbb\extension\exception $e)
- {
- $this->assertEquals((string) $e, $this->user->lang('META_FIELD_INVALID', 'version'));
+ $this->assertEquals((string) $e, $this->user->lang('META_FIELD_INVALID', $field_name));
}
}
@@ -286,143 +240,83 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
}
}
-
- public function test_validator_requirements()
+ public function validator_requirements_data()
{
- $ext_name = 'validator';
-
- $manager = $this->get_metadata_manager($ext_name);
- // Too high of requirements
- $manager->merge_metadata(array(
- 'require' => array(
- 'php' => '10.0.0',
- 'phpbb/phpbb' => '3.2.0', // config is set to 3.1.0
+ return array(
+ array(
+ '10.0.0',
+ '100.2.0',
+ false,
+ false,
+ 'Versions are not compared at the moment',
),
- ));
-
- try
- {
- //$this->assertEquals(false, $manager->validate_require_php());
- //$this->assertEquals(false, $manager->validate_require_phpbb());
- }
- catch(\phpbb\extension\exception $e)
- {
- $this->fail($e);
- }
-
-
- // Too high of requirements
- $manager->merge_metadata(array(
- 'require' => array(
- 'php' => '5.3.0',
- 'phpbb/phpbb' => '3.1.0-beta', // config is set to 3.1.0
+ array(
+ '5.3.0',
+ '3.1.0-beta',
+ true,
+ true,
),
- ));
-
- try
- {
- $this->assertEquals(true, $manager->validate_require_php());
- $this->assertEquals(true, $manager->validate_require_phpbb());
- }
- catch(\phpbb\extension\exception $e)
- {
- $this->fail($e);
- }
-
-
- // Too high of requirements
- $manager->merge_metadata(array(
- 'require' => array(
- 'php' => '>' . phpversion(),
- 'phpbb/phpbb' => '>3.1.0', // config is set to 3.1.0
+ array(
+ '>' . phpversion(),
+ '>3.1.0',
+ false,
+ false,
+ 'Versions are not compared at the moment',
),
- ));
-
- try
- {
- //$this->assertEquals(false, $manager->validate_require_php());
- //$this->assertEquals(false, $manager->validate_require_phpbb());
- }
- catch(\phpbb\extension\exception $e)
- {
- $this->fail($e);
- }
-
-
- // Too high of current install
- $manager->merge_metadata(array(
- 'require' => array(
- 'php' => '<' . phpversion(),
- 'phpbb/phpbb' => '<3.1.0', // config is set to 3.1.0
+ array(
+ '<' . phpversion(),
+ '<3.1.0',
+ false,
+ false,
+ 'Versions are not compared at the moment',
),
- ));
-
- try
- {
- //$this->assertEquals(false, $manager->validate_require_php());
- //$this->assertEquals(false, $manager->validate_require_phpbb());
- }
- catch(\phpbb\extension\exception $e)
- {
- $this->fail($e);
- }
-
-
- // Matching requirements
- $manager->merge_metadata(array(
- 'require' => array(
- 'php' => phpversion(),
- 'phpbb/phpbb' => '3.1.0', // config is set to 3.1.0
+ array(
+ phpversion(),
+ '3.1.0',
+ true,
+ true,
),
- ));
-
- try
- {
- $this->assertEquals(true, $manager->validate_require_php());
- $this->assertEquals(true, $manager->validate_require_phpbb());
- }
- catch(\phpbb\extension\exception $e)
- {
- $this->fail($e);
- }
-
-
- // Matching requirements
- $manager->merge_metadata(array(
- 'require' => array(
- 'php' => '>=' . phpversion(),
- 'phpbb/phpbb' => '>=3.1.0', // config is set to 3.1.0
+ array(
+ '>=' . phpversion(),
+ '>=3.1.0',
+ true,
+ true,
),
- ));
+ array(
+ '<=' . phpversion(),
+ '<=3.1.0',
+ true,
+ true,
+ ),
+ );
+ }
- try
- {
- $this->assertEquals(true, $manager->validate_require_php());
- $this->assertEquals(true, $manager->validate_require_phpbb());
- }
- catch(\phpbb\extension\exception $e)
+ /**
+ * @dataProvider validator_requirements_data
+ */
+ public function test_validator_requirements($php_version, $phpbb_version, $expected_php, $expected_phpbb, $incomplete_reason = '')
+ {
+ if ($incomplete_reason)
{
- $this->fail($e);
+ $this->markTestIncomplete($incomplete_reason);
}
-
- // Matching requirements
+ $ext_name = 'validator';
+ $manager = $this->get_metadata_manager($ext_name);
+ // Too high of requirements
$manager->merge_metadata(array(
'require' => array(
- 'php' => '<=' . phpversion(),
- 'phpbb/phpbb' => '<=3.1.0', // config is set to 3.1.0
+ 'php' => $php_version,
+ ),
+ 'extra' => array(
+ 'soft-require' => array(
+ 'phpbb/phpbb' => $phpbb_version, // config is set to 3.1.0
+ ),
),
));
- try
- {
- $this->assertEquals(true, $manager->validate_require_php());
- $this->assertEquals(true, $manager->validate_require_phpbb());
- }
- catch(\phpbb\extension\exception $e)
- {
- $this->fail($e);
- }
+ $this->assertEquals($expected_php, $manager->validate_require_php());
+ $this->assertEquals($expected_phpbb, $manager->validate_require_phpbb());
}
/**
diff --git a/tests/functional/fixtures/ext/foo/bar/composer.json b/tests/functional/fixtures/ext/foo/bar/composer.json
index 2f91426d2a..f0c7f0e6c1 100644
--- a/tests/functional/fixtures/ext/foo/bar/composer.json
+++ b/tests/functional/fixtures/ext/foo/bar/composer.json
@@ -13,10 +13,12 @@
"role": "Developer"
}],
"require": {
- "php": ">=5.3",
- "phpbb/phpbb": "3.1.*@dev"
+ "php": ">=5.3"
},
"extra": {
- "display-name": "phpBB 3.1 Extension Testing"
+ "display-name": "phpBB 3.1 Extension Testing",
+ "soft-require": {
+ "phpbb/phpbb": "3.1.*@dev"
+ }
}
}
diff --git a/tests/profilefields/type_bool_test.php b/tests/profilefields/type_bool_test.php
index 29c118d57d..bdab179c8c 100644
--- a/tests/profilefields/type_bool_test.php
+++ b/tests/profilefields/type_bool_test.php
@@ -74,10 +74,10 @@ class phpbb_profilefield_type_bool_test extends phpbb_test_case
{
return array(
array(
- false,
- array('field_required' => true),
- 'FIELD_REQUIRED-field',
- 'Field should not accept empty values for required fields',
+ false,
+ array('field_required' => true),
+ 'FIELD_REQUIRED-field',
+ 'Field should not accept empty values for required fields',
),
);
}
@@ -130,6 +130,54 @@ class phpbb_profilefield_type_bool_test extends phpbb_test_case
$this->assertSame($expected, $result, $description);
}
+ public function profile_value_raw_data()
+ {
+ return array(
+ array(
+ '4',
+ array('field_show_novalue' => true),
+ '4',
+ 'Field should return the correct raw value',
+ ),
+ array(
+ '',
+ array('field_show_novalue' => false),
+ null,
+ 'Field should return correct raw value',
+ ),
+ array(
+ '',
+ array('field_show_novalue' => true),
+ null,
+ 'Field should return correct raw value',
+ ),
+ array(
+ null,
+ array('field_show_novalue' => false),
+ null,
+ 'Field should return correct raw value',
+ ),
+ array(
+ null,
+ array('field_show_novalue' => true),
+ null,
+ 'Field should return correct raw value',
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider profile_value_raw_data
+ */
+ public function test_get_profile_value_raw($value, $field_options, $expected, $description)
+ {
+ $field_options = array_merge($this->field_options, $field_options);
+
+ $result = $this->cp->get_profile_value_raw($value, $field_options);
+
+ $this->assertSame($expected, $result, $description);
+ }
+
public function is_set_callback($field_id, $lang_id, $field_value)
{
return isset($this->options[$field_value]);
diff --git a/tests/profilefields/type_date_test.php b/tests/profilefields/type_date_test.php
index 39fe95b97f..0ad2cde9fe 100644
--- a/tests/profilefields/type_date_test.php
+++ b/tests/profilefields/type_date_test.php
@@ -179,6 +179,42 @@ class phpbb_profilefield_type_date_test extends phpbb_test_case
$this->assertSame($expected, $result, $description);
}
+ public function profile_value_raw_data()
+ {
+ return array(
+ array(
+ '',
+ array('field_show_novalue' => false),
+ null,
+ 'Field should return the correct raw value',
+ ),
+ array(
+ '',
+ array('field_show_novalue' => true),
+ '',
+ 'Field should return correct raw value',
+ ),
+ array(
+ '12/06/2014',
+ array('field_show_novalue' => true),
+ '12/06/2014',
+ 'Field should return correct raw value',
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider profile_value_raw_data
+ */
+ public function test_get_profile_value_raw($value, $field_options, $expected, $description)
+ {
+ $field_options = array_merge($this->field_options, $field_options);
+
+ $result = $this->cp->get_profile_value_raw($value, $field_options);
+
+ $this->assertSame($expected, $result, $description);
+ }
+
public function return_callback_implode()
{
return implode('-', func_get_args());
diff --git a/tests/profilefields/type_dropdown_test.php b/tests/profilefields/type_dropdown_test.php
index 0e92afd504..ebecbf97f0 100644
--- a/tests/profilefields/type_dropdown_test.php
+++ b/tests/profilefields/type_dropdown_test.php
@@ -170,6 +170,54 @@ class phpbb_profilefield_type_dropdown_test extends phpbb_test_case
$this->assertSame($expected, $result, $description);
}
+ public function profile_value_raw_data()
+ {
+ return array(
+ array(
+ '4',
+ array('field_show_novalue' => true),
+ '4',
+ 'Field should return the correct raw value',
+ ),
+ array(
+ '',
+ array('field_show_novalue' => false),
+ null,
+ 'Field should null for empty value without show_novalue',
+ ),
+ array(
+ '',
+ array('field_show_novalue' => true),
+ 0,
+ 'Field should return 0 for empty value with show_novalue',
+ ),
+ array(
+ null,
+ array('field_show_novalue' => false),
+ null,
+ 'Field should return correct raw value',
+ ),
+ array(
+ null,
+ array('field_show_novalue' => true),
+ 0,
+ 'Field should return 0 for empty value with show_novalue',
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider profile_value_raw_data
+ */
+ public function test_get_profile_value_raw($value, $field_options, $expected, $description)
+ {
+ $field_options = array_merge($this->field_options, $field_options);
+
+ $result = $this->cp->get_profile_value_raw($value, $field_options);
+
+ $this->assertSame($expected, $result, $description);
+ }
+
public function is_set_callback($field_id, $lang_id, $field_value)
{
return isset($this->dropdown_options[$field_value]);
diff --git a/tests/profilefields/type_int_test.php b/tests/profilefields/type_int_test.php
index 611edd32b9..ac48c10a84 100644
--- a/tests/profilefields/type_int_test.php
+++ b/tests/profilefields/type_int_test.php
@@ -169,6 +169,66 @@ class phpbb_profilefield_type_int_test extends phpbb_test_case
$this->assertSame($expected, $result, $description);
}
+ public function profile_value_raw_data()
+ {
+ return array(
+ array(
+ '10',
+ array('field_show_novalue' => true),
+ 10,
+ 'Field should return the correct raw value',
+ ),
+ array(
+ '0',
+ array('field_show_novalue' => true),
+ 0,
+ 'Field should return correct raw value',
+ ),
+ array(
+ '',
+ array('field_show_novalue' => true),
+ 0,
+ 'Field should return correct raw value',
+ ),
+ array(
+ '10',
+ array('field_show_novalue' => false),
+ 10,
+ 'Field should return the correct raw value',
+ ),
+ array(
+ '0',
+ array('field_show_novalue' => false),
+ 0,
+ 'Field should return correct raw value',
+ ),
+ array(
+ '',
+ array('field_show_novalue' => false),
+ null,
+ 'Field should return correct raw value',
+ ),
+ array(
+ 'string',
+ array('field_show_novalue' => false),
+ 0,
+ 'Field should return int cast of passed string'
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider profile_value_raw_data
+ */
+ public function test_get_profile_value_raw($value, $field_options, $expected, $description)
+ {
+ $field_options = array_merge($this->field_options, $field_options);
+
+ $result = $this->cp->get_profile_value_raw($value, $field_options);
+
+ $this->assertSame($expected, $result, $description);
+ }
+
public function return_callback_implode()
{
return implode('-', func_get_args());
diff --git a/tests/profilefields/type_string_test.php b/tests/profilefields/type_string_test.php
index cee8a1d863..f6c14ee38b 100644
--- a/tests/profilefields/type_string_test.php
+++ b/tests/profilefields/type_string_test.php
@@ -225,6 +225,60 @@ class phpbb_profilefield_type_string_test extends phpbb_test_case
$this->assertSame($expected, $result, $description);
}
+ public function profile_value_raw_data()
+ {
+ return array(
+ array(
+ '[b]bbcode test[/b]',
+ array('field_show_novalue' => true),
+ '[b]bbcode test[/b]',
+ 'Field should return the correct raw value',
+ ),
+ array(
+ '[b]bbcode test[/b]',
+ array('field_show_novalue' => false),
+ '[b]bbcode test[/b]',
+ 'Field should return correct raw value',
+ ),
+ array(
+ 125,
+ array('field_show_novalue' => false),
+ 125,
+ 'Field should return value of integer as is',
+ ),
+ array(
+ 0,
+ array('field_show_novalue' => false),
+ null,
+ 'Field should return null for empty integer without show_novalue',
+ ),
+ array(
+ 0,
+ array('field_show_novalue' => true),
+ 0,
+ 'Field should return 0 for empty integer with show_novalue',
+ ),
+ array(
+ null,
+ array('field_show_novalue' => true),
+ null,
+ 'field should return null value as is',
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider profile_value_raw_data
+ */
+ public function test_get_profile_value_raw($value, $field_options, $expected, $description)
+ {
+ $field_options = array_merge($this->field_options, $field_options);
+
+ $result = $this->cp->get_profile_value_raw($value, $field_options);
+
+ $this->assertSame($expected, $result, $description);
+ }
+
public function return_callback_implode()
{
return implode('-', func_get_args());
diff --git a/tests/profilefields/type_url_test.php b/tests/profilefields/type_url_test.php
index 9957510d90..a45a28e7c7 100644
--- a/tests/profilefields/type_url_test.php
+++ b/tests/profilefields/type_url_test.php
@@ -104,6 +104,36 @@ class phpbb_profilefield_type_url_test extends phpbb_test_case
$this->assertSame($expected, $result, $description);
}
+ public function profile_value_raw_data()
+ {
+ return array(
+ array(
+ 'http://example.com',
+ array('field_show_novalue' => true),
+ 'http://example.com',
+ 'Field should return the correct raw value',
+ ),
+ array(
+ 'http://example.com',
+ array('field_show_novalue' => false),
+ 'http://example.com',
+ 'Field should return correct raw value',
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider profile_value_raw_data
+ */
+ public function test_get_profile_value_raw($value, $field_options, $expected, $description)
+ {
+ $field_options = array_merge($this->field_options, $field_options);
+
+ $result = $this->cp->get_profile_value_raw($value, $field_options);
+
+ $this->assertSame($expected, $result, $description);
+ }
+
public function return_callback_implode()
{
return implode('-', func_get_args());
diff --git a/tests/template/template_test.php b/tests/template/template_test.php
index 4f5b7629d5..0bbfe3848d 100644
--- a/tests/template/template_test.php
+++ b/tests/template/template_test.php
@@ -352,6 +352,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(),
"13FOOBAR|foobar",
),
+ array(
+ 'if_nested_tags.html',
+ array('S_VALUE' => true,),
+ array(),
+ array(),
+ 'inner_value',
+ ),
);
}
diff --git a/tests/template/templates/if_nested_tags.html b/tests/template/templates/if_nested_tags.html
new file mode 100644
index 0000000000..0348a31a8d
--- /dev/null
+++ b/tests/template/templates/if_nested_tags.html
@@ -0,0 +1 @@
+<!-- IF S_VALUE --><!-- DEFINE $INNER_VALUE = 'inner_value' --><!-- ENDIF -->{$INNER_VALUE}
diff --git a/tests/viewonline/helper_test.php b/tests/viewonline/helper_test.php
new file mode 100644
index 0000000000..e4950bb51a
--- /dev/null
+++ b/tests/viewonline/helper_test.php
@@ -0,0 +1,42 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+class phpbb_viewonline_helper_test extends phpbb_test_case
+{
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->viewonline_helper = new \phpbb\viewonline_helper();
+ }
+
+ public function session_pages_data()
+ {
+ return array(
+ array('index.php', 'index.php'),
+ array('foobar/test.php', 'foobar/test.php'),
+ array('', ''),
+ array('../index.php', '../index.php'),
+ );
+ }
+
+ /**
+ * @dataProvider session_pages_data
+ */
+ public function test_get_user_page($expected, $session_page)
+ {
+ $on_page = $this->viewonline_helper->get_user_page($session_page);
+ $this->assertArrayHasKey(1, $on_page);
+ $this->assertSame($expected, $on_page[1]);
+ }
+}