aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--.travis.yml5
-rw-r--r--build/build.xml48
-rw-r--r--phpBB/includes/captcha/captcha_non_gd.php2
-rw-r--r--phpBB/includes/functions_database_helper.php206
-rw-r--r--phpBB/includes/functions_install.php2
-rw-r--r--phpBB/includes/functions_posting.php5
-rw-r--r--phpBB/includes/mcp/mcp_forum.php15
-rw-r--r--phpBB/includes/mcp/mcp_main.php22
-rw-r--r--phpBB/includes/mcp/mcp_pm_reports.php1
-rw-r--r--phpBB/includes/mcp/mcp_topic.php56
-rw-r--r--phpBB/install/database_update.php47
-rw-r--r--phpBB/posting.php7
-rw-r--r--tests/RUNNING_TESTS.txt21
-rw-r--r--tests/compress/compress_test.php25
-rw-r--r--tests/functional/posting_test.php149
-rw-r--r--tests/functions_database_helper/fixtures/bookmarks_duplicates.xml47
-rw-r--r--tests/functions_database_helper/fixtures/topics_watch_duplicates.xml80
-rw-r--r--tests/functions_database_helper/update_rows_avoiding_duplicates_notify_status_test.php101
-rw-r--r--tests/functions_database_helper/update_rows_avoiding_duplicates_test.php71
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php62
21 files changed, 837 insertions, 137 deletions
diff --git a/.gitignore b/.gitignore
index 4093aeb56d..c757210654 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,7 +2,7 @@
/phpunit.xml
/phpBB/cache/*.html
/phpBB/cache/*.php
-/phpBB/cache/queue.php.lock
+/phpBB/cache/*.lock
/phpBB/composer.phar
/phpBB/config.php
/phpBB/config_dev.php
diff --git a/.travis.yml b/.travis.yml
index 94e7086c1e..ba8c1b4a91 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,11 +4,16 @@ php:
- 5.3.3
- 5.3
- 5.4
+ - 5.5
env:
- DB=mysql
- DB=postgres
+matrix:
+ allow_failures:
+ - php: 5.5
+
before_script:
- sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'DROP DATABASE IF EXISTS phpbb_tests;' -U postgres; fi"
- sh -c "if [ '$DB' = 'postgres' ]; then psql -c 'create database phpbb_tests;' -U postgres; fi"
diff --git a/build/build.xml b/build/build.xml
index 28dd36bea8..f9574a3d4d 100644
--- a/build/build.xml
+++ b/build/build.xml
@@ -2,17 +2,16 @@
<project name="phpBB" description="The phpBB forum software" default="all" basedir="../">
<!-- a few settings for the build -->
- <property name="newversion" value="3.0.11" />
- <property name="prevversion" value="3.0.10" />
- <property name="olderversions" value="3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.0.6, 3.0.7, 3.0.7-PL1, 3.0.8, 3.0.9, 3.0.11-RC1, 3.0.11-RC2" />
+ <property name="newversion" value="3.0.12-dev" />
+ <property name="prevversion" value="3.0.11" />
+ <property name="olderversions" value="3.0.2, 3.0.3, 3.0.4, 3.0.5, 3.0.6, 3.0.7, 3.0.7-PL1, 3.0.8, 3.0.9, 3.0.10" />
<!-- no configuration should be needed beyond this point -->
<property name="oldversions" value="${olderversions}, ${prevversion}" />
<property name="versions" value="${oldversions}, ${newversion}" />
<!-- These are the main targets which you will probably want to use -->
- <target name="package" depends="clean,prepare,composer,create-package" />
- <target name="all" depends="clean,prepare,composer,test,docs,create-package" />
+ <target name="all" depends="clean,prepare,composer,test,docs,package" />
<target name="build" depends="clean,prepare,composer,test,docs" />
<target name="prepare">
@@ -43,9 +42,15 @@
<delete dir="build/save" />
</target>
- <target name="composer" depends="clean,prepare">
- <exec dir="./phpBB/"
- command="php ../composer.phar install"
+ <!--
+ This target basically just runs composer in the phpBB tree to ensure
+ all dependencies are loaded. Additional development dependencies are
+ loaded because testing framework may depend on them.
+ -->
+ <target name="composer">
+ <exec dir="phpBB"
+ command="php ../composer.phar install --dev"
+ checkreturn="true"
passthru="true" />
</target>
@@ -122,7 +127,7 @@
</target>
- <target name="create-package" depends="prepare-new-version,old-version-diffs">
+ <target name="package" depends="clean,prepare,prepare-new-version,old-version-diffs">
<exec dir="build" command="php -f package.php '${versions}' > logs/package.log" escape="false" />
<exec dir="build" command="php -f build_diff.php '${prevversion}' '${newversion}' > logs/build_diff.log" escape="false" />
@@ -162,9 +167,27 @@
command="git archive ${revision} | tar -xf - -C ../${dir}"
checkreturn="true" />
- <exec dir="${dir}"
- command="php ../composer.phar install"
- passthru="true" />
+ <!--
+ If composer.phar exists in this version of the tree, also export
+ it into ${dir}, install dependencies, then delete it again.
+ -->
+ <exec dir="."
+ command="git ls-tree ${revision} composer.phar"
+ checkreturn="true"
+ outputProperty='composer-ls-tree-output' />
+ <if>
+ <not><equals arg1="${composer-ls-tree-output}" arg2="" trim="true" /></not>
+ <then>
+ <exec dir="."
+ command="git archive ${revision} composer.phar | tar -xf - -C ${dir}"
+ checkreturn="true" />
+ <exec dir="${dir}"
+ command="php composer.phar install"
+ checkreturn="true"
+ passthru="true" />
+ <delete file="${dir}/composer.phar" />
+ </then>
+ </if>
<delete file="${dir}/config.php" />
<delete dir="${dir}/develop" />
@@ -187,6 +210,7 @@
<delete dir="${dir}/files" />
<delete dir="${dir}/install" />
<delete dir="${dir}/store" />
+ <delete dir="${dir}/vendor" />
</target>
</project>
diff --git a/phpBB/includes/captcha/captcha_non_gd.php b/phpBB/includes/captcha/captcha_non_gd.php
index f82896f628..2adf909b96 100644
--- a/phpBB/includes/captcha/captcha_non_gd.php
+++ b/phpBB/includes/captcha/captcha_non_gd.php
@@ -119,7 +119,7 @@ class captcha
$new_line = '';
$end = strlen($scanline) - ceil($width/2);
- for ($i = floor($width/2); $i < $end; $i++)
+ for ($i = (int) floor($width / 2); $i < $end; $i++)
{
$pixel = ord($scanline{$i});
diff --git a/phpBB/includes/functions_database_helper.php b/phpBB/includes/functions_database_helper.php
new file mode 100644
index 0000000000..664c246888
--- /dev/null
+++ b/phpBB/includes/functions_database_helper.php
@@ -0,0 +1,206 @@
+<?php
+/**
+*
+* @package phpBB3
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @ignore
+*/
+if (!defined('IN_PHPBB'))
+{
+ exit;
+}
+
+/**
+* Updates rows in given table from a set of values to a new value.
+* If this results in rows violating uniqueness constraints, the duplicate
+* rows are eliminated.
+*
+* The only supported table is bookmarks.
+*
+* @param dbal $db Database object
+* @param string $table Table on which to perform the update
+* @param string $column Column whose values to change
+* @param array $from_values An array of values that should be changed
+* @param int $to_value The new value
+* @return null
+*/
+function phpbb_update_rows_avoiding_duplicates($db, $table, $column, $from_values, $to_value)
+{
+ $sql = "SELECT $column, user_id
+ FROM $table
+ WHERE " . $db->sql_in_set($column, $from_values);
+ $result = $db->sql_query($sql);
+
+ $old_user_ids = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $old_user_ids[$row[$column]][] = (int) $row['user_id'];
+ }
+ $db->sql_freeresult($result);
+
+ $sql = "SELECT $column, user_id
+ FROM $table
+ WHERE $column = " . (int) $to_value;
+ $result = $db->sql_query($sql);
+
+ $new_user_ids = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $new_user_ids[$row[$column]][] = (int) $row['user_id'];
+ }
+ $db->sql_freeresult($result);
+
+ $queries = array();
+ foreach ($from_values as $from_value)
+ {
+ if (!isset($old_user_ids[$from_value]))
+ {
+ continue;
+ }
+ if (empty($new_user_ids))
+ {
+ $sql = "UPDATE $table
+ SET $column = " . (int) $to_value . "
+ WHERE $column = '" . $db->sql_escape($from_value) . "'";
+ $queries[] = $sql;
+ }
+ else
+ {
+ $different_user_ids = array_diff($old_user_ids[$from_value], $new_user_ids[$to_value]);
+ if (!empty($different_user_ids))
+ {
+ $sql = "UPDATE $table
+ SET $column = " . (int) $to_value . "
+ WHERE $column = '" . $db->sql_escape($from_value) . "'
+ AND " . $db->sql_in_set('user_id', $different_user_ids);
+ $queries[] = $sql;
+ }
+ }
+ }
+
+ if (!empty($queries))
+ {
+ $db->sql_transaction('begin');
+
+ foreach ($queries as $sql)
+ {
+ $db->sql_query($sql);
+ }
+
+ $sql = "DELETE FROM $table
+ WHERE " . $db->sql_in_set($column, $from_values);
+ $db->sql_query($sql);
+
+ $db->sql_transaction('commit');
+ }
+}
+
+/**
+* Updates rows in given table from a set of values to a new value.
+* If this results in rows violating uniqueness constraints, the duplicate
+* rows are merged respecting notify_status (0 takes precedence over 1).
+*
+* The only supported table is topics_watch.
+*
+* @param dbal $db Database object
+* @param string $table Table on which to perform the update
+* @param string $column Column whose values to change
+* @param array $from_values An array of values that should be changed
+* @param int $to_value The new value
+* @return null
+*/
+function phpbb_update_rows_avoiding_duplicates_notify_status($db, $table, $column, $from_values, $to_value)
+{
+ $sql = "SELECT $column, user_id, notify_status
+ FROM $table
+ WHERE " . $db->sql_in_set($column, $from_values);
+ $result = $db->sql_query($sql);
+
+ $old_user_ids = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $old_user_ids[(int) $row['notify_status']][$row[$column]][] = (int) $row['user_id'];
+ }
+ $db->sql_freeresult($result);
+
+ $sql = "SELECT $column, user_id
+ FROM $table
+ WHERE $column = " . (int) $to_value;
+ $result = $db->sql_query($sql);
+
+ $new_user_ids = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $new_user_ids[$row[$column]][] = (int) $row['user_id'];
+ }
+ $db->sql_freeresult($result);
+
+ $queries = array();
+ $extra_updates = array(
+ 0 => 'notify_status = 0',
+ 1 => '',
+ );
+ foreach ($from_values as $from_value)
+ {
+ foreach ($extra_updates as $notify_status => $extra_update)
+ {
+ if (!isset($old_user_ids[$notify_status][$from_value]))
+ {
+ continue;
+ }
+ if (empty($new_user_ids))
+ {
+ $sql = "UPDATE $table
+ SET $column = " . (int) $to_value . "
+ WHERE $column = '" . $db->sql_escape($from_value) . "'";
+ $queries[] = $sql;
+ }
+ else
+ {
+ $different_user_ids = array_diff($old_user_ids[$notify_status][$from_value], $new_user_ids[$to_value]);
+ if (!empty($different_user_ids))
+ {
+ $sql = "UPDATE $table
+ SET $column = " . (int) $to_value . "
+ WHERE $column = '" . $db->sql_escape($from_value) . "'
+ AND " . $db->sql_in_set('user_id', $different_user_ids);
+ $queries[] = $sql;
+ }
+
+ if ($extra_update)
+ {
+ $same_user_ids = array_diff($old_user_ids[$notify_status][$from_value], $different_user_ids);
+ if (!empty($same_user_ids))
+ {
+ $sql = "UPDATE $table
+ SET $extra_update
+ WHERE $column = '" . (int) $to_value . "'
+ AND " . $db->sql_in_set('user_id', $same_user_ids);
+ $queries[] = $sql;
+ }
+ }
+ }
+ }
+ }
+
+ if (!empty($queries))
+ {
+ $db->sql_transaction('begin');
+
+ foreach ($queries as $sql)
+ {
+ $db->sql_query($sql);
+ }
+
+ $sql = "DELETE FROM $table
+ WHERE " . $db->sql_in_set($column, $from_values);
+ $db->sql_query($sql);
+
+ $db->sql_transaction('commit');
+ }
+}
diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php
index eae136808c..47f4eac627 100644
--- a/phpBB/includes/functions_install.php
+++ b/phpBB/includes/functions_install.php
@@ -55,6 +55,8 @@ function get_available_dbms($dbms = false, $return_unavailable = false, $only_20
'AVAILABLE' => true,
'2.0.x' => false,
),
+ // Note: php 5.5 alpha 2 deprecated mysql.
+ // Keep mysqli before mysql in this list.
'mysqli' => array(
'LABEL' => 'MySQL with MySQLi Extension',
'SCHEMA' => 'mysql_41',
diff --git a/phpBB/includes/functions_posting.php b/phpBB/includes/functions_posting.php
index a1029ab97a..e5cbae0d71 100644
--- a/phpBB/includes/functions_posting.php
+++ b/phpBB/includes/functions_posting.php
@@ -1698,8 +1698,9 @@ function submit_post($mode, $subject, $username, $topic_type, &$poll, &$data, $u
// The variable name should be $post_approved, because it indicates if the post is approved or not
$post_approval = 1;
- // Check the permissions for post approval. Moderators are not affected.
- if (!$auth->acl_get('f_noapprove', $data['forum_id']) && !$auth->acl_get('m_approve', $data['forum_id']))
+ // Check the permissions for post approval.
+ // Moderators must go through post approval like ordinary users.
+ if (!$auth->acl_get('f_noapprove', $data['forum_id']))
{
// Post not approved, but in queue
$post_approval = 0;
diff --git a/phpBB/includes/mcp/mcp_forum.php b/phpBB/includes/mcp/mcp_forum.php
index b70601b479..04e0e70f1d 100644
--- a/phpBB/includes/mcp/mcp_forum.php
+++ b/phpBB/includes/mcp/mcp_forum.php
@@ -414,13 +414,16 @@ function merge_topics($forum_id, $topic_ids, $to_topic_id)
// Message and return links
$success_msg = 'POSTS_MERGED_SUCCESS';
- // If the topic no longer exist, we will update the topic watch table.
- // To not let it error out on users watching both topics, we just return on an error...
- $db->sql_return_on_error(true);
- $db->sql_query('UPDATE ' . TOPICS_WATCH_TABLE . ' SET topic_id = ' . (int) $to_topic_id . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids));
- $db->sql_return_on_error(false);
+ if (!function_exists('phpbb_update_rows_avoiding_duplicates_notify_status'))
+ {
+ include($phpbb_root_path . 'includes/functions_database_helper.' . $phpEx);
+ }
+
+ // Update the topic watch table.
+ phpbb_update_rows_avoiding_duplicates_notify_status($db, TOPICS_WATCH_TABLE, 'topic_id', $topic_ids, $to_topic_id);
- $db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . ' WHERE ' . $db->sql_in_set('topic_id', $topic_ids));
+ // Update the bookmarks table.
+ phpbb_update_rows_avoiding_duplicates($db, BOOKMARKS_TABLE, 'topic_id', $topic_ids, $to_topic_id);
// Link to the new topic
$return_link .= (($return_link) ? '<br /><br />' : '') . sprintf($user->lang['RETURN_NEW_TOPIC'], '<a href="' . append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $to_forum_id . '&amp;t=' . $to_topic_id) . '">', '</a>');
diff --git a/phpBB/includes/mcp/mcp_main.php b/phpBB/includes/mcp/mcp_main.php
index ffede11d37..0cef8933fc 100644
--- a/phpBB/includes/mcp/mcp_main.php
+++ b/phpBB/includes/mcp/mcp_main.php
@@ -1231,6 +1231,7 @@ function mcp_fork_topic($topic_ids)
}
}
+ // Copy topic subscriptions to new topic
$sql = 'SELECT user_id, notify_status
FROM ' . TOPICS_WATCH_TABLE . '
WHERE topic_id = ' . $topic_id;
@@ -1251,6 +1252,27 @@ function mcp_fork_topic($topic_ids)
{
$db->sql_multi_insert(TOPICS_WATCH_TABLE, $sql_ary);
}
+
+ // Copy bookmarks to new topic
+ $sql = 'SELECT user_id
+ FROM ' . BOOKMARKS_TABLE . '
+ WHERE topic_id = ' . $topic_id;
+ $result = $db->sql_query($sql);
+
+ $sql_ary = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $sql_ary[] = array(
+ 'topic_id' => (int) $new_topic_id,
+ 'user_id' => (int) $row['user_id'],
+ );
+ }
+ $db->sql_freeresult($result);
+
+ if (sizeof($sql_ary))
+ {
+ $db->sql_multi_insert(BOOKMARKS_TABLE, $sql_ary);
+ }
}
// Sync new topics, parent forums and board stats
diff --git a/phpBB/includes/mcp/mcp_pm_reports.php b/phpBB/includes/mcp/mcp_pm_reports.php
index 72f77fae7c..77bc7680e6 100644
--- a/phpBB/includes/mcp/mcp_pm_reports.php
+++ b/phpBB/includes/mcp/mcp_pm_reports.php
@@ -123,6 +123,7 @@ class mcp_pm_reports
$message = bbcode_nl2br($message);
$message = smiley_text($message);
+ $report['report_text'] = make_clickable(bbcode_nl2br($report['report_text']));
if ($pm_info['message_attachment'] && $auth->acl_get('u_pm_download'))
{
diff --git a/phpBB/includes/mcp/mcp_topic.php b/phpBB/includes/mcp/mcp_topic.php
index 7d4edaf362..76985488b7 100644
--- a/phpBB/includes/mcp/mcp_topic.php
+++ b/phpBB/includes/mcp/mcp_topic.php
@@ -517,6 +517,49 @@ function split_topic($action, $topic_id, $to_forum_id, $subject)
WHERE post_id = {$post_id_list[0]}";
$db->sql_query($sql);
+ // Copy topic subscriptions to new topic
+ $sql = 'SELECT user_id, notify_status
+ FROM ' . TOPICS_WATCH_TABLE . '
+ WHERE topic_id = ' . $topic_id;
+ $result = $db->sql_query($sql);
+
+ $sql_ary = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $sql_ary[] = array(
+ 'topic_id' => (int) $to_topic_id,
+ 'user_id' => (int) $row['user_id'],
+ 'notify_status' => (int) $row['notify_status'],
+ );
+ }
+ $db->sql_freeresult($result);
+
+ if (sizeof($sql_ary))
+ {
+ $db->sql_multi_insert(TOPICS_WATCH_TABLE, $sql_ary);
+ }
+
+ // Copy bookmarks to new topic
+ $sql = 'SELECT user_id
+ FROM ' . BOOKMARKS_TABLE . '
+ WHERE topic_id = ' . $topic_id;
+ $result = $db->sql_query($sql);
+
+ $sql_ary = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $sql_ary[] = array(
+ 'topic_id' => (int) $to_topic_id,
+ 'user_id' => (int) $row['user_id'],
+ );
+ }
+ $db->sql_freeresult($result);
+
+ if (sizeof($sql_ary))
+ {
+ $db->sql_multi_insert(BOOKMARKS_TABLE, $sql_ary);
+ }
+
$success_msg = 'TOPIC_SPLIT_SUCCESS';
// Update forum statistics
@@ -619,13 +662,16 @@ function merge_posts($topic_id, $to_topic_id)
}
else
{
+ if (!function_exists('phpbb_update_rows_avoiding_duplicates_notify_status'))
+ {
+ include($phpbb_root_path . 'includes/functions_database_helper.' . $phpEx);
+ }
+
// If the topic no longer exist, we will update the topic watch table.
- // To not let it error out on users watching both topics, we just return on an error...
- $db->sql_return_on_error(true);
- $db->sql_query('UPDATE ' . TOPICS_WATCH_TABLE . ' SET topic_id = ' . (int) $to_topic_id . ' WHERE topic_id = ' . (int) $topic_id);
- $db->sql_return_on_error(false);
+ phpbb_update_rows_avoiding_duplicates_notify_status($db, TOPICS_WATCH_TABLE, 'topic_id', $topic_ids, $to_topic_id);
- $db->sql_query('DELETE FROM ' . TOPICS_WATCH_TABLE . ' WHERE topic_id = ' . (int) $topic_id);
+ // If the topic no longer exist, we will update the bookmarks table.
+ phpbb_update_rows_avoiding_duplicates($db, BOOKMARKS_TABLE, 'topic_id', $topic_id, $to_topic_id);
}
// Link to the new topic
diff --git a/phpBB/install/database_update.php b/phpBB/install/database_update.php
index 983b1b46c4..8aa62af7e1 100644
--- a/phpBB/install/database_update.php
+++ b/phpBB/install/database_update.php
@@ -1017,7 +1017,7 @@ function database_update_info()
*****************************************************************************/
function change_database_data(&$no_updates, $version)
{
- global $db, $errored, $error_ary, $config, $phpbb_root_path, $phpEx;
+ global $db, $db_tools, $errored, $error_ary, $config, $table_prefix, $phpbb_root_path, $phpEx;
switch ($version)
{
@@ -1332,8 +1332,6 @@ function change_database_data(&$no_updates, $version)
),
);
- global $db_tools;
-
$statements = $db_tools->perform_schema_changes($changes);
foreach ($statements as $sql)
@@ -1975,26 +1973,41 @@ function change_database_data(&$no_updates, $version)
}
$db->sql_freeresult($result);
- global $db_tools, $table_prefix;
-
- // Recover from potentially broken Q&A CAPTCHA table on firebird
- // Q&A CAPTCHA was uninstallable, so it's safe to remove these
- // without data loss
+ /*
+ * Due to a bug, vanilla phpbb could not create captcha tables
+ * in 3.0.8 on firebird. It was possible for board administrators
+ * to adjust the code to work. If code was manually adjusted by
+ * board administrators, index names would not be the same as
+ * what 3.0.9 and newer expect. This code fragment drops captcha
+ * tables, destroying all entered Q&A captcha configuration, such
+ * that when Q&A is configured next the respective tables will be
+ * created with correct index names.
+ *
+ * If you wish to preserve your Q&A captcha configuration, you can
+ * manually rename indexes to the currently expected name:
+ * phpbb_captcha_questions_lang_iso => phpbb_captcha_questions_lang
+ * phpbb_captcha_answers_question_id => phpbb_captcha_answers_qid
+ *
+ * Again, this needs to be done only if a board was manually modified
+ * to fix broken captcha code.
+ *
if ($db_tools->sql_layer == 'firebird')
{
- $tables = array(
- $table_prefix . 'captcha_questions',
- $table_prefix . 'captcha_answers',
- $table_prefix . 'qa_confirm',
+ $changes = array(
+ 'drop_tables' => array(
+ $table_prefix . 'captcha_questions',
+ $table_prefix . 'captcha_answers',
+ $table_prefix . 'qa_confirm',
+ ),
);
- foreach ($tables as $table)
+ $statements = $db_tools->perform_schema_changes($changes);
+
+ foreach ($statements as $sql)
{
- if ($db_tools->sql_table_exists($table))
- {
- $db_tools->sql_table_drop($table);
- }
+ _sql($sql, $errored, $error_ary);
}
}
+ */
$no_updates = false;
break;
diff --git a/phpBB/posting.php b/phpBB/posting.php
index 76c8100c78..e57f5420f5 100644
--- a/phpBB/posting.php
+++ b/phpBB/posting.php
@@ -1018,7 +1018,7 @@ if ($submit || $preview || $refresh)
$forum_type = (int) $db->sql_fetchfield('forum_type');
$db->sql_freeresult($result);
- if ($forum_type != FORUM_POST || !$auth->acl_get('f_post', $to_forum_id) || (!$auth->acl_get('m_approve', $to_forum_id) && !$auth->acl_get('f_noapprove', $to_forum_id)))
+ if ($forum_type != FORUM_POST || !$auth->acl_get('f_post', $to_forum_id) || !$auth->acl_get('f_noapprove', $to_forum_id))
{
$to_forum_id = 0;
}
@@ -1138,8 +1138,9 @@ if ($submit || $preview || $refresh)
$captcha->reset();
}
- // Check the permissions for post approval. Moderators are not affected.
- if ((!$auth->acl_get('f_noapprove', $data['forum_id']) && !$auth->acl_get('m_approve', $data['forum_id']) && empty($data['force_approved_state'])) || (isset($data['force_approved_state']) && !$data['force_approved_state']))
+ // Check the permissions for post approval.
+ // Moderators must go through post approval like ordinary users.
+ if ((!$auth->acl_get('f_noapprove', $data['forum_id']) && empty($data['force_approved_state'])) || (isset($data['force_approved_state']) && !$data['force_approved_state']))
{
meta_refresh(10, $redirect_url);
$message = ($mode == 'edit') ? $user->lang['POST_EDITED_MOD'] : $user->lang['POST_STORED_MOD'];
diff --git a/tests/RUNNING_TESTS.txt b/tests/RUNNING_TESTS.txt
index 7c2a7c3fce..de9c751238 100644
--- a/tests/RUNNING_TESTS.txt
+++ b/tests/RUNNING_TESTS.txt
@@ -17,7 +17,24 @@ PHP extensions
Unit tests use several PHP extensions that board code does not use. Currently
the following PHP extensions must be installed and enabled to run unit tests:
-- ctype
+- ctype (also a PHPUnit dependency)
+- dom (PHPUnit dependency)
+
+Some of the functionality in phpBB and/or the test suite uses additional
+PHP extensions. If these extensions are not loaded, respective tests
+will be skipped:
+
+- apc (APC cache driver)
+- bz2 (compress tests)
+- interbase, pdo_firebird (Firebird database driver)
+- mysql, pdo_mysql (MySQL database driver)
+- mysqli, pdo_mysql (MySQLi database driver)
+- pdo (any database tests)
+- pgsql, pdo_pgsql (PostgreSQL database driver)
+- simplexml (any database tests)
+- sqlite, pdo_sqlite (SQLite database driver, requires SQLite 2.x support
+ in pdo_sqlite)
+- zlib (compress tests)
Database Tests
--------------
@@ -44,7 +61,7 @@ to use in the environment as follows:
$ PHPBB_TEST_CONFIG=tests/test_config.php phpunit
Alternatively you can specify parameters in the environment, so e.g. the
-following will run phpunit with the same parameters as in the shown
+following will run PHPUnit with the same parameters as in the shown
test_config.php file:
$ PHPBB_TEST_DBMS='mysqli' PHPBB_TEST_DBHOST='localhost' \
diff --git a/tests/compress/compress_test.php b/tests/compress/compress_test.php
index 65094671e3..ce193cf3ba 100644
--- a/tests/compress/compress_test.php
+++ b/tests/compress/compress_test.php
@@ -32,10 +32,16 @@ class phpbb_compress_test extends phpbb_test_case
$phpbb_root_path = '';
$this->path = dirname(__FILE__) . '/fixtures/';
+ }
- if (!@extension_loaded('zlib') || !@extension_loaded('bz2'))
+ protected function check_extensions($extensions)
+ {
+ foreach ($extensions as $extension)
{
- $this->markTestSkipped('PHP needs to be compiled with --with-zlib and --with-bz2 in order to run these tests');
+ if (!@extension_loaded($extension))
+ {
+ $this->markTestSkipped("$extension extension is not loaded");
+ }
}
}
@@ -103,17 +109,18 @@ class phpbb_compress_test extends phpbb_test_case
public function tar_archive_list()
{
return array(
- array('archive.tar', '.tar'),
- array('archive.tar.gz', '.tar.gz'),
- array('archive.tar.bz2', '.tar.bz2'),
+ array('archive.tar', '.tar', array()),
+ array('archive.tar.gz', '.tar.gz', array('zlib')),
+ array('archive.tar.bz2', '.tar.bz2', array('bz2')),
);
}
/**
* @dataProvider tar_archive_list
*/
- public function test_extract_tar($filename, $type)
+ public function test_extract_tar($filename, $type, $extensions)
{
+ $this->check_extensions($extensions);
$compress = new compress_tar('r', $this->path . $filename);
$compress->extract('tests/compress/' . self::EXTRACT_DIR);
$this->valid_extraction();
@@ -130,8 +137,10 @@ class phpbb_compress_test extends phpbb_test_case
* @depends test_extract_tar
* @dataProvider tar_archive_list
*/
- public function test_compress_tar($filename, $type)
+ public function test_compress_tar($filename, $type, $extensions)
{
+ $this->check_extensions($extensions);
+
$tar = dirname(__FILE__) . self::ARCHIVE_DIR . $filename;
$compress = new compress_tar('w', $tar);
$this->archive_files($compress);
@@ -149,6 +158,8 @@ class phpbb_compress_test extends phpbb_test_case
*/
public function test_compress_zip()
{
+ $this->check_extensions(array('zlib'));
+
$zip = dirname(__FILE__) . self::ARCHIVE_DIR . 'archive.zip';
$compress = new compress_zip('w', $zip);
$this->archive_files($compress);
diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php
index f54a3591b2..d05207edf0 100644
--- a/tests/functional/posting_test.php
+++ b/tests/functional/posting_test.php
@@ -15,70 +15,93 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
public function test_post_new_topic()
{
$this->login();
- $this->add_lang('posting');
- $crawler = $this->request('GET', 'posting.php?mode=post&f=2&sid=' . $this->sid);
- $this->assertContains($this->lang('POST_TOPIC'), $crawler->filter('html')->text());
+ // Test creating topic
+ $post = $this->create_topic(2, 'Test Topic 1', 'This is a test topic posted by the testing framework.');
- $hidden_fields = array();
- $hidden_fields[] = $crawler->filter('[type="hidden"]')->each(function ($node, $i) {
- return array('name' => $node->getAttribute('name'), 'value' => $node->getAttribute('value'));
- });
+ $crawler = $this->request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
+ $this->assertContains('This is a test topic posted by the testing framework.', $crawler->filter('html')->text());
- $test_message = 'This is a test topic posted by the testing framework.';
- $form_data = array(
- 'subject' => 'Test Topic 1',
- 'message' => $test_message,
- 'post' => true,
- 'f' => 2,
- 'mode' => 'post',
- 'sid' => $this->sid,
- );
+ // Test creating a reply
+ $post2 = $this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', 'This is a test post posted by the testing framework.');
- foreach ($hidden_fields as $fields)
- {
- foreach($fields as $field)
- {
- $form_data[$field['name']] = $field['value'];
- }
- }
+ $crawler = $this->request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}");
+ $this->assertContains('This is a test post posted by the testing framework.', $crawler->filter('html')->text());
- // Bypass time restriction that said that if the lastclick time (i.e. time when the form was opened)
- // is not at least 2 seconds before submission, cancel the form
- $form_data['lastclick'] = 0;
+ // Test quoting a message
+ $crawler = $this->request('GET', "posting.php?mode=quote&f=2&t={$post2['topic_id']}&p={$post2['post_id']}&sid={$this->sid}");
+ $this->assert_response_success();
+ $this->assertContains('This is a test post posted by the testing framework.', $crawler->filter('html')->text());
+ }
- // I use a request because the form submission method does not allow you to send data that is not
- // contained in one of the actual form fields that the browser sees (i.e. it ignores "hidden" inputs)
- // Instead, I send it as a request with the submit button "post" set to true.
- $crawler = $this->client->request('POST', 'posting.php', $form_data);
- $this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text());
+ /**
+ * Creates a topic
+ *
+ * Be sure to login before creating
+ *
+ * @param int $forum_id
+ * @param string $subject
+ * @param string $message
+ * @param array $additional_form_data Any additional form data to be sent in the request
+ * @return array post_id, topic_id
+ */
+ public function create_topic($forum_id, $subject, $message, $additional_form_data = array())
+ {
+ $posting_url = "posting.php?mode=post&f={$forum_id}&sid={$this->sid}";
+
+ $form_data = array_merge(array(
+ 'subject' => $subject,
+ 'message' => $message,
+ 'post' => true,
+ ), $additional_form_data);
- $crawler = $this->request('GET', 'viewtopic.php?t=2&sid=' . $this->sid);
- $this->assertContains($test_message, $crawler->filter('html')->text());
+ return $this->submit_post($posting_url, 'POST_TOPIC', $form_data);
}
- public function test_post_reply()
+ /**
+ * Creates a post
+ *
+ * Be sure to login before creating
+ *
+ * @param int $forum_id
+ * @param string $subject
+ * @param string $message
+ * @param array $additional_form_data Any additional form data to be sent in the request
+ * @return array post_id, topic_id
+ */
+ public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array())
{
- $this->login();
- $this->add_lang('posting');
+ $posting_url = "posting.php?mode=reply&f={$forum_id}&t={$topic_id}&sid={$this->sid}";
- $crawler = $this->request('GET', 'posting.php?mode=reply&t=2&f=2&sid=' . $this->sid);
- $this->assertContains($this->lang('POST_REPLY'), $crawler->filter('html')->text());
+ $form_data = array_merge(array(
+ 'subject' => $subject,
+ 'message' => $message,
+ 'post' => true,
+ ), $additional_form_data);
- $hidden_fields = array();
- $hidden_fields[] = $crawler->filter('[type="hidden"]')->each(function ($node, $i) {
- return array('name' => $node->getAttribute('name'), 'value' => $node->getAttribute('value'));
- });
+ return $this->submit_post($posting_url, 'POST_REPLY', $form_data);
+ }
+
+ /**
+ * Helper for submitting posts
+ *
+ * @param string $posting_url
+ * @param string $posting_contains
+ * @param array $form_data
+ * @return array post_id, topic_id
+ */
+ protected function submit_post($posting_url, $posting_contains, $form_data)
+ {
+ $this->add_lang('posting');
- $test_message = 'This is a test post posted by the testing framework.';
- $form_data = array(
- 'subject' => 'Re: Test Topic 1',
- 'message' => $test_message,
- 'post' => true,
- 't' => 2,
- 'f' => 2,
- 'mode' => 'reply',
- 'sid' => $this->sid,
+ $crawler = $this->request('GET', $posting_url);
+ $this->assert_response_success();
+ $this->assertContains($this->lang($posting_contains), $crawler->filter('html')->text());
+
+ $hidden_fields = array(
+ $crawler->filter('[type="hidden"]')->each(function ($node, $i) {
+ return array('name' => $node->getAttribute('name'), 'value' => $node->getAttribute('value'));
+ }),
);
foreach ($hidden_fields as $fields)
@@ -89,14 +112,28 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
}
}
- // For reasoning behind the following command, see the test_post_new_topic() test
+ // Bypass time restriction that said that if the lastclick time (i.e. time when the form was opened)
+ // is not at least 2 seconds before submission, cancel the form
$form_data['lastclick'] = 0;
- // Submit the post
- $crawler = $this->client->request('POST', 'posting.php', $form_data);
+ // I use a request because the form submission method does not allow you to send data that is not
+ // contained in one of the actual form fields that the browser sees (i.e. it ignores "hidden" inputs)
+ // Instead, I send it as a request with the submit button "post" set to true.
+ $crawler = $this->client->request('POST', $posting_url, $form_data);
+ $this->assert_response_success();
$this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text());
- $crawler = $this->request('GET', 'viewtopic.php?t=2&sid=' . $this->sid);
- $this->assertContains($test_message, $crawler->filter('html')->text());
+ $url = $crawler->selectLink($this->lang('VIEW_MESSAGE', '', ''))->link()->getUri();
+
+ $matches = $topic_id = $post_id = false;
+ preg_match_all('#&t=([0-9]+)(&p=([0-9]+))?#', $url, $matches);
+
+ $topic_id = (int) (isset($matches[1][0])) ? $matches[1][0] : 0;
+ $post_id = (int) (isset($matches[3][0])) ? $matches[3][0] : 0;
+
+ return array(
+ 'topic_id' => $topic_id,
+ 'post_id' => $post_id,
+ );
}
}
diff --git a/tests/functions_database_helper/fixtures/bookmarks_duplicates.xml b/tests/functions_database_helper/fixtures/bookmarks_duplicates.xml
new file mode 100644
index 0000000000..d49f76b073
--- /dev/null
+++ b/tests/functions_database_helper/fixtures/bookmarks_duplicates.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_bookmarks">
+ <column>user_id</column>
+ <column>topic_id</column>
+
+ <!-- one entry for this topic -->
+ <row>
+ <value>1</value>
+ <value>1</value>
+ </row>
+
+ <!-- non-conflicting entries -->
+ <row>
+ <value>2</value>
+ <value>2</value>
+ </row>
+ <row>
+ <value>3</value>
+ <value>3</value>
+ </row>
+
+ <!-- conflicting entries -->
+ <row>
+ <value>1</value>
+ <value>4</value>
+ </row>
+ <row>
+ <value>1</value>
+ <value>5</value>
+ </row>
+
+ <!-- conflicting and non-conflicting entries -->
+ <row>
+ <value>1</value>
+ <value>6</value>
+ </row>
+ <row>
+ <value>1</value>
+ <value>7</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>6</value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/functions_database_helper/fixtures/topics_watch_duplicates.xml b/tests/functions_database_helper/fixtures/topics_watch_duplicates.xml
new file mode 100644
index 0000000000..c387bb737a
--- /dev/null
+++ b/tests/functions_database_helper/fixtures/topics_watch_duplicates.xml
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_topics_watch">
+ <column>user_id</column>
+ <column>topic_id</column>
+ <column>notify_status</column>
+
+ <!-- one entry for this topic -->
+ <row>
+ <value>1</value>
+ <value>1</value>
+ <value>1</value>
+ </row>
+
+ <!-- non-conflicting entries -->
+ <row>
+ <value>1</value>
+ <value>2</value>
+ <value>1</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>3</value>
+ <value>0</value>
+ </row>
+
+ <!-- conflicting entries, same notify status -->
+ <row>
+ <value>1</value>
+ <value>4</value>
+ <value>1</value>
+ </row>
+ <row>
+ <value>1</value>
+ <value>5</value>
+ <value>1</value>
+ </row>
+
+ <!-- conflicting entries, notify status 0 into 1 -->
+ <row>
+ <value>1</value>
+ <value>6</value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>1</value>
+ <value>7</value>
+ <value>1</value>
+ </row>
+
+ <!-- conflicting entries, notify status 1 into 0 -->
+ <row>
+ <value>1</value>
+ <value>8</value>
+ <value>1</value>
+ </row>
+ <row>
+ <value>1</value>
+ <value>9</value>
+ <value>0</value>
+ </row>
+
+ <!-- conflicting and non-conflicting entries -->
+ <row>
+ <value>1</value>
+ <value>10</value>
+ <value>0</value>
+ </row>
+ <row>
+ <value>1</value>
+ <value>11</value>
+ <value>1</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>10</value>
+ <value>1</value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/functions_database_helper/update_rows_avoiding_duplicates_notify_status_test.php b/tests/functions_database_helper/update_rows_avoiding_duplicates_notify_status_test.php
new file mode 100644
index 0000000000..d4881daf7e
--- /dev/null
+++ b/tests/functions_database_helper/update_rows_avoiding_duplicates_notify_status_test.php
@@ -0,0 +1,101 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_database_helper.php';
+
+class phpbb_update_rows_avoiding_duplicates_notify_status_test extends phpbb_database_test_case
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/topics_watch_duplicates.xml');
+ }
+
+ public static function fixture_data()
+ {
+ return array(
+ // description
+ // from array
+ // to value
+ // expected count with to value post update
+ // expected notify_status values
+ array(
+ 'trivial',
+ array(1),
+ 1000,
+ 1,
+ 1,
+ ),
+ array(
+ 'no conflict',
+ array(2),
+ 3,
+ 2,
+ 1,
+ ),
+ array(
+ 'conflict, same notify status',
+ array(4),
+ 5,
+ 1,
+ 1,
+ ),
+ array(
+ 'conflict, notify status 0 into 1',
+ array(6),
+ 7,
+ 1,
+ 0,
+ ),
+ array(
+ 'conflict, notify status 1 into 0',
+ array(8),
+ 9,
+ 1,
+ 0,
+ ),
+ array(
+ 'conflict and no conflict',
+ array(10),
+ 11,
+ 2,
+ 0,
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider fixture_data
+ */
+ public function test_update($description, $from, $to, $expected_result_count, $expected_notify_status)
+ {
+ $db = $this->new_dbal();
+
+ phpbb_update_rows_avoiding_duplicates_notify_status($db, TOPICS_WATCH_TABLE, 'topic_id', $from, $to);
+
+ $sql = 'SELECT COUNT(*) AS remaining_rows
+ FROM ' . TOPICS_WATCH_TABLE . '
+ WHERE topic_id = ' . (int) $to;
+ $result = $db->sql_query($sql);
+ $result_count = $db->sql_fetchfield('remaining_rows');
+ $db->sql_freeresult($result);
+
+ $this->assertEquals($expected_result_count, $result_count);
+
+ // user id of 1 is the user being updated
+ $sql = 'SELECT notify_status
+ FROM ' . TOPICS_WATCH_TABLE . '
+ WHERE topic_id = ' . (int) $to . '
+ AND user_id = 1';
+ $result = $db->sql_query($sql);
+ $notify_status = $db->sql_fetchfield('notify_status');
+ $db->sql_freeresult($result);
+
+ $this->assertEquals($expected_notify_status, $notify_status);
+ }
+}
diff --git a/tests/functions_database_helper/update_rows_avoiding_duplicates_test.php b/tests/functions_database_helper/update_rows_avoiding_duplicates_test.php
new file mode 100644
index 0000000000..2f01d29d15
--- /dev/null
+++ b/tests/functions_database_helper/update_rows_avoiding_duplicates_test.php
@@ -0,0 +1,71 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2012 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_database_helper.php';
+
+class phpbb_update_rows_avoiding_duplicates_test extends phpbb_database_test_case
+{
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/bookmarks_duplicates.xml');
+ }
+
+ public static function fixture_data()
+ {
+ return array(
+ // description
+ // from array
+ // to value
+ // expected count with to value post update
+ array(
+ 'trivial',
+ array(1),
+ 10,
+ 1,
+ ),
+ array(
+ 'no conflict',
+ array(2),
+ 3,
+ 2,
+ ),
+ array(
+ 'conflict',
+ array(4),
+ 5,
+ 1,
+ ),
+ array(
+ 'conflict and no conflict',
+ array(6),
+ 7,
+ 2,
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider fixture_data
+ */
+ public function test_update($description, $from, $to, $expected_result_count)
+ {
+ $db = $this->new_dbal();
+
+ phpbb_update_rows_avoiding_duplicates($db, BOOKMARKS_TABLE, 'topic_id', $from, $to);
+
+ $sql = 'SELECT COUNT(*) AS remaining_rows
+ FROM ' . BOOKMARKS_TABLE . '
+ WHERE topic_id = ' . (int) $to;
+ $result = $db->sql_query($sql);
+ $result_count = $db->sql_fetchfield('remaining_rows');
+ $db->sql_freeresult($result);
+
+ $this->assertEquals($expected_result_count, $result_count);
+ }
+}
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index 71e88fbcf6..8ab6469e9a 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -35,13 +35,30 @@ class phpbb_functional_test_case extends phpbb_test_case
static protected $config = array();
static protected $already_installed = false;
- public function setUp()
+ static public function setUpBeforeClass()
{
+ parent::setUpBeforeClass();
+
+ self::$config = phpbb_test_case_helpers::get_test_config();
+
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.');
+ self::markTestSkipped('phpbb_functional_url was not set in test_config and wasn\'t set as PHPBB_FUNCTIONAL_URL environment variable either.');
}
+ if (!self::$already_installed)
+ {
+ self::install_board();
+ self::$already_installed = true;
+ }
+ }
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->bootstrap();
+
$this->cookieJar = new CookieJar;
$this->client = new Goutte\Client(array(), null, $this->cookieJar);
// Reset the curl handle because it is 0 at this point and not a valid
@@ -110,28 +127,14 @@ class phpbb_functional_test_case extends phpbb_test_case
$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()
+ static 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);
+ self::recreate_database(self::$config);
if (file_exists($phpbb_root_path . "config.$phpEx"))
{
@@ -176,19 +179,28 @@ class phpbb_functional_test_case extends phpbb_test_case
));
// end data
- $content = $this->do_request('install');
- $this->assertContains('Welcome to Installation', $content);
+ $content = self::do_request('install');
+ self::assertNotSame(false, $content);
+ self::assertContains('Welcome to Installation', $content);
- $this->do_request('create_table', $data);
+ $content = self::do_request('create_table', $data);
+ self::assertNotSame(false, $content);
+ self::assertContains('The database tables used by phpBB', $content);
+ // 3.0 or 3.1
+ self::assertContains('have been created and populated with some initial data.', $content);
- $this->do_request('config_file', $data);
+ $content = self::do_request('config_file', $data);
+ self::assertNotSame(false, $content);
+ self::assertContains('Configuration file', $content);
file_put_contents($phpbb_root_path . "config.$phpEx", phpbb_create_config_file_data($data, self::$config['dbms'], array(), true, true));
- $this->do_request('final', $data);
+ $content = self::do_request('final', $data);
+ self::assertNotSame(false, $content);
+ self::assertContains('You have successfully installed', $content);
copy($phpbb_root_path . "config.$phpEx", $phpbb_root_path . "config_test.$phpEx");
}
- private function do_request($sub, $post_data = null)
+ static private function do_request($sub, $post_data = null)
{
$context = null;
@@ -207,7 +219,7 @@ class phpbb_functional_test_case extends phpbb_test_case
return file_get_contents(self::$config['phpbb_functional_url'] . 'install/index.php?mode=install&sub=' . $sub, false, $context);
}
- private function recreate_database($config)
+ static private function recreate_database($config)
{
$db_conn_mgr = new phpbb_database_test_connection_manager($config);
$db_conn_mgr->recreate_db();