aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--code_sniffer/phpbb/Sniffs/Commenting/FileCommentSniff.php210
-rw-r--r--code_sniffer/phpbb/Tests/Commenting/FileCommentUnitTest.inc19
-rw-r--r--code_sniffer/phpbb/Tests/Commenting/FileCommentUnitTest.php51
-rw-r--r--code_sniffer/phpbb/build.xml23
-rw-r--r--code_sniffer/phpbb/phpbbCodingStandard.php43
-rw-r--r--phpBB/develop/create_schema_files.php1
-rw-r--r--phpBB/develop/mysql_upgrader.php1
-rw-r--r--phpBB/includes/session.php2
-rw-r--r--phpBB/includes/utf/utf_normalizer.php14
-rw-r--r--phpBB/install/schemas/firebird_schema.sql1
-rw-r--r--phpBB/install/schemas/mssql_schema.sql3
-rw-r--r--phpBB/install/schemas/mysql_40_schema.sql1
-rw-r--r--phpBB/install/schemas/mysql_41_schema.sql1
-rw-r--r--phpBB/install/schemas/oracle_schema.sql2
-rw-r--r--phpBB/install/schemas/postgres_schema.sql1
-rw-r--r--phpBB/install/schemas/sqlite_schema.sql1
-rw-r--r--phpBB/styles/prosilver/template/ucp_register.html2
-rw-r--r--tests/all_tests.php4
-rw-r--r--tests/bbcode/all_tests.php44
-rw-r--r--tests/bbcode/parser_test.php31
-rw-r--r--tests/request/request_class.php74
-rw-r--r--tests/request/request_var.php85
-rw-r--r--tests/template/template.php10
-rw-r--r--tests/template/templates/includephp.html2
-rw-r--r--tests/template/templates/loop_expressions.html11
25 files changed, 616 insertions, 21 deletions
diff --git a/code_sniffer/phpbb/Sniffs/Commenting/FileCommentSniff.php b/code_sniffer/phpbb/Sniffs/Commenting/FileCommentSniff.php
new file mode 100644
index 0000000000..e63c3f65fd
--- /dev/null
+++ b/code_sniffer/phpbb/Sniffs/Commenting/FileCommentSniff.php
@@ -0,0 +1,210 @@
+<?php
+/**
+*
+* @package code_sniffer
+* @version $Id: $
+* @copyright (c) 2007 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+/**
+* Checks that each source file contains the standard header.
+*
+* Based on Coding Guidelines 1.ii File Header.
+*
+* @package code_sniffer
+* @author Manuel Pichler <mapi@phpundercontrol.org>
+*/
+class phpbb_Sniffs_Commenting_FileCommentSniff implements PHP_CodeSniffer_Sniff
+{
+ /**
+ * Returns an array of tokens this test wants to listen for.
+ *
+ * @return array
+ */
+ public function register()
+ {
+ return array(T_OPEN_TAG);
+ }
+
+ /**
+ * Processes this test, when one of its tokens is encountered.
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
+ * @param int $stackPtr The position of the current token
+ * in the stack passed in $tokens.
+ *
+ * @return void
+ */
+ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
+ {
+ // We are only interested in the first file comment.
+ if ($stackPtr !== 0)
+ {
+ if ($phpcsFile->findPrevious(T_OPEN_TAG, $stackPtr - 1) !== false)
+ {
+ return;
+ }
+ }
+
+ // Fetch next non whitespace token
+ $tokens = $phpcsFile->getTokens();
+ $start = $phpcsFile->findNext(T_WHITESPACE, $stackPtr + 1, null, true);
+
+ // Skip empty files
+ if ($tokens[$start]['code'] === T_CLOSE_TAG)
+ {
+ return;
+ }
+ // Mark as error if this is not a doc comment
+ else if ($start === false || $tokens[$start]['code'] !== T_DOC_COMMENT)
+ {
+ $phpcsFile->addError('Missing required file doc comment.', $stackPtr);
+ return;
+ }
+
+ // Find comment end token
+ $end = $phpcsFile->findNext(T_DOC_COMMENT, $start + 1, null, true) - 1;
+
+ // If there is no end, skip processing here
+ if ($end === false)
+ {
+ return;
+ }
+
+ // List of found comment tags
+ $tags = array();
+
+ // check comment lines without the first(/**) an last(*/) line
+ for ($i = $start + 1, $c = ($end - $start); $i <= $c; ++$i)
+ {
+ $line = $tokens[$i]['content'];
+
+ // Check that each line starts with a '*'
+ if (substr($line, 0, 1) !== '*')
+ {
+ $message = 'The file doc comment should not be idented.';
+ $phpcsFile->addWarning($message, $i);
+ }
+ else if (preg_match('/^\*\s+@([\w]+)\s+(.*)$/', $line, $match) !== 0)
+ {
+ $tags[$match[1]] = array($match[2], $i);
+ }
+ }
+
+ // Check that the first and last line is empty
+ if (trim($tokens[$start + 1]['content']) !== '*')
+ {
+ $message = 'The first file comment line should be empty.';
+ $phpcsFile->addWarning($message, ($start + 1));
+ }
+ if (trim($tokens[$end - $start]['content']) !== '*')
+ {
+ $message = 'The last file comment line should be empty.';
+ $phpcsFile->addWarning($message, ($end - $start));
+ }
+
+ $this->processPackage($phpcsFile, $start, $tags);
+ $this->processVersion($phpcsFile, $start, $tags);
+ $this->processCopyright($phpcsFile, $start, $tags);
+ $this->processLicense($phpcsFile, $start, $tags);
+
+ //print_r($tags);
+ }
+
+ /**
+ * Checks that the tags array contains a valid package tag
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The context source file instance.
+ * @param integer The stack pointer for the first comment token.
+ * @param array(string=>array) $tags The found file doc comment tags.
+ *
+ * @return void
+ */
+ protected function processPackage(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags)
+ {
+ if (!isset($tags['package']))
+ {
+ $message = 'Missing require @package tag in file doc comment.';
+ $phpcsFile->addError($message, $ptr);
+ }
+ else if (preg_match('/^([\w]+)$/', $tags['package'][0]) === 0)
+ {
+ $message = 'Invalid content found for @package tag.';
+ $phpcsFile->addWarning($message, $tags['package'][1]);
+ }
+ }
+
+ /**
+ * Checks that the tags array contains a valid version tag
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The context source file instance.
+ * @param integer The stack pointer for the first comment token.
+ * @param array(string=>array) $tags The found file doc comment tags.
+ *
+ * @return void
+ */
+ protected function processVersion(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags)
+ {
+ if (!isset($tags['version']))
+ {
+ $message = 'Missing require @version tag in file doc comment.';
+ $phpcsFile->addError($message, $ptr);
+ }
+ else if (preg_match('/^\$Id:[^\$]+\$$/', $tags['version'][0]) === 0)
+ {
+ $message = 'Invalid content found for @version tag, use "$Id: $".';
+ $phpcsFile->addError($message, $tags['version'][1]);
+ }
+ }
+
+ /**
+ * Checks that the tags array contains a valid copyright tag
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The context source file instance.
+ * @param integer The stack pointer for the first comment token.
+ * @param array(string=>array) $tags The found file doc comment tags.
+ *
+ * @return void
+ */
+ protected function processCopyright(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags)
+ {
+ if (!isset($tags['copyright']))
+ {
+ $message = 'Missing require @copyright tag in file doc comment.';
+ $phpcsFile->addError($message, $ptr);
+ }
+ else if (preg_match('/^\(c\) 2[0-9]{3} phpBB Group\s*$/', $tags['copyright'][0]) === 0)
+ {
+ $message = 'Invalid content found for @copyright tag, use "(c) <year> phpBB Group".';
+ $phpcsFile->addError($message, $tags['copyright'][1]);
+ }
+ }
+
+ /**
+ * Checks that the tags array contains a valid license tag
+ *
+ * @param PHP_CodeSniffer_File $phpcsFile The context source file instance.
+ * @param integer The stack pointer for the first comment token.
+ * @param array(string=>array) $tags The found file doc comment tags.
+ *
+ * @return void
+ */
+ protected function processLicense(PHP_CodeSniffer_File $phpcsFile, $ptr, $tags)
+ {
+ $license = 'http://opensource.org/licenses/gpl-license.php GNU Public License';
+
+ if (!isset($tags['license']))
+ {
+ $message = 'Missing require @license tag in file doc comment.';
+ $phpcsFile->addError($message, $ptr);
+ }
+ else if (trim($tags['license'][0]) !== $license)
+ {
+ $message = 'Invalid content found for @license tag, use '
+ . '"' . $license . '".';
+ $phpcsFile->addError($message, $tags['license'][1]);
+ }
+ }
+} \ No newline at end of file
diff --git a/code_sniffer/phpbb/Tests/Commenting/FileCommentUnitTest.inc b/code_sniffer/phpbb/Tests/Commenting/FileCommentUnitTest.inc
new file mode 100644
index 0000000000..0ace1c1bda
--- /dev/null
+++ b/code_sniffer/phpbb/Tests/Commenting/FileCommentUnitTest.inc
@@ -0,0 +1,19 @@
+<?php
+/**
+*
+* @package code_sniffer³
+* @version $Id: $
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php BSD License
+ *
+*/
+?>
+<?php
+/**
+* Broken but not first file doc comment.
+*
+* @version @package_version@
+* @license http://www.opensource.org/licenses/bsd-license.php BSD License
+* @copyright (c) 2007 phpBB Group
+*
+*/
diff --git a/code_sniffer/phpbb/Tests/Commenting/FileCommentUnitTest.php b/code_sniffer/phpbb/Tests/Commenting/FileCommentUnitTest.php
new file mode 100644
index 0000000000..849a7fb9a0
--- /dev/null
+++ b/code_sniffer/phpbb/Tests/Commenting/FileCommentUnitTest.php
@@ -0,0 +1,51 @@
+<?php
+/**
+*
+* @package code_sniffer
+* @version $Id: $
+* @copyright (c) 2007 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+/**
+* Unit test class for the EmptyStatement sniff.
+*
+* @package code_sniffer
+* @author Manuel Pichler <mapi@phpundercontrol.org>
+*/
+class phpbb_Tests_Commenting_FileCommentUnitTest extends AbstractSniffUnitTest
+{
+
+ /**
+ * Returns the lines where errors should occur.
+ *
+ * The key of the array should represent the line number and the value
+ * should represent the number of errors that should occur on that line.
+ *
+ * @return array(int => int)
+ */
+ public function getErrorList()
+ {
+ return array(
+ 7 => 1 // BSD License error :)
+ );
+ }//end getErrorList()
+
+
+ /**
+ * Returns the lines where warnings should occur.
+ *
+ * The key of the array should represent the line number and the value
+ * should represent the number of warnings that should occur on that line.
+ *
+ * @return array(int => int)
+ */
+ public function getWarningList()
+ {
+ return array(
+ 4 => 1,
+ 8 => 1
+ );
+ }//end getWarningList()
+} \ No newline at end of file
diff --git a/code_sniffer/phpbb/build.xml b/code_sniffer/phpbb/build.xml
new file mode 100644
index 0000000000..b6d3bf6451
--- /dev/null
+++ b/code_sniffer/phpbb/build.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="code_sniffer" basedir="." default="install">
+
+ <property name="working.dir" value="${basedir}" />
+ <property name="target.dir" value="/usr/share/php/PHP/CodeSniffer/Standards" />
+
+ <!--
+ Install phpbb sniff
+ -->
+ <target name="install">
+ <delete dir="${target.dir}/phpbb" />
+ <mkdir dir="${target.dir}/phpbb"/>
+
+ <copy todir="${target.dir}/phpbb">
+ <fileset file="${working.dir}/phpbbCodingStandard.php" />
+ </copy>
+ <copy todir="${target.dir}/phpbb/Sniffs">
+ <fileset dir="${working.dir}/Sniffs" />
+ </copy>
+
+ </target>
+
+</project>
diff --git a/code_sniffer/phpbb/phpbbCodingStandard.php b/code_sniffer/phpbb/phpbbCodingStandard.php
new file mode 100644
index 0000000000..be51b54b40
--- /dev/null
+++ b/code_sniffer/phpbb/phpbbCodingStandard.php
@@ -0,0 +1,43 @@
+<?php
+/**
+*
+* @package code_sniffer
+* @version $Id: $
+* @copyright (c) 2007 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+/**
+ * @ignore
+ */
+if (class_exists('PHP_CodeSniffer_Standards_CodingStandard', true) === false) {
+ throw new PHP_CodeSniffer_Exception(
+ 'Class PHP_CodeSniffer_Standards_CodingStandard not found'
+ );
+}
+
+/**
+ * Primary class for the phpbb coding standard.
+ *
+ * @package code_sniffer
+ */
+class PHP_CodeSniffer_Standards_phpbb_phpbbCodingStandard extends PHP_CodeSniffer_Standards_CodingStandard
+{
+ /**
+ * Return a list of external sniffs to include with this standard.
+ *
+ * External locations can be single sniffs, a whole directory of sniffs, or
+ * an entire coding standard. Locations start with the standard name. For
+ * example:
+ * PEAR => include all sniffs in this standard
+ * PEAR/Sniffs/Files => include all sniffs in this dir
+ * PEAR/Sniffs/Files/LineLengthSniff => include this single sniff
+ *
+ * @return array
+ */
+ public function getIncludedSniffs()
+ {
+ return array();
+ }
+} \ No newline at end of file
diff --git a/phpBB/develop/create_schema_files.php b/phpBB/develop/create_schema_files.php
index 0515d801f2..4fb7b0d8f7 100644
--- a/phpBB/develop/create_schema_files.php
+++ b/phpBB/develop/create_schema_files.php
@@ -1200,6 +1200,7 @@ function get_schema_struct()
'PRIMARY_KEY' => 'log_id',
'KEYS' => array(
'log_type' => array('INDEX', 'log_type'),
+ 'log_time' => array('INDEX', 'log_time'),
'forum_id' => array('INDEX', 'forum_id'),
'topic_id' => array('INDEX', 'topic_id'),
'reportee_id' => array('INDEX', 'reportee_id'),
diff --git a/phpBB/develop/mysql_upgrader.php b/phpBB/develop/mysql_upgrader.php
index 57230339e8..85da1dfa47 100644
--- a/phpBB/develop/mysql_upgrader.php
+++ b/phpBB/develop/mysql_upgrader.php
@@ -688,6 +688,7 @@ function get_schema_struct()
'PRIMARY_KEY' => 'log_id',
'KEYS' => array(
'log_type' => array('INDEX', 'log_type'),
+ 'log_time' => array('INDEX', 'log_time'),
'forum_id' => array('INDEX', 'forum_id'),
'topic_id' => array('INDEX', 'topic_id'),
'reportee_id' => array('INDEX', 'reportee_id'),
diff --git a/phpBB/includes/session.php b/phpBB/includes/session.php
index 0a01b4e73b..37c62c130c 100644
--- a/phpBB/includes/session.php
+++ b/phpBB/includes/session.php
@@ -39,7 +39,7 @@ class session
*
* @param string $root_path current root path (phpbb_root_path)
*/
- function extract_current_page($root_path)
+ static function extract_current_page($root_path)
{
$page_array = array();
diff --git a/phpBB/includes/utf/utf_normalizer.php b/phpBB/includes/utf/utf_normalizer.php
index a77952499a..78684df69c 100644
--- a/phpBB/includes/utf/utf_normalizer.php
+++ b/phpBB/includes/utf/utf_normalizer.php
@@ -77,7 +77,7 @@ class utf_normalizer
* @param string &$str The dirty string
* @return string The same string, all shiny and cleaned-up
*/
- function cleanup(&$str)
+ static function cleanup(&$str)
{
// The string below is the list of all autorized characters, sorted by frequency in latin text
$pos = strspn($str, "\x20\x65\x69\x61\x73\x6E\x74\x72\x6F\x6C\x75\x64\x5D\x5B\x63\x6D\x70\x27\x0A\x67\x7C\x68\x76\x2E\x66\x62\x2C\x3A\x3D\x2D\x71\x31\x30\x43\x32\x2A\x79\x78\x29\x28\x4C\x39\x41\x53\x2F\x50\x22\x45\x6A\x4D\x49\x6B\x33\x3E\x35\x54\x3C\x44\x34\x7D\x42\x7B\x38\x46\x77\x52\x36\x37\x55\x47\x4E\x3B\x4A\x7A\x56\x23\x48\x4F\x57\x5F\x26\x21\x4B\x3F\x58\x51\x25\x59\x5C\x09\x5A\x2B\x7E\x5E\x24\x40\x60\x7F\x0D");
@@ -119,7 +119,7 @@ class utf_normalizer
* @param string &$str Unchecked UTF string
* @return string The string, validated and in normal form
*/
- function nfc(&$str)
+ static function nfc(&$str)
{
$pos = strspn($str, UTF8_ASCII_RANGE);
$len = strlen($str);
@@ -151,7 +151,7 @@ class utf_normalizer
* @param string &$str Unchecked UTF string
* @return string The string, validated and in normal form
*/
- function nfkc(&$str)
+ static function nfkc(&$str)
{
$pos = strspn($str, UTF8_ASCII_RANGE);
$len = strlen($str);
@@ -183,7 +183,7 @@ class utf_normalizer
* @param string &$str Unchecked UTF string
* @return string The string, validated and in normal form
*/
- function nfd(&$str)
+ static function nfd(&$str)
{
$pos = strspn($str, UTF8_ASCII_RANGE);
$len = strlen($str);
@@ -209,7 +209,7 @@ class utf_normalizer
* @param string &$str Unchecked UTF string
* @return string The string, validated and in normal form
*/
- function nfkd(&$str)
+ static function nfkd(&$str)
{
$pos = strspn($str, UTF8_ASCII_RANGE);
$len = strlen($str);
@@ -242,7 +242,7 @@ class utf_normalizer
*
* @access private
*/
- function recompose($str, $pos, $len, &$qc, &$decomp_map)
+ static function recompose($str, $pos, $len, &$qc, &$decomp_map)
{
global $utf_combining_class, $utf_canonical_comp, $utf_jamo_type, $utf_jamo_index;
@@ -944,7 +944,7 @@ class utf_normalizer
*
* @access private
*/
- function decompose($str, $pos, $len, &$decomp_map)
+ static function decompose($str, $pos, $len, &$decomp_map)
{
global $utf_combining_class;
diff --git a/phpBB/install/schemas/firebird_schema.sql b/phpBB/install/schemas/firebird_schema.sql
index 85f86781de..ab622e8fde 100644
--- a/phpBB/install/schemas/firebird_schema.sql
+++ b/phpBB/install/schemas/firebird_schema.sql
@@ -529,6 +529,7 @@ CREATE TABLE phpbb_log (
ALTER TABLE phpbb_log ADD PRIMARY KEY (log_id);;
CREATE INDEX phpbb_log_log_type ON phpbb_log(log_type);;
+CREATE INDEX phpbb_log_log_time ON phpbb_log(log_time);;
CREATE INDEX phpbb_log_forum_id ON phpbb_log(forum_id);;
CREATE INDEX phpbb_log_topic_id ON phpbb_log(topic_id);;
CREATE INDEX phpbb_log_reportee_id ON phpbb_log(reportee_id);;
diff --git a/phpBB/install/schemas/mssql_schema.sql b/phpBB/install/schemas/mssql_schema.sql
index 0827b14cc2..068373c9a1 100644
--- a/phpBB/install/schemas/mssql_schema.sql
+++ b/phpBB/install/schemas/mssql_schema.sql
@@ -636,6 +636,9 @@ GO
CREATE INDEX [log_type] ON [phpbb_log]([log_type]) ON [PRIMARY]
GO
+CREATE INDEX [log_time] ON [phpbb_log]([log_time]) ON [PRIMARY]
+GO
+
CREATE INDEX [forum_id] ON [phpbb_log]([forum_id]) ON [PRIMARY]
GO
diff --git a/phpBB/install/schemas/mysql_40_schema.sql b/phpBB/install/schemas/mysql_40_schema.sql
index 19b1b4f0f7..813cf8613f 100644
--- a/phpBB/install/schemas/mysql_40_schema.sql
+++ b/phpBB/install/schemas/mysql_40_schema.sql
@@ -362,6 +362,7 @@ CREATE TABLE phpbb_log (
log_data mediumblob NOT NULL,
PRIMARY KEY (log_id),
KEY log_type (log_type),
+ KEY log_time (log_time),
KEY forum_id (forum_id),
KEY topic_id (topic_id),
KEY reportee_id (reportee_id),
diff --git a/phpBB/install/schemas/mysql_41_schema.sql b/phpBB/install/schemas/mysql_41_schema.sql
index 3b70630a9e..97369d2bf7 100644
--- a/phpBB/install/schemas/mysql_41_schema.sql
+++ b/phpBB/install/schemas/mysql_41_schema.sql
@@ -362,6 +362,7 @@ CREATE TABLE phpbb_log (
log_data mediumtext NOT NULL,
PRIMARY KEY (log_id),
KEY log_type (log_type),
+ KEY log_time (log_time),
KEY forum_id (forum_id),
KEY topic_id (topic_id),
KEY reportee_id (reportee_id),
diff --git a/phpBB/install/schemas/oracle_schema.sql b/phpBB/install/schemas/oracle_schema.sql
index d577fce46c..7be7cd0756 100644
--- a/phpBB/install/schemas/oracle_schema.sql
+++ b/phpBB/install/schemas/oracle_schema.sql
@@ -715,6 +715,8 @@ CREATE TABLE phpbb_log (
CREATE INDEX phpbb_log_log_type ON phpbb_log (log_type)
/
+CREATE INDEX phpbb_log_log_time ON phpbb_log (log_time)
+/
CREATE INDEX phpbb_log_forum_id ON phpbb_log (forum_id)
/
CREATE INDEX phpbb_log_topic_id ON phpbb_log (topic_id)
diff --git a/phpBB/install/schemas/postgres_schema.sql b/phpBB/install/schemas/postgres_schema.sql
index 50b3979adb..9cdf35024b 100644
--- a/phpBB/install/schemas/postgres_schema.sql
+++ b/phpBB/install/schemas/postgres_schema.sql
@@ -519,6 +519,7 @@ CREATE TABLE phpbb_log (
);
CREATE INDEX phpbb_log_log_type ON phpbb_log (log_type);
+CREATE INDEX phpbb_log_log_time ON phpbb_log (log_time);
CREATE INDEX phpbb_log_forum_id ON phpbb_log (forum_id);
CREATE INDEX phpbb_log_topic_id ON phpbb_log (topic_id);
CREATE INDEX phpbb_log_reportee_id ON phpbb_log (reportee_id);
diff --git a/phpBB/install/schemas/sqlite_schema.sql b/phpBB/install/schemas/sqlite_schema.sql
index 7ee821d395..34b4b05478 100644
--- a/phpBB/install/schemas/sqlite_schema.sql
+++ b/phpBB/install/schemas/sqlite_schema.sql
@@ -352,6 +352,7 @@ CREATE TABLE phpbb_log (
);
CREATE INDEX phpbb_log_log_type ON phpbb_log (log_type);
+CREATE INDEX phpbb_log_log_time ON phpbb_log (log_time);
CREATE INDEX phpbb_log_forum_id ON phpbb_log (forum_id);
CREATE INDEX phpbb_log_topic_id ON phpbb_log (topic_id);
CREATE INDEX phpbb_log_reportee_id ON phpbb_log (reportee_id);
diff --git a/phpBB/styles/prosilver/template/ucp_register.html b/phpBB/styles/prosilver/template/ucp_register.html
index 0c632f5c69..e63abaec05 100644
--- a/phpBB/styles/prosilver/template/ucp_register.html
+++ b/phpBB/styles/prosilver/template/ucp_register.html
@@ -48,7 +48,7 @@
</dl>
<dl>
<dt><label for="password_confirm">{L_CONFIRM_PASSWORD}:</label></dt>
- <dd><input type="password" tabindex="5" name="password_confirm" id="password_confirm" size="25" value="{PASSWORD_CONFIRM}" class="inputbox autowidth" title="{L_CONFIRM_PASSWORD}" /></dd>
+ <dd><input type="password" tabindex="5" name="password_confirm" id="password_confirm" size="25" value="{PASSWORD_CONFIRM}" class="inputbox autowidth" title="{L_CONFIRM_PASSWORD}" /></dd>
</dl>
<hr />
diff --git a/tests/all_tests.php b/tests/all_tests.php
index e693427809..dbd161ddbb 100644
--- a/tests/all_tests.php
+++ b/tests/all_tests.php
@@ -7,8 +7,6 @@
*
*/
-error_reporting(E_ALL);
-
if (!defined('PHPUnit_MAIN_METHOD'))
{
define('PHPUnit_MAIN_METHOD', 'phpbb_all_tests::main');
@@ -21,6 +19,7 @@ require_once 'utf/all_tests.php';
require_once 'request/all_tests.php';
require_once 'security/all_tests.php';
require_once 'template/all_tests.php';
+#require_once 'bbcode/all_tests.php';
require_once 'text_processing/all_tests.php';
require_once 'dbal/all_tests.php';
@@ -42,6 +41,7 @@ class phpbb_all_tests
$suite->addTest(phpbb_request_all_tests::suite());
$suite->addTest(phpbb_security_all_tests::suite());
$suite->addTest(phpbb_template_all_tests::suite());
+# $suite->addTest(phpbb_bbcode_all_tests::suite());
$suite->addTest(phpbb_text_processing_all_tests::suite());
$suite->addTest(phpbb_dbal_all_tests::suite());
diff --git a/tests/bbcode/all_tests.php b/tests/bbcode/all_tests.php
new file mode 100644
index 0000000000..f4200fd0a9
--- /dev/null
+++ b/tests/bbcode/all_tests.php
@@ -0,0 +1,44 @@
+<?php
+/**
+*
+* @package testing
+* @version $Id$
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+define('IN_PHPBB', true);
+
+if (!defined('PHPUnit_MAIN_METHOD'))
+{
+ define('PHPUnit_MAIN_METHOD', 'phpbb_bbcode_all_tests::main');
+}
+
+require_once 'test_framework/framework.php';
+require_once 'PHPUnit/TextUI/TestRunner.php';
+
+require_once 'bbcode/parser_test.php';
+
+class phpbb_bbcode_all_tests
+{
+ public static function main()
+ {
+ PHPUnit_TextUI_TestRunner::run(self::suite());
+ }
+
+ public static function suite()
+ {
+ $suite = new PHPUnit_Framework_TestSuite('phpBB Formatted Text / BBCode');
+
+ $suite->addTestSuite('phpbb_bbcode_parser_test');
+
+ return $suite;
+ }
+}
+
+if (PHPUnit_MAIN_METHOD == 'phpbb_bbcode_all_tests::main')
+{
+ phpbb_bbcode_all_tests::main();
+}
+?> \ No newline at end of file
diff --git a/tests/bbcode/parser_test.php b/tests/bbcode/parser_test.php
new file mode 100644
index 0000000000..729fe93fc2
--- /dev/null
+++ b/tests/bbcode/parser_test.php
@@ -0,0 +1,31 @@
+<?php
+/**
+*
+* @package testing
+* @version $Id$
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+define('IN_PHPBB', true);
+
+require_once 'test_framework/framework.php';
+require_once '../phpBB/includes/bbcode/bbcode_parser_base.php';
+require_once '../phpBB/includes/bbcode/bbcode_parser.php';
+
+class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase
+{
+ public function test_both_passes()
+ {
+ $parser = new phpbb_bbcode_parser();
+
+ $result = $parser->first_pass('[i]Italic [u]underlined text[/u][/i]');
+ $result = $parser->second_pass($result);
+
+ $expected = '<span style="font-style: italic">Italic <span style="text-decoration: underline">underlined text</span></span>';
+
+ $this->assertEquals($expected, $result, 'Simple nested BBCode first+second pass');
+ }
+}
+?> \ No newline at end of file
diff --git a/tests/request/request_class.php b/tests/request/request_class.php
new file mode 100644
index 0000000000..e8c2154bab
--- /dev/null
+++ b/tests/request/request_class.php
@@ -0,0 +1,74 @@
+<?php
+/**
+*
+* @package testing
+* @version $Id$
+* @copyright (c) 2008 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+define('IN_PHPBB', true);
+
+require_once 'test_framework/framework.php';
+
+require_once '../phpBB/includes/functions.php';
+
+class phpbb_request_request_class_test extends phpbb_test_case
+{
+ protected function setUp()
+ {
+ $_POST['test'] = 1;
+ $_GET['test'] = 2;
+ $_COOKIE['test'] = 3;
+ $_REQUEST['test'] = 3;
+
+ // reread data from super globals
+ request::reset();
+ }
+
+ public function test_toggle_super_globals()
+ {
+ // toggle super globals
+ request::disable_super_globals();
+ request::enable_super_globals();
+
+ $this->assertEquals(1, $_POST['test'], 'Checking $_POST toggling via request::dis/enable_super_globals');
+ $this->assertEquals(2, $_GET['test'], 'Checking $_GET toggling via request::dis/enable_super_globals');
+ $this->assertEquals(3, $_COOKIE['test'], 'Checking $_COOKIE toggling via request::dis/enable_super_globals');
+ $this->assertEquals(3, $_REQUEST['test'], 'Checking $_REQUEST toggling via request::dis/enable_super_globals');
+
+ $_POST['x'] = 2;
+ $this->assertEquals($_POST, $GLOBALS['_POST'], 'Checking whether $_POST can still be accessed via $GLOBALS[\'_POST\']');
+ }
+
+ /**
+ * Checks that directly accessing $_POST will trigger
+ * an error.
+ */
+ public function test_disable_post_super_global()
+ {
+ request::disable_super_globals();
+
+ $this->setExpectedTriggerError(E_USER_ERROR);
+ $_POST['test'] = 3;
+ }
+
+ public function test_is_set_post()
+ {
+ $_GET['unset'] = '';
+ request::reset();
+
+ $this->assertTrue(request::is_set_post('test'));
+ $this->assertFalse(request::is_set_post('unset'));
+ }
+
+ /**
+ * Makes sure super globals work properly after these tests
+ */
+ protected function tearDown()
+ {
+ request::enable_super_globals();
+ request::reset();
+ }
+} \ No newline at end of file
diff --git a/tests/request/request_var.php b/tests/request/request_var.php
index b1dacef3fd..0f24d77034 100644
--- a/tests/request/request_var.php
+++ b/tests/request/request_var.php
@@ -73,6 +73,45 @@ class phpbb_request_request_var_test extends phpbb_test_case
unset($_GET[$var], $_POST[$var], $_REQUEST[$var], $_COOKIE[$var]);
}
+ /**
+ * @dataProvider deep_access
+ * Only possible with 3.1.x (later)
+ public function test_deep_multi_dim_array_access($path, $default, $expected)
+ {
+ $this->unset_variables('var');
+
+ $_REQUEST['var'] = array(
+ 0 => array(
+ 'b' => array(
+ true => array(
+ 5 => 'c',
+ 6 => 'd',
+ ),
+ ),
+ ),
+ 2 => array(
+ 3 => array(
+ false => 5,
+ ),
+ ),
+ );
+
+ $result = request_var($path, $default);
+ $this->assertEquals($expected, $result, 'Testing deep access to multidimensional input arrays: ' . $path);
+ }
+
+ public static function deep_access()
+ {
+ return array(
+ // array(path, default, expected result)
+ array(array('var', 0, 'b', true, 5), '', 'c'),
+ array(array('var', 0, 'b', true, 6), '', 'd'),
+ array(array('var', 2, 3, false), 0, 5),
+ array(array('var', 0, 'b', true), array(0 => ''), array(5 => 'c', 6 => 'd')),
+ );
+ }
+*/
+
public static function request_variables()
{
return array(
@@ -173,6 +212,52 @@ class phpbb_request_request_var_test extends phpbb_test_case
'abc' => array()
)
),
+ /* 3-dimensional (not supported atm!
+ array(
+ // input:
+ array(
+ 0 => array(0 => array(3, '4', 'ab'), 1 => array()),
+ 1 => array(array(3, 4)),
+ ),
+ // default:
+ array(0 => array(0 => array(0))),
+ false,
+ // expected:
+ array(
+ 0 => array(0 => array(3, 4, 0), 1 => array()),
+ 1 => array(array(3, 4))
+ )
+ ),
+ array(
+ // input:
+ array(
+ 'ü' => array(array('c' => 'd')),
+ 'ä' => array(4 => array('a' => 2, 'ö' => 3)),
+ ),
+ // default:
+ array('' => array(0 => array('' => 0))),
+ false,
+ // expected:
+ array(
+ '??' => array(4 => array('a' => 2, '??' => 3)),
+ )
+ ),
+ array(
+ // input:
+ array(
+ 'ü' => array(array('c' => 'd')),
+ 'ä' => array(4 => array('a' => 2, 'ö' => 3)),
+ ),
+ // default:
+ array('' => array(0 => array('' => 0))),
+ true,
+ // expected:
+ array(
+ 'ü' => array(array('c' => 0)),
+ 'ä' => array(4 => array('a' => 2, 'ö' => 3)),
+ )
+ ),
+ */
);
}
diff --git a/tests/template/template.php b/tests/template/template.php
index 145fe8de61..9436ab2d98 100644
--- a/tests/template/template.php
+++ b/tests/template/template.php
@@ -17,20 +17,12 @@ class phpbb_template_template_test extends phpbb_test_case
private $template_path;
// Keep the contents of the cache for debugging?
- const PRESERVE_CACHE = true;
+ const PRESERVE_CACHE = false;
private function display($handle)
{
- // allow the templates to throw notices
- $error_level = error_reporting();
- error_reporting($error_level & ~E_NOTICE);
-
ob_start();
$this->assertTrue($this->template->display($handle, false));
-
- // reset error level
- error_reporting($error_level);
-
return self::trim_template_result(ob_get_clean());
}
diff --git a/tests/template/templates/includephp.html b/tests/template/templates/includephp.html
index 3e13fa33fa..42c78b9377 100644
--- a/tests/template/templates/includephp.html
+++ b/tests/template/templates/includephp.html
@@ -1 +1 @@
-<!-- INCLUDEPHP ../templates/_dummy_include.php -->
+<!-- INCLUDEPHP _dummy_include.php -->
diff --git a/tests/template/templates/loop_expressions.html b/tests/template/templates/loop_expressions.html
new file mode 100644
index 0000000000..6bff53f388
--- /dev/null
+++ b/tests/template/templates/loop_expressions.html
@@ -0,0 +1,11 @@
+<!-- BEGIN loop -->
+
+<!-- IF loop.S_ROW_NUM is even by 4 -->on<!-- ELSE -->off<!-- ENDIF -->
+
+<!-- END loop -->
+
+<!-- BEGIN loop -->
+
+<!-- IF loop.S_ROW_NUM is odd by 3 -->on<!-- ELSE -->off<!-- ENDIF -->
+
+<!-- END loop -->