diff options
21 files changed, 435 insertions, 99 deletions
diff --git a/git-tools/hooks/commit-msg b/git-tools/hooks/commit-msg index 52969670ca..b156d276df 100755 --- a/git-tools/hooks/commit-msg +++ b/git-tools/hooks/commit-msg @@ -12,6 +12,13 @@ # ln -s ../../git-tools/hooks/commit-msg \\ # .git/hooks/commit-msg # +# You can configure whether invalid commit messages abort commits: +# +# git config phpbb.hooks.commit-msg.fatal true (abort) +# git config phpbb.hooks.commit-msg.fatal false (warn only, do not abort) +# +# The default is to warn only. +# # Warning/error messages use color by default if the output is a terminal # ("output" here is normally standard error when you run git commit). # To force or disable the use of color: @@ -21,6 +28,15 @@ config_ns="phpbb.hooks.commit-msg"; +if [ "$(git config --bool $config_ns.fatal)" = "true" ] +then + fatal=1; + severity=Error; +else + fatal=0; + severity=Warning; +fi + debug_level=$(git config --int $config_ns.debug || echo 0); # Error codes @@ -47,9 +63,19 @@ debug() quit() { - # Now we always exit with success, since git will trash - # entered commit message if commit-msg hook exits with a failure. - exit 0 + if [ $1 -eq 0 ] || [ $1 -eq $ERR_UNKNOWN ] + then + # success + exit 0; + elif [ $fatal -eq 0 ] + then + # problems found but fatal is false + complain 'Please run `git commit --amend` and fix the problems mentioned.' 1>&2 + exit 0; + else + complain "Aborting commit." 1>&2 + exit $1; + fi } use_color() @@ -170,7 +196,7 @@ do # Don't be too strict. # Commits may be temporary, intended to be squashed later. # Just issue a warning here. - complain "Warning: heading should be a sentence beginning with a capital letter." 1>&2 + complain "$severity: heading should be a sentence beginning with a capital letter." 1>&2 complain "You entered:" 1>&2 complain "$line" 1>&2 fi diff --git a/phpBB/includes/acp/acp_main.php b/phpBB/includes/acp/acp_main.php index e529ae0e5a..cffe296651 100644 --- a/phpBB/includes/acp/acp_main.php +++ b/phpBB/includes/acp/acp_main.php @@ -201,7 +201,7 @@ class acp_main // No maximum post id? :o if (!$max_post_id) { - $sql = 'SELECT MAX(post_id) + $sql = 'SELECT MAX(post_id) as max_post_id FROM ' . POSTS_TABLE; $result = $db->sql_query($sql); $max_post_id = (int) $db->sql_fetchfield('max_post_id'); diff --git a/phpBB/includes/functions_install.php b/phpBB/includes/functions_install.php index 6caa5c943f..633b2755f0 100644 --- a/phpBB/includes/functions_install.php +++ b/phpBB/includes/functions_install.php @@ -512,4 +512,56 @@ function adjust_language_keys_callback($matches) } } +/** +* Creates the output to be stored in a phpBB config.php file +* +* @param array $data Array containing the database connection information +* @param string $dbms The name of the DBAL class to use +* @param array $load_extensions Array of additional extensions that should be loaded +* @param bool $debug If the debug constants should be enabled by default or not +* +* @return string The output to write to the file +*/ +function phpbb_create_config_file_data($data, $dbms, $load_extensions, $debug = false) +{ + $load_extensions = implode(',', $load_extensions); + + $config_data = "<?php\n"; + $config_data .= "// phpBB 3.0.x auto-generated configuration file\n// Do not change anything in this file!\n"; + + $config_data_array = array( + 'dbms' => $dbms, + 'dbhost' => $data['dbhost'], + 'dbport' => $data['dbport'], + 'dbname' => $data['dbname'], + 'dbuser' => $data['dbuser'], + 'dbpasswd' => htmlspecialchars_decode($data['dbpasswd']), + 'table_prefix' => $data['table_prefix'], + 'acm_type' => 'file', + 'load_extensions' => $load_extensions, + ); + + foreach ($config_data_array as $key => $value) + { + $config_data .= "\${$key} = '" . str_replace("'", "\\'", str_replace('\\', '\\\\', $value)) . "';\n"; + } + + $config_data .= "\n@define('PHPBB_INSTALLED', true);\n"; + + if ($debug) + { + $config_data .= "@define('DEBUG', true);\n"; + $config_data .= "@define('DEBUG_EXTRA', true);\n"; + } + else + { + $config_data .= "// @define('DEBUG', true);\n"; + $config_data .= "// @define('DEBUG_EXTRA', true);\n"; + } + + $config_data .= '?' . '>'; // Done this to prevent highlighting editors getting confused! + + return $config_data; +} + ?>
\ No newline at end of file diff --git a/phpBB/includes/mcp/mcp_warn.php b/phpBB/includes/mcp/mcp_warn.php index 63e5b19155..1016204ff8 100644 --- a/phpBB/includes/mcp/mcp_warn.php +++ b/phpBB/includes/mcp/mcp_warn.php @@ -308,7 +308,7 @@ class mcp_warn include($phpbb_root_path . 'includes/functions_display.' . $phpEx); } - $rank_title = $rank_img = ''; + get_user_rank($user_row['user_rank'], $user_row['user_posts'], $rank_title, $rank_img, $rank_img_src); $avatar_img = get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height']); $template->assign_vars(array( @@ -413,7 +413,7 @@ class mcp_warn include($phpbb_root_path . 'includes/functions_display.' . $phpEx); } - $rank_title = $rank_img = ''; + get_user_rank($user_row['user_rank'], $user_row['user_posts'], $rank_title, $rank_img, $rank_img_src); $avatar_img = get_user_avatar($user_row['user_avatar'], $user_row['user_avatar_type'], $user_row['user_avatar_width'], $user_row['user_avatar_height']); // OK, they didn't submit a warning so lets build the page for them to do so diff --git a/phpBB/install/install_install.php b/phpBB/install/install_install.php index 026fc0d404..35fc0bb58e 100644 --- a/phpBB/install/install_install.php +++ b/phpBB/install/install_install.php @@ -105,6 +105,7 @@ class install_install extends module $this->add_language($mode, $sub); $this->add_bots($mode, $sub); $this->email_admin($mode, $sub); + $this->disable_avatars_if_unwritable(); // Remove the lock file @unlink($phpbb_root_path . 'cache/install_lock'); @@ -166,25 +167,28 @@ class install_install extends module 'S_LEGEND' => false, )); - // Check for register_globals being enabled - if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on') + // Don't check for register_globals on 5.4+ + if (version_compare($php_version, '5.4.0-dev') < 0) { - $result = '<strong style="color:red">' . $lang['NO'] . '</strong>'; - } - else - { - $result = '<strong style="color:green">' . $lang['YES'] . '</strong>'; - } - - $template->assign_block_vars('checks', array( - 'TITLE' => $lang['PHP_REGISTER_GLOBALS'], - 'TITLE_EXPLAIN' => $lang['PHP_REGISTER_GLOBALS_EXPLAIN'], - 'RESULT' => $result, + // Check for register_globals being enabled + if (@ini_get('register_globals') == '1' || strtolower(@ini_get('register_globals')) == 'on') + { + $result = '<strong style="color:red">' . $lang['NO'] . '</strong>'; + } + else + { + $result = '<strong style="color:green">' . $lang['YES'] . '</strong>'; + } - 'S_EXPLAIN' => true, - 'S_LEGEND' => false, - )); + $template->assign_block_vars('checks', array( + 'TITLE' => $lang['PHP_REGISTER_GLOBALS'], + 'TITLE_EXPLAIN' => $lang['PHP_REGISTER_GLOBALS_EXPLAIN'], + 'RESULT' => $result, + 'S_EXPLAIN' => true, + 'S_LEGEND' => false, + )); + } // Check for url_fopen if (@ini_get('allow_url_fopen') == '1' || strtolower(@ini_get('allow_url_fopen')) == 'on') @@ -881,34 +885,8 @@ class install_install extends module @chmod($phpbb_root_path . 'cache/install_lock', 0777); - $load_extensions = implode(',', $load_extensions); - // Time to convert the data provided into a config file - $config_data = "<?php\n"; - $config_data .= "// phpBB 3.0.x auto-generated configuration file\n// Do not change anything in this file!\n"; - - $config_data_array = array( - 'dbms' => $available_dbms[$data['dbms']]['DRIVER'], - 'dbhost' => $data['dbhost'], - 'dbport' => $data['dbport'], - 'dbname' => $data['dbname'], - 'dbuser' => $data['dbuser'], - 'dbpasswd' => htmlspecialchars_decode($data['dbpasswd']), - 'table_prefix' => $data['table_prefix'], - 'acm_type' => 'file', - 'load_extensions' => $load_extensions, - ); - - foreach ($config_data_array as $key => $value) - { - $config_data .= "\${$key} = '" . str_replace("'", "\\'", str_replace('\\', '\\\\', $value)) . "';\n"; - } - unset($config_data_array); - - $config_data .= "\n@define('PHPBB_INSTALLED', true);\n"; - $config_data .= "// @define('DEBUG', true);\n"; - $config_data .= "// @define('DEBUG_EXTRA', true);\n"; - $config_data .= '?' . '>'; // Done this to prevent highlighting editors getting confused! + $config_data = phpbb_create_config_file_data($data, $available_dbms[$data['dbms']]['DRIVER'], $load_extensions); // Attempt to write out the config file directly. If it works, this is the easiest way to do it ... if ((file_exists($phpbb_root_path . 'config.' . $phpEx) && phpbb_is_writable($phpbb_root_path . 'config.' . $phpEx)) || phpbb_is_writable($phpbb_root_path)) @@ -1965,6 +1943,21 @@ class install_install extends module } /** + * Check if the avatar directory is writable and disable avatars + * if it isn't writable. + */ + function disable_avatars_if_unwritable() + { + global $phpbb_root_path; + + if (!phpbb_is_writable($phpbb_root_path . 'images/avatars/upload/')) + { + set_config('allow_avatar', 0); + set_config('allow_avatar_upload', 0); + } + } + + /** * Generate a list of available mail server authentication methods */ function mail_auth_select($selected_method) diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index fcc372ae93..ba2d18da00 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -8,10 +8,10 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('active_sessions', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_attachments', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_autologin', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar_local', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar_remote', '0'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar_upload', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar_upload', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_avatar_remote_upload', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_bbcode', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('allow_birthdays', '1'); @@ -99,7 +99,7 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('email_package_size INSERT INTO phpbb_config (config_name, config_value) VALUES ('enable_confirm', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('enable_pm_icons', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('enable_post_confirm', '1'); -INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_enable', '0'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_enable', '1'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_http_auth', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_limit_post', '15'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('feed_limit_topic', '10'); diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index 0c387d0f36..0184dd083b 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -460,6 +460,7 @@ $lang = array_merge($lang, array( 'PRIVATE_MESSAGING' => 'Private messaging', 'PROFILE' => 'User Control Panel', + 'RANK' => 'Rank', 'READING_FORUM' => 'Viewing topics in %s', 'READING_GLOBAL_ANNOUNCE' => 'Reading global announcement', 'READING_LINK' => 'Following forum link %s', diff --git a/phpBB/language/en/memberlist.php b/phpBB/language/en/memberlist.php index e71f9d6565..7dc5e6b74a 100644 --- a/phpBB/language/en/memberlist.php +++ b/phpBB/language/en/memberlist.php @@ -110,7 +110,6 @@ $lang = array_merge($lang, array( 'POST_IP' => 'Posted from IP/domain', - 'RANK' => 'Rank', 'REAL_NAME' => 'Recipient name', 'RECIPIENT' => 'Recipient', 'REMOVE_FOE' => 'Remove foe', diff --git a/phpBB/styles/prosilver/template/posting_editor.html b/phpBB/styles/prosilver/template/posting_editor.html index 5f7fb8408e..67ba74a690 100644 --- a/phpBB/styles/prosilver/template/posting_editor.html +++ b/phpBB/styles/prosilver/template/posting_editor.html @@ -37,10 +37,10 @@ <!-- ENDIF --> <!-- IF not S_EDIT_POST --> <dl class="pmlist"> - <dt><textarea id="username_list" name="username_list" class="inputbox" cols="50" rows="2"></textarea></dt> + <dt><textarea id="username_list" name="username_list" class="inputbox" cols="50" rows="2" tabindex="1"></textarea></dt> <dd><span><a href="{U_FIND_USERNAME}" onclick="find_username(this.href); return false;">{L_FIND_USERNAME}</a></span></dd> - <dd><input type="submit" name="add_to" value="{L_ADD}" class="button2" /></dd> - <dd><input type="submit" name="add_bcc" value="{L_ADD_BCC}" class="button2" /></dd> + <dd><input type="submit" name="add_to" value="{L_ADD}" class="button2" tabindex="1" /></dd> + <dd><input type="submit" name="add_bcc" value="{L_ADD_BCC}" class="button2" tabindex="1" /></dd> </dl> <!-- ENDIF --> <!-- ELSE --> @@ -87,8 +87,8 @@ <dl> <dt><label for="icon">{L_ICON}:</label></dt> <dd> - <label for="icon"><input type="radio" name="icon" id="icon" value="0" checked="checked" /> <!-- IF S_SHOW_TOPIC_ICONS -->{L_NO_TOPIC_ICON}<!-- ELSE -->{L_NO_PM_ICON}<!-- ENDIF --></label> - <!-- BEGIN topic_icon --><label for="icon-{topic_icon.ICON_ID}"><input type="radio" name="icon" id="icon-{topic_icon.ICON_ID}" value="{topic_icon.ICON_ID}" {topic_icon.S_ICON_CHECKED} /><img src="{topic_icon.ICON_IMG}" width="{topic_icon.ICON_WIDTH}" height="{topic_icon.ICON_HEIGHT}" alt="" title="" /></label> <!-- END topic_icon --> + <label for="icon"><input type="radio" name="icon" id="icon" value="0" checked="checked" tabindex="1" /> <!-- IF S_SHOW_TOPIC_ICONS -->{L_NO_TOPIC_ICON}<!-- ELSE -->{L_NO_PM_ICON}<!-- ENDIF --></label> + <!-- BEGIN topic_icon --><label for="icon-{topic_icon.ICON_ID}"><input type="radio" name="icon" id="icon-{topic_icon.ICON_ID}" value="{topic_icon.ICON_ID}" {topic_icon.S_ICON_CHECKED} tabindex="1" /><img src="{topic_icon.ICON_IMG}" width="{topic_icon.ICON_WIDTH}" height="{topic_icon.ICON_HEIGHT}" alt="" title="" /></label> <!-- END topic_icon --> </dd> </dl> <!-- ENDIF --> diff --git a/phpBB/styles/subsilver2/template/posting_body.html b/phpBB/styles/subsilver2/template/posting_body.html index d7947caf2f..8e9934c173 100644 --- a/phpBB/styles/subsilver2/template/posting_body.html +++ b/phpBB/styles/subsilver2/template/posting_body.html @@ -127,7 +127,7 @@ <td class="row2"> <table width="100%" cellspacing="0" cellpadding="0" border="0"> <tr> - <td><input type="radio" class="radio" name="icon" value="0"{S_NO_ICON_CHECKED} /><span class="genmed"><!-- IF S_SHOW_TOPIC_ICONS -->{L_NO_TOPIC_ICON}<!-- ELSE -->{L_NO_PM_ICON}<!-- ENDIF --></span> <!-- BEGIN topic_icon --><span style="white-space: nowrap;"><input type="radio" class="radio" name="icon" value="{topic_icon.ICON_ID}"{topic_icon.S_ICON_CHECKED} /><img src="{topic_icon.ICON_IMG}" width="{topic_icon.ICON_WIDTH}" height="{topic_icon.ICON_HEIGHT}" alt="" title="" hspace="2" vspace="2" /></span> <!-- END topic_icon --></td> + <td><input type="radio" class="radio" name="icon" value="0"{S_NO_ICON_CHECKED} tabindex="1" /><span class="genmed"><!-- IF S_SHOW_TOPIC_ICONS -->{L_NO_TOPIC_ICON}<!-- ELSE -->{L_NO_PM_ICON}<!-- ENDIF --></span> <!-- BEGIN topic_icon --><span style="white-space: nowrap;"><input type="radio" class="radio" name="icon" value="{topic_icon.ICON_ID}"{topic_icon.S_ICON_CHECKED} tabindex="1" /><img src="{topic_icon.ICON_IMG}" width="{topic_icon.ICON_WIDTH}" height="{topic_icon.ICON_HEIGHT}" alt="" title="" hspace="2" vspace="2" /></span> <!-- END topic_icon --></td> </tr> </table> </td> diff --git a/phpBB/styles/subsilver2/template/posting_buttons.html b/phpBB/styles/subsilver2/template/posting_buttons.html index a9105b5eec..cfe69dee56 100644 --- a/phpBB/styles/subsilver2/template/posting_buttons.html +++ b/phpBB/styles/subsilver2/template/posting_buttons.html @@ -16,6 +16,7 @@ q: '{LA_BBCODE_Q_HELP}', c: '{LA_BBCODE_C_HELP}', l: '{LA_BBCODE_L_HELP}', + e: '{LA_BBCODE_LISTITEM_HELP}', o: '{LA_BBCODE_O_HELP}', p: '{LA_BBCODE_P_HELP}', w: '{LA_BBCODE_W_HELP}', diff --git a/phpBB/styles/subsilver2/template/ucp_header.html b/phpBB/styles/subsilver2/template/ucp_header.html index ea64dcb299..1566a15929 100644 --- a/phpBB/styles/subsilver2/template/ucp_header.html +++ b/phpBB/styles/subsilver2/template/ucp_header.html @@ -26,7 +26,7 @@ <td class="row1"><b class="genmed">{L_USERNAMES}:</b></td> </tr> <tr> - <td class="row2"><textarea name="username_list" rows="5" cols="22"></textarea><br /> + <td class="row2"><textarea name="username_list" rows="5" cols="22" tabindex="1"></textarea><br /> [ <a href="{U_FIND_USERNAME}" onclick="find_username(this.href); return false;">{L_FIND_USERNAME}</a> ] </td> </tr> @@ -41,7 +41,7 @@ <!-- ENDIF --> <!-- IF S_ALLOW_MASS_PM --> <tr> - <td class="row1"><div style="float: {S_CONTENT_FLOW_BEGIN};"> <input class="post" type="submit" name="add_bcc" value="{L_ADD_BCC}" /> </div><div style="float: {S_CONTENT_FLOW_END};"> <input class="post" type="submit" name="add_to" value="{L_ADD_TO}" /> </div></td> + <td class="row1"><div style="float: {S_CONTENT_FLOW_BEGIN};"> <input class="post" type="submit" name="add_bcc" value="{L_ADD_BCC}" tabindex="1" /> </div><div style="float: {S_CONTENT_FLOW_END};"> <input class="post" type="submit" name="add_to" value="{L_ADD_TO}" tabindex="1" /> </div></td> </tr> <!-- ENDIF --> </table> diff --git a/phpunit.xml.all b/phpunit.xml.all index 1be2830729..9e220ff559 100644 --- a/phpunit.xml.all +++ b/phpunit.xml.all @@ -14,6 +14,10 @@ <testsuites> <testsuite name="phpBB Test Suite"> <directory suffix="_test.php">./tests/</directory> + <exclude>./tests/functional</exclude> + </testsuite> + <testsuite name="phpBB Functional Tests"> + <directory suffix="_test.php" phpVersion="5.3.0" phpVersionOperator=">=">./tests/functional</directory> </testsuite> </testsuites> diff --git a/phpunit.xml.dist b/phpunit.xml.dist index de8134da8e..f8bf063d9a 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -14,11 +14,16 @@ <testsuites> <testsuite name="phpBB Test Suite"> <directory suffix="_test.php">./tests/</directory> + <exclude>./tests/functional</exclude> + </testsuite> + <testsuite name="phpBB Functional Tests"> + <directory suffix="_test.php" phpVersion="5.3.0" phpVersionOperator=">=">./tests/functional</directory> </testsuite> </testsuites> <groups> <exclude> + <group>functional</group> <group>slow</group> </exclude> </groups> diff --git a/phpunit.xml.functional b/phpunit.xml.functional new file mode 100644 index 0000000000..376d52e6d8 --- /dev/null +++ b/phpunit.xml.functional @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<phpunit backupGlobals="true" + backupStaticAttributes="true" + colors="true" + convertErrorsToExceptions="true" + convertNoticesToExceptions="true" + convertWarningsToExceptions="true" + processIsolation="false" + stopOnFailure="false" + syntaxCheck="false" + bootstrap="tests/bootstrap.php" +> + <testsuites> + <testsuite name="phpBB Test Suite"> + <directory suffix="_test.php">./tests/</directory> + <exclude>./tests/functional</exclude> + </testsuite> + <testsuite name="phpBB Functional Tests"> + <directory suffix="_test.php" phpVersion="5.3.0" phpVersionOperator=">=">./tests/functional</directory> + </testsuite> + </testsuites> + + <groups> + <include> + <group>functional</group> + </include> + </groups> + + <filter> + <blacklist> + <directory>./tests/</directory> + </blacklist> + </filter> +</phpunit> diff --git a/tests/bootstrap.php b/tests/bootstrap.php index 2fb805043e..d6c5d25bc8 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -19,3 +19,8 @@ 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/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/test_framework/phpbb_database_test_case.php b/tests/test_framework/phpbb_database_test_case.php index fdb662b284..e742b543b0 100644 --- a/tests/test_framework/phpbb_database_test_case.php +++ b/tests/test_framework/phpbb_database_test_case.php @@ -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_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_helpers.php b/tests/test_framework/phpbb_test_case_helpers.php index 9a7ab2d237..b46c36efaa 100644 --- a/tests/test_framework/phpbb_test_case_helpers.php +++ b/tests/test_framework/phpbb_test_case_helpers.php @@ -41,4 +41,61 @@ class phpbb_test_case_helpers $this->expectedTriggerError = true; $this->test_case->setExpectedException($exceptionName, (string) $message, $errno); } + + 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/vendor/goutte.phar b/vendor/goutte.phar Binary files differnew file mode 100644 index 0000000000..20b7166a67 --- /dev/null +++ b/vendor/goutte.phar |