Merge pull request #165 from marc1706/feature/tests

[feature/tests] add unit testing framework
This commit is contained in:
Marc Alexander
2013-10-29 08:22:02 -07:00
34 changed files with 14652 additions and 3 deletions

3
.gitignore vendored
View File

@@ -1 +1,2 @@
/.idea/* /.idea/*
/tests/test_config.php

44
.travis.yml Normal file
View File

@@ -0,0 +1,44 @@
language: php
php:
- 5.3.3
- 5.3
- 5.4
- 5.5
env:
- DB=mysql
- DB=postgres
before_script:
# checkout phpBB and move your extension in place
- cd ../../
- git clone "git://github.com/phpbb/phpbb3.git" "phpBB3"
- mkdir phpBB3/phpBB/ext
# - mkdir phpBB3/phpBB/ext/board3
- find -type d -name "Board3-Portal" -print | xargs -i mv {} phpBB3/phpBB/ext/board3
# - mv board3/Board3-Portal phpBB3/phpBB/ext/board3
# Setup the dependencies
- cd phpBB3/phpBB
- php ../composer.phar install --dev --no-interaction --prefer-source
# Setup the tests/travis
- cd ext/board3
- 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"
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'create database IF NOT EXISTS phpbb_tests;'; fi"
- ls -l
- travis/install-php-extensions.sh
- phpenv rehash
- sh -c "if [ `php -r "echo (int) version_compare(PHP_VERSION, '5.3.19', '>=');"` = "1" ]; then travis/setup-webserver.sh; fi"
script:
- ../../vendor/bin/phpunit --configuration travis/phpunit-$DB-travis.xml
notifications:
email:
recipients:
- nickvergessen@gmx.de
- admin@m-a-styles.de
on_success: change
on_failure: change

View File

@@ -1,6 +1,6 @@
#Board3 Portal 2.1.0 #Board3 Portal 2.1.x
Board Portal 2.1.0 is a second generation portal for phpBB 3.1.x. It adds a portal with several blocks to your forum. Board Portal 2.1.x is a second generation portal for phpBB 3.1.x. It adds a portal with several blocks to your forum.
You can change the settings, move the blocks, add new blocks and more in the ACP. You can change the settings, move the blocks, add new blocks and more in the ACP.
##How to use ##How to use

23
composer.json Normal file
View File

@@ -0,0 +1,23 @@
{
"name": "phpbbgallery/core",
"type": "phpbb-extension",
"description": "Experimental version of phpBB Gallery for phpBB 3.1",
"homepage": "https://github.com/nickvergessen/phpbb-ext-gallery",
"version": "0.1.0",
"time": "2013-03-27",
"licence": "GPL-2.0",
"authors": [{
"name": "Joas Schilling",
"username": "nickvergessen",
"email": "nickvergessen@gmx.de",
"homepage": "https://github.com/nickvergessen/",
"role": "Lead Developer"
}],
"require": {
"php": ">=5.3.3",
"phpbb/phpbb": "3.1.*@dev"
},
"extra": {
"display-name": "phpBB Gallery Core"
}
}

View File

@@ -0,0 +1,720 @@
<?php
/**
*
* @package phpBB3
* @copyright (c) 2006 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
* This file creates new schema files for every database.
* The filenames will be prefixed with an underscore to not overwrite the current schema files.
*
* If you overwrite the original schema files please make sure you save the file with UNIX linefeeds.
*/
$schema_path = dirname(__FILE__) . '/../tests/schemas/';
$phpbb_root_path = dirname(__FILE__) . '/../../../../';
if (!is_writable($schema_path))
{
die('Schema path not writable');
}
define('IN_PHPBB', true);
require($phpbb_root_path . 'includes/db/schema_data.php');
require(dirname(__FILE__) . '/schema_data.php');
require($phpbb_root_path . 'phpbb/db/tools.php');
$dbms_type_map = phpbb\db\tools::get_dbms_type_map();
// A list of types being unsigned for better reference in some db's
$unsigned_types = array('UINT', 'UINT:', 'USINT', 'BOOL', 'TIMESTAMP');
$supported_dbms = array('firebird', 'mssql', 'mysql_40', 'mysql_41', 'oracle', 'postgres', 'sqlite');
foreach ($supported_dbms as $dbms)
{
$fp = fopen($schema_path . $dbms . '_schema.sql', 'wb');
$line = '';
// Write Header
switch ($dbms)
{
case 'mysql_40':
case 'mysql_41':
case 'firebird':
case 'sqlite':
fwrite($fp, "# DO NOT EDIT THIS FILE, IT IS GENERATED\n");
fwrite($fp, "#\n");
fwrite($fp, "# To change the contents of this file, edit\n");
fwrite($fp, "# phpBB/develop/create_schema_files.php and\n");
fwrite($fp, "# run it.\n");
break;
case 'mssql':
case 'oracle':
case 'postgres':
fwrite($fp, "/*\n");
fwrite($fp, " * DO NOT EDIT THIS FILE, IT IS GENERATED\n");
fwrite($fp, " *\n");
fwrite($fp, " * To change the contents of this file, edit\n");
fwrite($fp, " * phpBB/develop/create_schema_files.php and\n");
fwrite($fp, " * run it.\n");
fwrite($fp, " */\n\n");
break;
}
switch ($dbms)
{
case 'firebird':
$line .= custom_data('firebird') . "\n";
break;
case 'sqlite':
$line .= "BEGIN TRANSACTION;\n\n";
break;
case 'oracle':
$line .= custom_data('oracle') . "\n";
break;
case 'postgres':
$line .= "BEGIN;\n\n";
$line .= custom_data('postgres') . "\n";
break;
}
fwrite($fp, $line);
foreach ($schema_data as $table_name => $table_data)
{
// Write comment about table
switch ($dbms)
{
case 'mysql_40':
case 'mysql_41':
case 'firebird':
case 'sqlite':
fwrite($fp, "# Table: '{$table_name}'\n");
break;
case 'mssql':
case 'oracle':
case 'postgres':
fwrite($fp, "/*\n\tTable: '{$table_name}'\n*/\n");
break;
}
// Create Table statement
$generator = $textimage = false;
$line = '';
switch ($dbms)
{
case 'mysql_40':
case 'mysql_41':
case 'firebird':
case 'oracle':
case 'sqlite':
case 'postgres':
$line = "CREATE TABLE {$table_name} (\n";
break;
case 'mssql':
$line = "CREATE TABLE [{$table_name}] (\n";
break;
}
// Table specific so we don't get overlap
$modded_array = array();
// Write columns one by one...
foreach ($table_data['COLUMNS'] as $column_name => $column_data)
{
if (strlen($column_name) > 30)
{
trigger_error("Column name '$column_name' on table '$table_name' is too long. The maximum is 30 characters.", E_USER_ERROR);
}
if (isset($column_data[2]) && $column_data[2] == 'auto_increment' && strlen($column_name) > 26) // "${column_name}_gen"
{
trigger_error("Index name '${column_name}_gen' on table '$table_name' is too long. The maximum is 30 characters.", E_USER_ERROR);
}
// Get type
if (strpos($column_data[0], ':') !== false)
{
list($orig_column_type, $column_length) = explode(':', $column_data[0]);
if (!is_array($dbms_type_map[$dbms][$orig_column_type . ':']))
{
$column_type = sprintf($dbms_type_map[$dbms][$orig_column_type . ':'], $column_length);
}
else
{
if (isset($dbms_type_map[$dbms][$orig_column_type . ':']['rule']))
{
switch ($dbms_type_map[$dbms][$orig_column_type . ':']['rule'][0])
{
case 'div':
$column_length /= $dbms_type_map[$dbms][$orig_column_type . ':']['rule'][1];
$column_length = ceil($column_length);
$column_type = sprintf($dbms_type_map[$dbms][$orig_column_type . ':'][0], $column_length);
break;
}
}
if (isset($dbms_type_map[$dbms][$orig_column_type . ':']['limit']))
{
switch ($dbms_type_map[$dbms][$orig_column_type . ':']['limit'][0])
{
case 'mult':
$column_length *= $dbms_type_map[$dbms][$orig_column_type . ':']['limit'][1];
if ($column_length > $dbms_type_map[$dbms][$orig_column_type . ':']['limit'][2])
{
$column_type = $dbms_type_map[$dbms][$orig_column_type . ':']['limit'][3];
$modded_array[$column_name] = $column_type;
}
else
{
$column_type = sprintf($dbms_type_map[$dbms][$orig_column_type . ':'][0], $column_length);
}
break;
}
}
}
$orig_column_type .= ':';
}
else
{
$orig_column_type = $column_data[0];
$column_type = $dbms_type_map[$dbms][$column_data[0]];
if ($column_type == 'text' || $column_type == 'blob')
{
$modded_array[$column_name] = $column_type;
}
}
// Adjust default value if db-dependent specified
if (is_array($column_data[1]))
{
$column_data[1] = (isset($column_data[1][$dbms])) ? $column_data[1][$dbms] : $column_data[1]['default'];
}
switch ($dbms)
{
case 'mysql_40':
case 'mysql_41':
$line .= "\t{$column_name} {$column_type} ";
// For hexadecimal values do not use single quotes
if (!is_null($column_data[1]) && substr($column_type, -4) !== 'text' && substr($column_type, -4) !== 'blob')
{
$line .= (strpos($column_data[1], '0x') === 0) ? "DEFAULT {$column_data[1]} " : "DEFAULT '{$column_data[1]}' ";
}
$line .= 'NOT NULL';
if (isset($column_data[2]))
{
if ($column_data[2] == 'auto_increment')
{
$line .= ' auto_increment';
}
else if ($dbms === 'mysql_41' && $column_data[2] == 'true_sort')
{
$line .= ' COLLATE utf8_unicode_ci';
}
}
$line .= ",\n";
break;
case 'sqlite':
if (isset($column_data[2]) && $column_data[2] == 'auto_increment')
{
$line .= "\t{$column_name} INTEGER PRIMARY KEY ";
$generator = $column_name;
}
else
{
$line .= "\t{$column_name} {$column_type} ";
}
$line .= 'NOT NULL ';
$line .= (!is_null($column_data[1])) ? "DEFAULT '{$column_data[1]}'" : '';
$line .= ",\n";
break;
case 'firebird':
$line .= "\t{$column_name} {$column_type} ";
if (!is_null($column_data[1]))
{
$line .= 'DEFAULT ' . ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ' ';
}
$line .= 'NOT NULL';
// This is a UNICODE column and thus should be given it's fair share
if (preg_match('/^X?STEXT_UNI|VCHAR_(CI|UNI:?)/', $column_data[0]))
{
$line .= ' COLLATE UNICODE';
}
$line .= ",\n";
if (isset($column_data[2]) && $column_data[2] == 'auto_increment')
{
$generator = $column_name;
}
break;
case 'mssql':
if ($column_type == '[text]')
{
$textimage = true;
}
$line .= "\t[{$column_name}] {$column_type} ";
if (!is_null($column_data[1]))
{
// For hexadecimal values do not use single quotes
if (strpos($column_data[1], '0x') === 0)
{
$line .= 'DEFAULT (' . $column_data[1] . ') ';
}
else
{
$line .= 'DEFAULT (' . ((is_numeric($column_data[1])) ? $column_data[1] : "'{$column_data[1]}'") . ') ';
}
}
if (isset($column_data[2]) && $column_data[2] == 'auto_increment')
{
$line .= 'IDENTITY (1, 1) ';
}
$line .= 'NOT NULL';
$line .= " ,\n";
break;
case 'oracle':
$line .= "\t{$column_name} {$column_type} ";
$line .= (!is_null($column_data[1])) ? "DEFAULT '{$column_data[1]}' " : '';
// In Oracle empty strings ('') are treated as NULL.
// Therefore in oracle we allow NULL's for all DEFAULT '' entries
$line .= ($column_data[1] === '') ? ",\n" : "NOT NULL,\n";
if (isset($column_data[2]) && $column_data[2] == 'auto_increment')
{
$generator = $column_name;
}
break;
case 'postgres':
$line .= "\t{$column_name} {$column_type} ";
if (isset($column_data[2]) && $column_data[2] == 'auto_increment')
{
$line .= "DEFAULT nextval('{$table_name}_seq'),\n";
// Make sure the sequence will be created before creating the table
$line = "CREATE SEQUENCE {$table_name}_seq;\n\n" . $line;
}
else
{
$line .= (!is_null($column_data[1])) ? "DEFAULT '{$column_data[1]}' " : '';
$line .= "NOT NULL";
// Unsigned? Then add a CHECK contraint
if (in_array($orig_column_type, $unsigned_types))
{
$line .= " CHECK ({$column_name} >= 0)";
}
$line .= ",\n";
}
break;
}
}
switch ($dbms)
{
case 'firebird':
// Remove last line delimiter...
$line = substr($line, 0, -2);
$line .= "\n);;\n\n";
break;
case 'mssql':
$line = substr($line, 0, -2);
$line .= "\n) ON [PRIMARY]" . (($textimage) ? ' TEXTIMAGE_ON [PRIMARY]' : '') . "\n";
$line .= "GO\n\n";
break;
}
// Write primary key
if (isset($table_data['PRIMARY_KEY']))
{
if (!is_array($table_data['PRIMARY_KEY']))
{
$table_data['PRIMARY_KEY'] = array($table_data['PRIMARY_KEY']);
}
switch ($dbms)
{
case 'mysql_40':
case 'mysql_41':
case 'postgres':
$line .= "\tPRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . "),\n";
break;
case 'firebird':
$line .= "ALTER TABLE {$table_name} ADD PRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . ");;\n\n";
break;
case 'sqlite':
if ($generator === false || !in_array($generator, $table_data['PRIMARY_KEY']))
{
$line .= "\tPRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . "),\n";
}
break;
case 'mssql':
$line .= "ALTER TABLE [{$table_name}] WITH NOCHECK ADD \n";
$line .= "\tCONSTRAINT [PK_{$table_name}] PRIMARY KEY CLUSTERED \n";
$line .= "\t(\n";
$line .= "\t\t[" . implode("],\n\t\t[", $table_data['PRIMARY_KEY']) . "]\n";
$line .= "\t) ON [PRIMARY] \n";
$line .= "GO\n\n";
break;
case 'oracle':
$line .= "\tCONSTRAINT pk_{$table_name} PRIMARY KEY (" . implode(', ', $table_data['PRIMARY_KEY']) . "),\n";
break;
}
}
switch ($dbms)
{
case 'oracle':
// UNIQUE contrains to be added?
if (isset($table_data['KEYS']))
{
foreach ($table_data['KEYS'] as $key_name => $key_data)
{
if (!is_array($key_data[1]))
{
$key_data[1] = array($key_data[1]);
}
if ($key_data[0] == 'UNIQUE')
{
$line .= "\tCONSTRAINT u_phpbb_{$key_name} UNIQUE (" . implode(', ', $key_data[1]) . "),\n";
}
}
}
// Remove last line delimiter...
$line = substr($line, 0, -2);
$line .= "\n)\n/\n\n";
break;
case 'postgres':
// Remove last line delimiter...
$line = substr($line, 0, -2);
$line .= "\n);\n\n";
break;
case 'sqlite':
// Remove last line delimiter...
$line = substr($line, 0, -2);
$line .= "\n);\n\n";
break;
}
// Write Keys
if (isset($table_data['KEYS']))
{
foreach ($table_data['KEYS'] as $key_name => $key_data)
{
if (!is_array($key_data[1]))
{
$key_data[1] = array($key_data[1]);
}
if (strlen($table_name . $key_name) > 30)
{
trigger_error("Index name '${table_name}_$key_name' on table '$table_name' is too long. The maximum is 30 characters.", E_USER_ERROR);
}
switch ($dbms)
{
case 'mysql_40':
case 'mysql_41':
$line .= ($key_data[0] == 'INDEX') ? "\tKEY" : '';
$line .= ($key_data[0] == 'UNIQUE') ? "\tUNIQUE" : '';
foreach ($key_data[1] as $key => $col_name)
{
if (isset($modded_array[$col_name]))
{
switch ($modded_array[$col_name])
{
case 'text':
case 'blob':
$key_data[1][$key] = $col_name . '(255)';
break;
}
}
}
$line .= ' ' . $key_name . ' (' . implode(', ', $key_data[1]) . "),\n";
break;
case 'firebird':
$line .= ($key_data[0] == 'INDEX') ? 'CREATE INDEX' : '';
$line .= ($key_data[0] == 'UNIQUE') ? 'CREATE UNIQUE INDEX' : '';
$line .= ' ' . $table_name . '_' . $key_name . ' ON ' . $table_name . '(' . implode(', ', $key_data[1]) . ");;\n";
break;
case 'mssql':
$line .= ($key_data[0] == 'INDEX') ? 'CREATE INDEX' : '';
$line .= ($key_data[0] == 'UNIQUE') ? 'CREATE UNIQUE INDEX' : '';
$line .= " [{$key_name}] ON [{$table_name}]([" . implode('], [', $key_data[1]) . "]) ON [PRIMARY]\n";
$line .= "GO\n\n";
break;
case 'oracle':
if ($key_data[0] == 'UNIQUE')
{
continue;
}
$line .= ($key_data[0] == 'INDEX') ? 'CREATE INDEX' : '';
$line .= " {$table_name}_{$key_name} ON {$table_name} (" . implode(', ', $key_data[1]) . ")\n";
$line .= "/\n";
break;
case 'sqlite':
$line .= ($key_data[0] == 'INDEX') ? 'CREATE INDEX' : '';
$line .= ($key_data[0] == 'UNIQUE') ? 'CREATE UNIQUE INDEX' : '';
$line .= " {$table_name}_{$key_name} ON {$table_name} (" . implode(', ', $key_data[1]) . ");\n";
break;
case 'postgres':
$line .= ($key_data[0] == 'INDEX') ? 'CREATE INDEX' : '';
$line .= ($key_data[0] == 'UNIQUE') ? 'CREATE UNIQUE INDEX' : '';
$line .= " {$table_name}_{$key_name} ON {$table_name} (" . implode(', ', $key_data[1]) . ");\n";
break;
}
}
}
switch ($dbms)
{
case 'mysql_40':
// Remove last line delimiter...
$line = substr($line, 0, -2);
$line .= "\n);\n\n";
break;
case 'mysql_41':
// Remove last line delimiter...
$line = substr($line, 0, -2);
$line .= "\n) CHARACTER SET `utf8` COLLATE `utf8_bin`;\n\n";
break;
// Create Generator
case 'firebird':
if ($generator !== false)
{
$line .= "\nCREATE GENERATOR {$table_name}_gen;;\n";
$line .= 'SET GENERATOR ' . $table_name . "_gen TO 0;;\n\n";
$line .= 'CREATE TRIGGER t_' . $table_name . ' FOR ' . $table_name . "\n";
$line .= "BEFORE INSERT\nAS\nBEGIN\n";
$line .= "\tNEW.{$generator} = GEN_ID({$table_name}_gen, 1);\nEND;;\n\n";
}
break;
case 'oracle':
if ($generator !== false)
{
$line .= "\nCREATE SEQUENCE {$table_name}_seq\n/\n\n";
$line .= "CREATE OR REPLACE TRIGGER t_{$table_name}\n";
$line .= "BEFORE INSERT ON {$table_name}\n";
$line .= "FOR EACH ROW WHEN (\n";
$line .= "\tnew.{$generator} IS NULL OR new.{$generator} = 0\n";
$line .= ")\nBEGIN\n";
$line .= "\tSELECT {$table_name}_seq.nextval\n";
$line .= "\tINTO :new.{$generator}\n";
$line .= "\tFROM dual;\nEND;\n/\n\n";
}
break;
}
fwrite($fp, $line . "\n");
}
$line = '';
// Write custom function at the end for some db's
switch ($dbms)
{
case 'mssql':
// No need to do this, no transaction support for schema changes
//$line = "\nCOMMIT\nGO\n\n";
break;
case 'sqlite':
$line = "\nCOMMIT;";
break;
case 'postgres':
$line = "\nCOMMIT;";
break;
}
fwrite($fp, $line);
fclose($fp);
}
/**
* Data put into the header for various dbms
*/
function custom_data($dbms)
{
switch ($dbms)
{
case 'oracle':
return <<<EOF
/*
This first section is optional, however its probably the best method
of running phpBB on Oracle. If you already have a tablespace and user created
for phpBB you can leave this section commented out!
The first set of statements create a phpBB tablespace and a phpBB user,
make sure you change the password of the phpBB user before you run this script!!
*/
/*
CREATE TABLESPACE "PHPBB"
LOGGING
DATAFILE 'E:\ORACLE\ORADATA\LOCAL\PHPBB.ora'
SIZE 10M
AUTOEXTEND ON NEXT 10M
MAXSIZE 100M;
CREATE USER "PHPBB"
PROFILE "DEFAULT"
IDENTIFIED BY "phpbb_password"
DEFAULT TABLESPACE "PHPBB"
QUOTA UNLIMITED ON "PHPBB"
ACCOUNT UNLOCK;
GRANT ANALYZE ANY TO "PHPBB";
GRANT CREATE SEQUENCE TO "PHPBB";
GRANT CREATE SESSION TO "PHPBB";
GRANT CREATE TABLE TO "PHPBB";
GRANT CREATE TRIGGER TO "PHPBB";
GRANT CREATE VIEW TO "PHPBB";
GRANT "CONNECT" TO "PHPBB";
COMMIT;
DISCONNECT;
CONNECT phpbb/phpbb_password;
*/
EOF;
break;
case 'postgres':
return <<<EOF
/*
Domain definition
*/
CREATE DOMAIN varchar_ci AS varchar(255) NOT NULL DEFAULT ''::character varying;
/*
Operation Functions
*/
CREATE FUNCTION _varchar_ci_equal(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) = LOWER($2)' LANGUAGE SQL STRICT;
CREATE FUNCTION _varchar_ci_not_equal(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) != LOWER($2)' LANGUAGE SQL STRICT;
CREATE FUNCTION _varchar_ci_less_than(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) < LOWER($2)' LANGUAGE SQL STRICT;
CREATE FUNCTION _varchar_ci_less_equal(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) <= LOWER($2)' LANGUAGE SQL STRICT;
CREATE FUNCTION _varchar_ci_greater_than(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) > LOWER($2)' LANGUAGE SQL STRICT;
CREATE FUNCTION _varchar_ci_greater_equals(varchar_ci, varchar_ci) RETURNS boolean AS 'SELECT LOWER($1) >= LOWER($2)' LANGUAGE SQL STRICT;
/*
Operators
*/
CREATE OPERATOR <(
PROCEDURE = _varchar_ci_less_than,
LEFTARG = varchar_ci,
RIGHTARG = varchar_ci,
COMMUTATOR = >,
NEGATOR = >=,
RESTRICT = scalarltsel,
JOIN = scalarltjoinsel);
CREATE OPERATOR <=(
PROCEDURE = _varchar_ci_less_equal,
LEFTARG = varchar_ci,
RIGHTARG = varchar_ci,
COMMUTATOR = >=,
NEGATOR = >,
RESTRICT = scalarltsel,
JOIN = scalarltjoinsel);
CREATE OPERATOR >(
PROCEDURE = _varchar_ci_greater_than,
LEFTARG = varchar_ci,
RIGHTARG = varchar_ci,
COMMUTATOR = <,
NEGATOR = <=,
RESTRICT = scalargtsel,
JOIN = scalargtjoinsel);
CREATE OPERATOR >=(
PROCEDURE = _varchar_ci_greater_equals,
LEFTARG = varchar_ci,
RIGHTARG = varchar_ci,
COMMUTATOR = <=,
NEGATOR = <,
RESTRICT = scalargtsel,
JOIN = scalargtjoinsel);
CREATE OPERATOR <>(
PROCEDURE = _varchar_ci_not_equal,
LEFTARG = varchar_ci,
RIGHTARG = varchar_ci,
COMMUTATOR = <>,
NEGATOR = =,
RESTRICT = neqsel,
JOIN = neqjoinsel);
CREATE OPERATOR =(
PROCEDURE = _varchar_ci_equal,
LEFTARG = varchar_ci,
RIGHTARG = varchar_ci,
COMMUTATOR = =,
NEGATOR = <>,
RESTRICT = eqsel,
JOIN = eqjoinsel,
HASHES,
MERGES,
SORT1= <);
EOF;
break;
}
return '';
}
echo 'done';

324
develop/schema_data.php Normal file
View File

@@ -0,0 +1,324 @@
<?php
/**
*
* @package dbal
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Define the basic structure
* The format:
* array('{TABLE_NAME}' => {TABLE_DATA})
* {TABLE_DATA}:
* COLUMNS = array({column_name} = array({column_type}, {default}, {auto_increment}))
* PRIMARY_KEY = {column_name(s)}
* KEYS = array({key_name} = array({key_type}, {column_name(s)})),
*
* Column Types:
* INT:x => SIGNED int(x)
* BINT => BIGINT
* UINT => mediumint(8) UNSIGNED
* UINT:x => int(x) UNSIGNED
* TINT:x => tinyint(x)
* USINT => smallint(4) UNSIGNED (for _order columns)
* BOOL => tinyint(1) UNSIGNED
* VCHAR => varchar(255)
* CHAR:x => char(x)
* XSTEXT_UNI => text for storing 100 characters (topic_title for example)
* STEXT_UNI => text for storing 255 characters (normal input field with a max of 255 single-byte chars) - same as VCHAR_UNI
* TEXT_UNI => text for storing 3000 characters (short text, descriptions, comments, etc.)
* MTEXT_UNI => mediumtext (post text, large text)
* VCHAR:x => varchar(x)
* TIMESTAMP => int(11) UNSIGNED
* DECIMAL => decimal number (5,2)
* DECIMAL: => decimal number (x,2)
* PDECIMAL => precision decimal number (6,3)
* PDECIMAL: => precision decimal number (x,3)
* VCHAR_UNI => varchar(255) BINARY
* VCHAR_CI => varchar_ci for postgresql, others VCHAR
*/
/**
* Step 1: Manipulate phpbb's tables
*/
$schema_data['phpbb_log']['COLUMNS']['album_id'] = array('UINT', 0);
$schema_data['phpbb_log']['COLUMNS']['image_id'] = array('UINT', 0);
$schema_data['phpbb_sessions']['COLUMNS']['session_album_id'] = array('UINT', 0);
$schema_data['phpbb_sessions']['KEYS']['session_aid'] = array('INDEX', 'session_album_id');
/**
* Step 2: Add own tables
*/
$schema_data['phpbb_gallery_albums'] = array(
'COLUMNS' => array(
'album_id' => array('UINT', NULL, 'auto_increment'),
'parent_id' => array('UINT', 0),
'left_id' => array('UINT', 1),
'right_id' => array('UINT', 2),
'album_parents' => array('MTEXT_UNI', ''),
'album_type' => array('UINT:3', 1),
'album_status' => array('UINT:1', 1),
'album_contest' => array('UINT', 0),
'album_name' => array('VCHAR:255', ''),
'album_desc' => array('MTEXT_UNI', ''),
'album_desc_options' => array('UINT:3', 7),
'album_desc_uid' => array('VCHAR:8', ''),
'album_desc_bitfield' => array('VCHAR:255', ''),
'album_user_id' => array('UINT', 0),
'album_images' => array('UINT', 0),
'album_images_real' => array('UINT', 0),
'album_last_image_id' => array('UINT', 0),
'album_image' => array('VCHAR', ''),
'album_last_image_time' => array('INT:11', 0),
'album_last_image_name' => array('VCHAR', ''),
'album_last_username' => array('VCHAR', ''),
'album_last_user_colour' => array('VCHAR:6', ''),
'album_last_user_id' => array('UINT', 0),
'album_watermark' => array('UINT:1', 1),
'album_sort_key' => array('VCHAR:8', ''),
'album_sort_dir' => array('VCHAR:8', ''),
'display_in_rrc' => array('UINT:1', 1),
'display_on_index' => array('UINT:1', 1),
'display_subalbum_list' => array('UINT:1', 1),
'album_feed' => array('BOOL', 1),
'album_auth_access' => array('TINT:1', 0),
),
'PRIMARY_KEY' => 'album_id',
);
$schema_data['phpbb_gallery_albums_track'] = array(
'COLUMNS' => array(
'user_id' => array('UINT', 0),
'album_id' => array('UINT', 0),
'mark_time' => array('TIMESTAMP', 0),
),
'PRIMARY_KEY' => array('user_id', 'album_id'),
);
$schema_data['phpbb_gallery_comments'] = array(
'COLUMNS' => array(
'comment_id' => array('UINT', NULL, 'auto_increment'),
'comment_image_id' => array('UINT', NULL),
'comment_user_id' => array('UINT', 0),
'comment_username' => array('VCHAR', ''),
'comment_user_colour' => array('VCHAR:6', ''),
'comment_user_ip' => array('VCHAR:40', ''),
'comment_signature' => array('BOOL', 0),
'comment_time' => array('UINT:11', 0),
'comment' => array('MTEXT_UNI', ''),
'comment_uid' => array('VCHAR:8', ''),
'comment_bitfield' => array('VCHAR:255', ''),
'comment_edit_time' => array('UINT:11', 0),
'comment_edit_count' => array('USINT', 0),
'comment_edit_user_id' => array('UINT', 0),
),
'PRIMARY_KEY' => 'comment_id',
'KEYS' => array(
'id' => array('INDEX', 'comment_image_id'),
'uid' => array('INDEX', 'comment_user_id'),
'ip' => array('INDEX', 'comment_user_ip'),
'time' => array('INDEX', 'comment_time'),
),
);
$schema_data['phpbb_gallery_contests'] = array(
'COLUMNS' => array(
'contest_id' => array('UINT', NULL, 'auto_increment'),
'contest_album_id' => array('UINT', 0),
'contest_start' => array('UINT:11', 0),
'contest_rating' => array('UINT:11', 0),
'contest_end' => array('UINT:11', 0),
'contest_marked' => array('TINT:1', 0),
'contest_first' => array('UINT', 0),
'contest_second' => array('UINT', 0),
'contest_third' => array('UINT', 0),
),
'PRIMARY_KEY' => 'contest_id',
);
$schema_data['phpbb_gallery_favorites'] = array(
'COLUMNS' => array(
'favorite_id' => array('UINT', NULL, 'auto_increment'),
'user_id' => array('UINT', 0),
'image_id' => array('UINT', 0),
),
'PRIMARY_KEY' => 'favorite_id',
'KEYS' => array(
'uid' => array('INDEX', 'user_id'),
'id' => array('INDEX', 'image_id'),
),
);
$schema_data['phpbb_gallery_images'] = array(
'COLUMNS' => array(
'image_id' => array('UINT', NULL, 'auto_increment'),
'image_filename' => array('VCHAR:255', ''),
'image_name' => array('VCHAR:255', ''),
'image_name_clean' => array('VCHAR:255', ''),
'image_desc' => array('MTEXT_UNI', ''),
'image_desc_uid' => array('VCHAR:8', ''),
'image_desc_bitfield' => array('VCHAR:255', ''),
'image_user_id' => array('UINT', 0),
'image_username' => array('VCHAR:255', ''),
'image_username_clean' => array('VCHAR:255', ''),
'image_user_colour' => array('VCHAR:6', ''),
'image_user_ip' => array('VCHAR:40', ''),
'image_time' => array('UINT:11', 0),
'image_album_id' => array('UINT', 0),
'image_view_count' => array('UINT:11', 0),
'image_status' => array('UINT:3', 0),
'image_contest' => array('UINT:1', 0),
'image_contest_end' => array('TIMESTAMP', 0),
'image_contest_rank' => array('UINT:3', 0),
'image_filemissing' => array('UINT:3', 0),
'image_has_exif' => array('UINT:3', 2),
'image_exif_data' => array('TEXT', ''),
'image_rates' => array('UINT', 0),
'image_rate_points' => array('UINT', 0),
'image_rate_avg' => array('UINT', 0),
'image_comments' => array('UINT', 0),
'image_last_comment' => array('UINT', 0),
'image_allow_comments' => array('TINT:1', 1),
'image_favorited' => array('UINT', 0),
'image_reported' => array('UINT', 0),
'filesize_upload' => array('UINT:20', 0),
'filesize_medium' => array('UINT:20', 0),
'filesize_cache' => array('UINT:20', 0),
),
'PRIMARY_KEY' => 'image_id',
'KEYS' => array(
'aid' => array('INDEX', 'image_album_id'),
'uid' => array('INDEX', 'image_user_id'),
'time' => array('INDEX', 'image_time'),
),
);
$schema_data['phpbb_gallery_modscache'] = array(
'COLUMNS' => array(
'album_id' => array('UINT', 0),
'user_id' => array('UINT', 0),
'username' => array('VCHAR', ''),
'group_id' => array('UINT', 0),
'group_name' => array('VCHAR', ''),
'display_on_index' => array('TINT:1', 1),
),
'KEYS' => array(
'doi' => array('INDEX', 'display_on_index'),
'aid' => array('INDEX', 'album_id'),
),
);
$schema_data['phpbb_gallery_permissions'] = array(
'COLUMNS' => array(
'perm_id' => array('UINT', NULL, 'auto_increment'),
'perm_role_id' => array('UINT', 0),
'perm_album_id' => array('UINT', 0),
'perm_user_id' => array('UINT', 0),
'perm_group_id' => array('UINT', 0),
'perm_system' => array('INT:3', 0),
),
'PRIMARY_KEY' => 'perm_id',
);
$schema_data['phpbb_gallery_rates'] = array(
'COLUMNS' => array(
'rate_image_id' => array('UINT', 0),
'rate_user_id' => array('UINT', 0),
'rate_user_ip' => array('VCHAR:40', ''),
'rate_point' => array('UINT:3', 0),
),
'PRIMARY_KEY' => array('rate_image_id', 'rate_user_id'),
);
$schema_data['phpbb_gallery_reports'] = array(
'COLUMNS' => array(
'report_id' => array('UINT', NULL, 'auto_increment'),
'report_album_id' => array('UINT', 0),
'report_image_id' => array('UINT', 0),
'reporter_id' => array('UINT', 0),
'report_manager' => array('UINT', 0),
'report_note' => array('MTEXT_UNI', ''),
'report_time' => array('UINT:11', 0),
'report_status' => array('UINT:3', 0),
),
'PRIMARY_KEY' => 'report_id',
);
$schema_data['phpbb_gallery_roles'] = array(
'COLUMNS' => array(
'role_id' => array('UINT', NULL, 'auto_increment'),
'a_list' => array('UINT:3', 0),
'i_view' => array('UINT:3', 0),
'i_watermark' => array('UINT:3', 0),
'i_upload' => array('UINT:3', 0),
'i_edit' => array('UINT:3', 0),
'i_delete' => array('UINT:3', 0),
'i_rate' => array('UINT:3', 0),
'i_approve' => array('UINT:3', 0),
'i_lock' => array('UINT:3', 0),
'i_report' => array('UINT:3', 0),
'i_count' => array('UINT', 0),
'i_unlimited' => array('UINT:3', 0),
'c_read' => array('UINT:3', 0),
'c_post' => array('UINT:3', 0),
'c_edit' => array('UINT:3', 0),
'c_delete' => array('UINT:3', 0),
'm_comments' => array('UINT:3', 0),
'm_delete' => array('UINT:3', 0),
'm_edit' => array('UINT:3', 0),
'm_move' => array('UINT:3', 0),
'm_report' => array('UINT:3', 0),
'm_status' => array('UINT:3', 0),
'a_count' => array('UINT', 0),
'a_unlimited' => array('UINT:3', 0),
'a_restrict' => array('UINT:3', 0),
),
'PRIMARY_KEY' => 'role_id',
);
$schema_data['phpbb_gallery_users'] = array(
'COLUMNS' => array(
'user_id' => array('UINT', 0),
'watch_own' => array('UINT:3', 0),
'watch_favo' => array('UINT:3', 0),
'watch_com' => array('UINT:3', 0),
'user_images' => array('UINT', 0),
'personal_album_id' => array('UINT', 0),
'user_lastmark' => array('TIMESTAMP', 0),
'user_last_update' => array('TIMESTAMP', 0),
'user_viewexif' => array('UINT:1', 0),
'user_permissions' => array('MTEXT_UNI', ''),
'user_permissions_changed' => array('TIMESTAMP', 0),
'user_allow_comments' => array('TINT:1', 1),
'subscribe_pegas' => array('TINT:1', 0),
),
'PRIMARY_KEY' => 'user_id',
'KEYS' => array(
'pega' => array('INDEX', array('personal_album_id')),
),
);
$schema_data['phpbb_gallery_watch'] = array(
'COLUMNS' => array(
'watch_id' => array('UINT', NULL, 'auto_increment'),
'album_id' => array('UINT', 0),
'image_id' => array('UINT', 0),
'user_id' => array('UINT', 0),
),
'PRIMARY_KEY' => 'watch_id',
'KEYS' => array(
'uid' => array('INDEX', 'user_id'),
'id' => array('INDEX', 'image_id'),
'aid' => array('INDEX', 'album_id'),
),
);

22
ext.php Normal file
View File

@@ -0,0 +1,22 @@
<?php
/**
*
* @package phpBB Gallery Extension
* @copyright (c) 2013 nickvergessen
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
namespace phpbbgallery\core;
class ext extends \phpbb\extension\base
{
}

View File

@@ -0,0 +1,566 @@
<?php
/**
*
* @package phpBB Gallery Core
* @copyright (c) 2013 nickvergessen
* @license http://opensource.org/licenses/gpl-license.php GNU Public License v2
*
*/
namespace phpbbgallery\core\migrations;
class release_1_1_6 extends \phpbb\db\migration\migration
{
public function effectively_installed()
{
$sql = 'SELECT config_value
FROM ' . $this->table_prefix . "config
WHERE config_name = 'phpbb_gallery_version'";
$result = $this->db->sql_query($sql);
$version = $this->db->sql_fetchfield('config_value');
$this->db->sql_freeresult($result);
return $version && (version_compare($version, '1.1.6') >= 0);
}
static public function depends_on()
{
return array('\phpbb\db\migration\data\v310\dev');
}
public function update_schema()
{
return array(
'add_tables' => array(
$this->table_prefix . 'gallery_albums' => array(
'COLUMNS' => array(
'album_id' => array('UINT', NULL, 'auto_increment'),
'parent_id' => array('UINT', 0),
'left_id' => array('UINT', 1),
'right_id' => array('UINT', 2),
'album_parents' => array('MTEXT_UNI', ''),
'album_type' => array('UINT:3', 1),
'album_status' => array('UINT:1', 1),
'album_contest' => array('UINT', 0),
'album_name' => array('VCHAR:255', ''),
'album_desc' => array('MTEXT_UNI', ''),
'album_desc_options' => array('UINT:3', 7),
'album_desc_uid' => array('VCHAR:8', ''),
'album_desc_bitfield' => array('VCHAR:255', ''),
'album_user_id' => array('UINT', 0),
'album_images' => array('UINT', 0),
'album_images_real' => array('UINT', 0),
'album_last_image_id' => array('UINT', 0),
'album_image' => array('VCHAR', ''),
'album_last_image_time' => array('INT:11', 0),
'album_last_image_name' => array('VCHAR', ''),
'album_last_username' => array('VCHAR', ''),
'album_last_user_colour' => array('VCHAR:6', ''),
'album_last_user_id' => array('UINT', 0),
'album_watermark' => array('UINT:1', 1),
'album_sort_key' => array('VCHAR:8', ''),
'album_sort_dir' => array('VCHAR:8', ''),
'display_in_rrc' => array('UINT:1', 1),
'display_on_index' => array('UINT:1', 1),
'display_subalbum_list' => array('UINT:1', 1),
'album_auth_access' => array('TINT:1', 0),
),
'PRIMARY_KEY' => 'album_id',
),
$this->table_prefix . 'gallery_albums_track' => array(
'COLUMNS' => array(
'user_id' => array('UINT', 0),
'album_id' => array('UINT', 0),
'mark_time' => array('TIMESTAMP', 0),
),
'PRIMARY_KEY' => array('user_id', 'album_id'),
),
$this->table_prefix . 'gallery_comments' => array(
'COLUMNS' => array(
'comment_id' => array('UINT', NULL, 'auto_increment'),
'comment_image_id' => array('UINT', NULL),
'comment_user_id' => array('UINT', 0),
'comment_username' => array('VCHAR', ''),
'comment_user_colour' => array('VCHAR:6', ''),
'comment_user_ip' => array('VCHAR:40', ''),
'comment_signature' => array('BOOL', 0),
'comment_time' => array('UINT:11', 0),
'comment' => array('MTEXT_UNI', ''),
'comment_uid' => array('VCHAR:8', ''),
'comment_bitfield' => array('VCHAR:255', ''),
'comment_edit_time' => array('UINT:11', 0),
'comment_edit_count' => array('USINT', 0),
'comment_edit_user_id' => array('UINT', 0),
),
'PRIMARY_KEY' => 'comment_id',
'KEYS' => array(
'id' => array('INDEX', 'comment_image_id'),
'uid' => array('INDEX', 'comment_user_id'),
'ip' => array('INDEX', 'comment_user_ip'),
'time' => array('INDEX', 'comment_time'),
),
),
$this->table_prefix . 'gallery_contests' => array(
'COLUMNS' => array(
'contest_id' => array('UINT', NULL, 'auto_increment'),
'contest_album_id' => array('UINT', 0),
'contest_start' => array('UINT:11', 0),
'contest_rating' => array('UINT:11', 0),
'contest_end' => array('UINT:11', 0),
'contest_marked' => array('TINT:1', 0),
'contest_first' => array('UINT', 0),
'contest_second' => array('UINT', 0),
'contest_third' => array('UINT', 0),
),
'PRIMARY_KEY' => 'contest_id',
),
$this->table_prefix . 'gallery_favorites' => array(
'COLUMNS' => array(
'favorite_id' => array('UINT', NULL, 'auto_increment'),
'user_id' => array('UINT', 0),
'image_id' => array('UINT', 0),
),
'PRIMARY_KEY' => 'favorite_id',
'KEYS' => array(
'uid' => array('INDEX', 'user_id'),
'id' => array('INDEX', 'image_id'),
),
),
$this->table_prefix . 'gallery_images' => array(
'COLUMNS' => array(
'image_id' => array('UINT', NULL, 'auto_increment'),
'image_filename' => array('VCHAR:255', ''),
'image_name' => array('VCHAR:255', ''),
'image_name_clean' => array('VCHAR:255', ''),
'image_desc' => array('MTEXT_UNI', ''),
'image_desc_uid' => array('VCHAR:8', ''),
'image_desc_bitfield' => array('VCHAR:255', ''),
'image_user_id' => array('UINT', 0),
'image_username' => array('VCHAR:255', ''),
'image_username_clean' => array('VCHAR:255', ''),
'image_user_colour' => array('VCHAR:6', ''),
'image_user_ip' => array('VCHAR:40', ''),
'image_time' => array('UINT:11', 0),
'image_album_id' => array('UINT', 0),
'image_view_count' => array('UINT:11', 0),
'image_status' => array('UINT:3', 0),
'image_contest' => array('UINT:1', 0),
'image_contest_end' => array('TIMESTAMP', 0),
'image_contest_rank' => array('UINT:3', 0),
'image_filemissing' => array('UINT:3', 0),
'image_rates' => array('UINT', 0),
'image_rate_points' => array('UINT', 0),
'image_rate_avg' => array('UINT', 0),
'image_comments' => array('UINT', 0),
'image_last_comment' => array('UINT', 0),
'image_allow_comments' => array('TINT:1', 1),
'image_favorited' => array('UINT', 0),
'image_reported' => array('UINT', 0),
'filesize_upload' => array('UINT:20', 0),
'filesize_medium' => array('UINT:20', 0),
'filesize_cache' => array('UINT:20', 0),
),
'PRIMARY_KEY' => 'image_id',
'KEYS' => array(
'aid' => array('INDEX', 'image_album_id'),
'uid' => array('INDEX', 'image_user_id'),
'time' => array('INDEX', 'image_time'),
),
),
$this->table_prefix . 'gallery_modscache' => array(
'COLUMNS' => array(
'album_id' => array('UINT', 0),
'user_id' => array('UINT', 0),
'username' => array('VCHAR', ''),
'group_id' => array('UINT', 0),
'group_name' => array('VCHAR', ''),
'display_on_index' => array('TINT:1', 1),
),
'KEYS' => array(
'doi' => array('INDEX', 'display_on_index'),
'aid' => array('INDEX', 'album_id'),
),
),
$this->table_prefix . 'gallery_permissions' => array(
'COLUMNS' => array(
'perm_id' => array('UINT', NULL, 'auto_increment'),
'perm_role_id' => array('UINT', 0),
'perm_album_id' => array('UINT', 0),
'perm_user_id' => array('UINT', 0),
'perm_group_id' => array('UINT', 0),
'perm_system' => array('INT:3', 0),
),
'PRIMARY_KEY' => 'perm_id',
),
$this->table_prefix . 'gallery_rates' => array(
'COLUMNS' => array(
'rate_image_id' => array('UINT', 0),
'rate_user_id' => array('UINT', 0),
'rate_user_ip' => array('VCHAR:40', ''),
'rate_point' => array('UINT:3', 0),
),
'PRIMARY_KEY' => array('rate_image_id', 'rate_user_id'),
),
$this->table_prefix . 'gallery_reports' => array(
'COLUMNS' => array(
'report_id' => array('UINT', NULL, 'auto_increment'),
'report_album_id' => array('UINT', 0),
'report_image_id' => array('UINT', 0),
'reporter_id' => array('UINT', 0),
'report_manager' => array('UINT', 0),
'report_note' => array('MTEXT_UNI', ''),
'report_time' => array('UINT:11', 0),
'report_status' => array('UINT:3', 0),
),
'PRIMARY_KEY' => 'report_id',
),
$this->table_prefix . 'gallery_roles' => array(
'COLUMNS' => array(
'role_id' => array('UINT', NULL, 'auto_increment'),
'a_list' => array('UINT:3', 0),
'i_view' => array('UINT:3', 0),
'i_watermark' => array('UINT:3', 0),
'i_upload' => array('UINT:3', 0),
'i_edit' => array('UINT:3', 0),
'i_delete' => array('UINT:3', 0),
'i_rate' => array('UINT:3', 0),
'i_approve' => array('UINT:3', 0),
'i_lock' => array('UINT:3', 0),
'i_report' => array('UINT:3', 0),
'i_count' => array('UINT', 0),
'i_unlimited' => array('UINT:3', 0),
'c_read' => array('UINT:3', 0),
'c_post' => array('UINT:3', 0),
'c_edit' => array('UINT:3', 0),
'c_delete' => array('UINT:3', 0),
'm_comments' => array('UINT:3', 0),
'm_delete' => array('UINT:3', 0),
'm_edit' => array('UINT:3', 0),
'm_move' => array('UINT:3', 0),
'm_report' => array('UINT:3', 0),
'm_status' => array('UINT:3', 0),
'a_count' => array('UINT', 0),
'a_unlimited' => array('UINT:3', 0),
'a_restrict' => array('UINT:3', 0),
),
'PRIMARY_KEY' => 'role_id',
),
$this->table_prefix . 'gallery_users' => array(
'COLUMNS' => array(
'user_id' => array('UINT', 0),
'watch_own' => array('UINT:3', 0),
'watch_favo' => array('UINT:3', 0),
'watch_com' => array('UINT:3', 0),
'user_images' => array('UINT', 0),
'personal_album_id' => array('UINT', 0),
'user_lastmark' => array('TIMESTAMP', 0),
'user_last_update' => array('TIMESTAMP', 0),
'user_permissions' => array('MTEXT_UNI', ''),
'user_permissions_changed' => array('TIMESTAMP', 0),
'user_allow_comments' => array('TINT:1', 1),
'subscribe_pegas' => array('TINT:1', 0),
),
'PRIMARY_KEY' => 'user_id',
'KEYS' => array(
'pega' => array('INDEX', array('personal_album_id')),
),
),
$this->table_prefix . 'gallery_watch' => array(
'COLUMNS' => array(
'watch_id' => array('UINT', NULL, 'auto_increment'),
'album_id' => array('UINT', 0),
'image_id' => array('UINT', 0),
'user_id' => array('UINT', 0),
),
'PRIMARY_KEY' => 'watch_id',
'KEYS' => array(
'uid' => array('INDEX', 'user_id'),
'id' => array('INDEX', 'image_id'),
'aid' => array('INDEX', 'album_id'),
),
),
),
'add_columns' => array(
$this->table_prefix . 'log' => array(
'album_id' => array('UINT', 0),
'image_id' => array('UINT', 0),
),
$this->table_prefix . 'sessions' => array(
'session_album_id' => array('UINT', 0),
),
),
'add_index' => array(
$this->table_prefix . 'sessions' => array(
'session_aid' => array('session_album_id'),
),
),
);
}
public function revert_schema()
{
return array(
'drop_keys' => array(
$this->table_prefix . 'sessions' => array(
'session_aid',
),
),
'drop_columns' => array(
$this->table_prefix . 'log' => array(
'album_id',
'image_id',
),
$this->table_prefix . 'sessions' => array(
'session_album_id',
),
),
'drop_tables' => array(
$this->table_prefix . 'gallery_albums',
$this->table_prefix . 'gallery_albums_track',
$this->table_prefix . 'gallery_comments',
$this->table_prefix . 'gallery_contests',
$this->table_prefix . 'gallery_favorites',
$this->table_prefix . 'gallery_images',
$this->table_prefix . 'gallery_modscache',
$this->table_prefix . 'gallery_permissions',
$this->table_prefix . 'gallery_rates',
$this->table_prefix . 'gallery_reports',
$this->table_prefix . 'gallery_roles',
$this->table_prefix . 'gallery_users',
$this->table_prefix . 'gallery_watch',
),
);
}
public function update_data()
{
return array(
array('permission.add', array('a_gallery_manage', true, 'a_board')),
array('permission.add', array('a_gallery_albums', true, 'a_board')),
array('permission.add', array('a_gallery_import', true, 'a_board')),
array('permission.add', array('a_gallery_cleanup', true, 'a_board')),
// ACP
array('module.add', array('acp', 'ACP_CAT_DOT_MODS', 'PHPBB_GALLERY')),
array('module.add', array('acp', 'PHPBB_GALLERY', array(
'module_basename' => '\phpbbgallery\core\acp\main_module',
'module_langname' => 'ACP_GALLERY_OVERVIEW',
'module_mode' => 'overview',
'module_auth' => 'acl_a_gallery_manage',
))),
array('module.add', array('acp', 'PHPBB_GALLERY', array(
'module_basename' => '\phpbbgallery\core\acp\config_module',
'module_langname' => 'ACP_GALLERY_CONFIGURE_GALLERY',
'module_mode' => 'main',
'module_auth' => 'acl_a_gallery_manage',
))),
array('module.add', array('acp', 'PHPBB_GALLERY', array(
'module_basename' => '\phpbbgallery\core\acp\albums_module',
'module_langname' => 'ACP_GALLERY_MANAGE_ALBUMS',
'module_mode' => 'manage',
'module_auth' => 'acl_a_gallery_albums',
))),
array('module.add', array('acp', 'PHPBB_GALLERY', array(
'module_basename' => '\phpbbgallery\core\acp\permissions_module',
'module_langname' => 'ACP_GALLERY_ALBUM_PERMISSIONS',
'module_mode' => 'manage',
'module_auth' => 'acl_a_gallery_albums',
))),
array('module.add', array('acp', 'PHPBB_GALLERY', array(
'module_basename' => '\phpbbgallery\core\acp\permissions_module',
'module_langname' => 'ACP_GALLERY_ALBUM_PERMISSIONS_COPY',
'module_mode' => 'copy',
'module_auth' => 'acl_a_gallery_albums',
))),
array('module.add', array('acp', 'PHPBB_GALLERY', array(
'module_basename' => '\phpbbgallery\core\acp\gallery_module',
'module_langname' => 'ACP_IMPORT_ALBUMS',
'module_mode' => 'import_images',
'module_auth' => 'acl_a_gallery_import',
))),
array('module.add', array('acp', 'PHPBB_GALLERY', array(
'module_basename' => '\phpbbgallery\core\acp\gallery_module',
'module_langname' => 'ACP_GALLERY_CLEANUP',
'module_mode' => 'cleanup',
'module_auth' => 'acl_a_gallery_cleanup',
))),
// UCP
array('module.add', array('ucp', '', 'UCP_GALLERY')),
array('module.add', array('ucp', 'UCP_GALLERY', array(
'module_basename' => '\phpbbgallery\core\ucp\gallery_module',
'module_langname' => 'UCP_GALLERY_SETTINGS',
'module_mode' => 'manage_settings',
'module_auth' => '',
))),
array('module.add', array('ucp', 'UCP_GALLERY', array(
'module_basename' => '\phpbbgallery\core\ucp\gallery_module',
'module_langname' => 'UCP_GALLERY_PERSONAL_ALBUMS',
'module_mode' => 'manage_albums',
'module_auth' => '',
))),
array('module.add', array('ucp', 'UCP_GALLERY', array(
'module_basename' => '\phpbbgallery\core\ucp\gallery_module',
'module_langname' => 'UCP_GALLERY_WATCH',
'module_mode' => 'manage_subscriptions',
'module_auth' => '',
))),
array('module.add', array('ucp', 'UCP_GALLERY', array(
'module_basename' => '\phpbbgallery\core\ucp\gallery_module',
'module_langname' => 'UCP_GALLERY_FAVORITES',
'module_mode' => 'manage_favorites',
'module_auth' => '',
))),
// Logs
array('module.add', array('acp', 'ACP_FORUM_LOGS', array(
'module_basename' => 'logs',
'module_langname' => 'ACP_GALLERY_LOGS',
'module_mode' => 'gallery',
'module_auth' => 'acl_a_viewlogs',
))),
// @todo: ADD BBCODE
array('custom', array(array(&$this, 'install_config'))),
);
}
public function install_config()
{
global $config;
foreach (self::$configs as $name => $value)
{
if (isset(self::$is_dynamic[$name]))
{
$config->set('phpbb_gallery_' . $name, $value, true);
}
else
{
$config->set('phpbb_gallery_' . $name, $value);
}
}
return true;
}
static public $is_dynamic = array(
'mvc_time',
'mvc_version',
'num_comments',
'num_images',
'num_pegas',
'current_upload_dir_size',
);
static public $configs = array(
'album_columns' => 3,
'album_display' => 254,
'album_images' => 2500,
'album_rows' => 4,
'allow_comments' => true,
'allow_gif' => true,
'allow_hotlinking' => true,
'allow_jpg' => true,
'allow_png' => true,
'allow_rates' => true,
'allow_resize' => true,
'allow_rotate' => true,
'allow_zip' => false,
'captcha_comment' => true,
'captcha_upload' => true,
'comment_length' => 2000,
'comment_user_control' => true,
'contests_ended' => 0,
'current_upload_dir_size' => 0,
'current_upload_dir' => 0,
'default_sort_dir' => 'd',
'default_sort_key' => 't',
'description_length'=> 2000,
'disp_birthdays' => false,
'disp_image_url' => true,
'disp_login' => true,
'disp_nextprev_thumbnail' => false,
'disp_statistic' => true,
'disp_total_images' => true,
'disp_whoisonline' => true,
'gdlib_version' => 2,
'hotlinking_domains' => 'flying-bits.org',
'jpg_quality' => 100,
'link_thumbnail' => 'image_page',
'link_imagepage' => 'image',
'link_image_name' => 'image_page',
'link_image_icon' => 'image_page',
'max_filesize' => 512000,
'max_height' => 1024,
'max_rating' => 10,
'max_width' => 1280,
'medium_cache' => true,
'medium_height' => 600,
'medium_width' => 800,
'mini_thumbnail_disp' => true,
'mini_thumbnail_size' => 70,
'mvc_ignore' => 0,
'mvc_time' => 0,
'mvc_version' => '',
'newest_pega_user_id' => 0,
'newest_pega_username' => '',
'newest_pega_user_colour' => '',
'newest_pega_album_id' => 0,
'num_comments' => 0,
'num_images' => 0,
'num_pegas' => 0,
'num_uploads' => 10,
'pegas_index_album' => false,
'pegas_per_page' => 15,
'profile_user_images' => true,
'profile_pega' => true,
'prune_orphan_time' => 0,
'rrc_gindex_columns' => 4,
'rrc_gindex_comments' => false,
'rrc_gindex_contests' => 1,
'rrc_gindex_crows' => 5,
'rrc_gindex_display' => 173,
'rrc_gindex_mode' => 7,
'rrc_gindex_pegas' => true,
'rrc_gindex_rows' => 1,
'rrc_profile_columns' => 4,
'rrc_profile_display' => 141,
'rrc_profile_mode' => 3,
'rrc_profile_pegas' => true,
'rrc_profile_rows' => 1,
'search_display' => 45,
'shortnames' => 25,
'thumbnail_cache' => true,
'thumbnail_height' => 160,
'thumbnail_infoline' => false,
'thumbnail_quality' => 50,
'thumbnail_width' => 240,
'version' => '',
'viewtopic_icon' => true,
'viewtopic_images' => true,
'viewtopic_link' => false,
'watermark_changed' => 0,
'watermark_enabled' => true,
'watermark_height' => 50,
'watermark_position' => 20,
'watermark_source' => 'gallery/images/watermark.png',
'watermark_width' => 200,
);
}

25
phpunit.xml.all Normal file
View File

@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="true"
backupStaticAttributes="true"
colors="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
verbose="true"
bootstrap="tests/bootstrap.php">
<testsuites>
<testsuite name="phpBB Gallery Test Suite">
<directory suffix="_test.php">./tests/</directory>
</testsuite>
</testsuites>
<filter>
<blacklist>
<directory>./tests/</directory>
</blacklist>
</filter>
</phpunit>

32
phpunit.xml.dist Normal file
View File

@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="true"
backupStaticAttributes="true"
colors="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
verbose="true"
bootstrap="tests/bootstrap.php">
<testsuites>
<testsuite name="phpBB Gallery Test Suite">
<directory suffix="_test.php">./tests/</directory>
</testsuite>
</testsuites>
<groups>
<exclude>
<group>functional</group>
<group>slow</group>
</exclude>
</groups>
<filter>
<blacklist>
<directory>./tests/</directory>
</blacklist>
</filter>
</phpunit>

31
phpunit.xml.functional Normal file
View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="true"
backupStaticAttributes="true"
colors="false"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
verbose="true"
bootstrap="tests/bootstrap.php">
<testsuites>
<testsuite name="phpBB Gallery Test Suite">
<directory suffix="_test.php">./tests/</directory>
</testsuite>
</testsuites>
<groups>
<include>
<group>functional</group>
</include>
</groups>
<filter>
<blacklist>
<directory>./tests/</directory>
</blacklist>
</filter>
</phpunit>

30
tests/bootstrap.php Normal file
View File

@@ -0,0 +1,30 @@
<?php
/**
*
* @package phpBB Gallery Testing
* @copyright (c) 2013 nickvergessen
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
define('IN_PHPBB', true);
$phpbb_root_path = './../../';
$phpEx = 'php';
require_once $phpbb_root_path . 'includes/startup.' . $phpEx;
$table_prefix = 'phpbb_';
require_once $phpbb_root_path . 'includes/constants.' . $phpEx;
require_once $phpbb_root_path . 'phpbb/class_loader.' . $phpEx;
$phpbb_class_loader_mock = new \phpbb\class_loader('phpbb_mock_', $phpbb_root_path . '../tests/mock/', "php");
$phpbb_class_loader_mock->register();
$phpbb_class_loader_ext = new \phpbb\class_loader('\\', $phpbb_root_path . 'ext/', "php");
$phpbb_class_loader_ext->register();
$phpbb_class_loader = new \phpbb\class_loader('phpbb\\', $phpbb_root_path . 'phpbb/', "php");
$phpbb_class_loader->register();
require_once $phpbb_root_path . '../tests/test_framework/phpbb_test_case_helpers.' . $phpEx;
require_once $phpbb_root_path . '../tests/test_framework/phpbb_test_case.' . $phpEx;
require_once $phpbb_root_path . '../tests/test_framework/phpbb_database_test_case.' . $phpEx;
require_once $phpbb_root_path . '../tests/test_framework/phpbb_database_test_connection_manager.' . $phpEx;
require_once $phpbb_root_path . '../tests/test_framework/phpbb_functional_test_case.' . $phpEx;

View File

@@ -0,0 +1,19 @@
<?php
/**
*
* @package testing
* @copyright (c) Board3 Group ( www.board3.de )
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
require_once(dirname(__FILE__) . '/../../portal/portal/includes/functions.php');
class phpbb_functions_simple_test extends PHPUnit_Framework_TestCase
{
public function test_ap_validate()
{
$this->assertEquals('<br/>woot<br/><ul><li>test</li></ul>', ap_validate('<br />woot<br/><ul><li>test</li><br /></ul>'));
}
}

View File

@@ -0,0 +1,179 @@
<?php
/**
*
* @package testing
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ScopeInterface;
class phpbb_mock_container_builder implements ContainerInterface
{
protected $services = array();
protected $parameters = array();
/**
* Sets a service.
*
* @param string $id The service identifier
* @param object $service The service instance
* @param string $scope The scope of the service
*
* @api
*/
public function set($id, $service, $scope = self::SCOPE_CONTAINER)
{
$this->services[$id] = $service;
}
/**
* Gets a service.
*
* @param string $id The service identifier
* @param int $invalidBehavior The behavior when the service does not exist
*
* @return object The associated service
*
* @throws InvalidArgumentException if the service is not defined
* @throws ServiceCircularReferenceException When a circular reference is detected
* @throws ServiceNotFoundException When the service is not defined
*
* @see Reference
*
* @api
*/
public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE)
{
if ($this->has($id))
{
return $this->services[$id];
}
throw new Exception('Could not find service: ' . $id);
}
/**
* Returns true if the given service is defined.
*
* @param string $id The service identifier
*
* @return Boolean true if the service is defined, false otherwise
*
* @api
*/
public function has($id)
{
return isset($this->services[$id]);
}
/**
* Gets a parameter.
*
* @param string $name The parameter name
*
* @return mixed The parameter value
*
* @throws InvalidArgumentException if the parameter is not defined
*
* @api
*/
public function getParameter($name)
{
if ($this->hasParameter($name))
{
return $this->parameters[$name];
}
throw new Exception('Could not find parameter: ' . $name);
}
/**
* Checks if a parameter exists.
*
* @param string $name The parameter name
*
* @return Boolean The presence of parameter in container
*
* @api
*/
public function hasParameter($name)
{
return isset($this->parameters[$name]);
}
/**
* Sets a parameter.
*
* @param string $name The parameter name
* @param mixed $value The parameter value
*
* @api
*/
public function setParameter($name, $value)
{
$this->parameters[$name] = $value;
}
/**
* Enters the given scope
*
* @param string $name
*
* @api
*/
public function enterScope($name)
{
}
/**
* Leaves the current scope, and re-enters the parent scope
*
* @param string $name
*
* @api
*/
public function leaveScope($name)
{
}
/**
* Adds a scope to the container
*
* @param ScopeInterface $scope
*
* @api
*/
public function addScope(ScopeInterface $scope)
{
}
/**
* Whether this container has the given scope
*
* @param string $name
*
* @return Boolean
*
* @api
*/
public function hasScope($name)
{
}
/**
* Determines whether the given scope is currently active.
*
* It does however not check if the scope actually exists.
*
* @param string $name
*
* @return Boolean
*
* @api
*/
public function isScopeActive($name)
{
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,34 @@
<?php
/**
*
* @package phpBB Gallery Testing
* @copyright (c) 2013 nickvergessen
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace board3\tests\systemtests;
class base_database_test extends \board3\tests\testframework\database_test_case
{
public function getDataSet()
{
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/basetests.xml');
}
public function test_check()
{
$sql = 'SELECT session_user_id, album_name
FROM phpbb_sessions s
LEFT JOIN phpbb_gallery_albums a
ON (s.session_album_id = a.album_id)';
$result = $this->db->sql_query($sql);
$this->assertEquals(array(
array(
'session_user_id' => 4,
'album_name' => 'Testalbum',
),
), $this->db->sql_fetchrowset($result));
$this->db->sql_freeresult($result);
}
}

View File

@@ -0,0 +1,18 @@
<?php
/**
*
* @package phpBB Gallery Testing
* @copyright (c) 2013 nickvergessen
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace board3\tests\systemtests;
class base_test extends \board3\tests\testframework\test_case
{
public function test_check()
{
$this->assertTrue(true);
}
}

View File

@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dataset>
<table name="phpbb_sessions">
<column>session_id</column>
<column>session_user_id</column>
<column>session_album_id</column>
<column>session_ip</column>
<column>session_browser</column>
<column>session_admin</column>
<row>
<value>bar_session000000000000000000000</value>
<value>4</value>
<value>42</value>
<value>127.0.0.1</value>
<value>user agent</value>
<value>1</value>
</row>
</table>
<table name="phpbb_gallery_albums">
<column>album_id</column>
<column>album_name</column>
<column>album_parents</column>
<column>album_desc</column>
<row>
<value>42</value>
<value>Testalbum</value>
<value></value>
<value></value>
</row>
</table>
</dataset>

View File

@@ -0,0 +1,7 @@
<?php
$dbms = 'phpbb\\db\\driver\\mysqli';
$dbhost = 'localhost';
$dbport = '';
$dbname = 'phpbb_test';
$dbuser = 'root';
$dbpasswd = '';

View File

@@ -0,0 +1,50 @@
<?php
/**
*
* @package phpBB Gallery Testing
* @copyright (c) 2013 nickvergessen
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace board3\tests\testframework;
abstract class database_test_case extends \phpbb_database_test_case
{
protected $db;
public function setUp()
{
parent::setUp();
global $db;
$db = $this->db = $this->new_dbal();
}
protected function create_connection_manager($config)
{
return new \board3\tests\testframework\database_test_connection_manager($config);
}
public function get_database_config()
{
$config = \board3\tests\testframework\test_case_helpers::get_test_config();
if (!isset($config['dbms']))
{
$this->markTestSkipped('Missing test_config.php: See first error.');
}
return $config;
}
public function get_test_case_helpers()
{
if (!$this->test_case_helpers)
{
$this->test_case_helpers = new \board3\tests\testframework\test_case_helpers($this);
}
return $this->test_case_helpers;
}
}

View File

@@ -0,0 +1,22 @@
<?php
/**
*
* @package phpBB Gallery Testing
* @copyright (c) 2013 nickvergessen
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace board3\tests\testframework;
class database_test_connection_manager extends \phpbb_database_test_connection_manager
{
public function load_schema()
{
$this->ensure_connected(__METHOD__);
$directory = dirname(__FILE__) . '/../schemas/';
$this->load_schema_from_file($directory);
}
}

View File

@@ -0,0 +1,14 @@
<?php
/**
*
* @package phpBB Gallery Testing
* @copyright (c) 2013 nickvergessen
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace board3\tests\testframework;
abstract class functional_test_case extends \phpbb_functional_test_case
{
}

View File

@@ -0,0 +1,23 @@
<?php
/**
*
* @package phpBB Gallery Testing
* @copyright (c) 2013 nickvergessen
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace board3\tests\testframework;
abstract class test_case extends \phpbb_test_case
{
public function get_test_case_helpers()
{
if (!$this->test_case_helpers)
{
$this->test_case_helpers = new \board3\tests\testframework\test_case_helpers($this);
}
return $this->test_case_helpers;
}
}

View File

@@ -0,0 +1,116 @@
<?php
/**
*
* @package phpBB Gallery Testing
* @copyright (c) 2013 nickvergessen
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace board3\tests\testframework;
abstract class test_case_helpers extends \phpbb_test_case_helpers
{
/**
* Copied from phpbb_test_case_helpers::get_test_config() to fix some paths
*/
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' => 'phpbb_db_driver_sqlite',
'dbhost' => dirname(__FILE__) . '/../phpbb_unit_tests.sqlite2', // filename
'dbport' => '',
'dbname' => '',
'dbuser' => '',
'dbpasswd' => '',
));
}
if (isset($_SERVER['PHPBB_TEST_CONFIG']))
{
// Could be an absolute path
$test_config = $_SERVER['PHPBB_TEST_CONFIG'];
}
else
{
$test_config = dirname(__FILE__) . '/../test_config.php';
}
if (file_exists($test_config))
{
include($test_config);
if (!function_exists('phpbb_convert_30_dbms_to_31'))
{
global $phpbb_root_path;
require_once $phpbb_root_path . 'includes/functions.php';
}
$config = array_merge($config, array(
'dbms' => phpbb_convert_30_dbms_to_31($dbms),
'dbhost' => $dbhost,
'dbport' => $dbport,
'dbname' => $dbname,
'dbuser' => $dbuser,
'dbpasswd' => $dbpasswd,
'custom_dsn' => isset($custom_dsn) ? $custom_dsn : '',
));
if (isset($phpbb_functional_url))
{
$config['phpbb_functional_url'] = $phpbb_functional_url;
}
if (isset($phpbb_redis_host))
{
$config['redis_host'] = $phpbb_redis_host;
}
if (isset($phpbb_redis_port))
{
$config['redis_port'] = $phpbb_redis_port;
}
}
if (isset($_SERVER['PHPBB_TEST_DBMS']))
{
if (!function_exists('phpbb_convert_30_dbms_to_31'))
{
global $phpbb_root_path;
require_once $phpbb_root_path . 'includes/functions.php';
}
$config = array_merge($config, array(
'dbms' => isset($_SERVER['PHPBB_TEST_DBMS']) ? phpbb_convert_30_dbms_to_31($_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'] : '',
'custom_dsn' => isset($_SERVER['PHPBB_TEST_CUSTOM_DSN']) ? $_SERVER['PHPBB_TEST_CUSTOM_DSN'] : '',
));
}
if (isset($_SERVER['PHPBB_FUNCTIONAL_URL']))
{
$config = array_merge($config, array(
'phpbb_functional_url' => isset($_SERVER['PHPBB_FUNCTIONAL_URL']) ? $_SERVER['PHPBB_FUNCTIONAL_URL'] : '',
));
}
if (isset($_SERVER['PHPBB_TEST_REDIS_HOST']))
{
$config['redis_host'] = $_SERVER['PHPBB_TEST_REDIS_HOST'];
}
if (isset($_SERVER['PHPBB_TEST_REDIS_PORT']))
{
$config['redis_port'] = $_SERVER['PHPBB_TEST_REDIS_PORT'];
}
return $config;
}
}

View File

@@ -0,0 +1,21 @@
#!/bin/bash
#
# @copyright (c) 2013 phpBB Group
# @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
#
set -e
function add_ext_to_php_ini
{
echo "extension=$1.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
}
# redis
git clone git://github.com/nicolasff/phpredis.git
cd phpredis
phpize
./configure
make
make install
cd ..
add_ext_to_php_ini 'redis'

View File

@@ -0,0 +1,41 @@
<?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="true"
strict="true"
verbose="true"
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.19" phpVersionOperator=">=">../tests/functional</directory>
</testsuite>
</testsuites>
<groups>
<exclude>
<group>slow</group>
</exclude>
</groups>
<php>
<server name="PHPBB_TEST_DBMS" value="phpbb\db\driver\mysqli" />
<server name="PHPBB_TEST_DBHOST" value="0.0.0.0" />
<server name="PHPBB_TEST_DBPORT" value="3306" />
<server name="PHPBB_TEST_DBNAME" value="phpbb_tests" />
<server name="PHPBB_TEST_DBUSER" value="root" />
<server name="PHPBB_TEST_DBPASSWD" value="" />
<server name="PHPBB_TEST_REDIS_HOST" value="localhost" />
<server name="PHPBB_TEST_TABLE_PREFIX" value="phpbb_"/>
<server name="PHPBB_FUNCTIONAL_URL" value="http://localhost/" />
</php>
</phpunit>

View File

@@ -0,0 +1,43 @@
<?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="true"
strict="true"
verbose="true"
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.19" phpVersionOperator=">=">../tests/functional</directory>
</testsuite>
</testsuites>
<groups>
<exclude>
<group>slow</group>
</exclude>
</groups>
<php>
<!-- "Real" test database -->
<!-- uncomment, otherwise sqlite memory runs -->
<server name="PHPBB_TEST_DBMS" value="phpbb\db\driver\postgres"/>
<server name="PHPBB_TEST_DBHOST" value="localhost" />
<server name="PHPBB_TEST_DBPORT" value="5432" />
<server name="PHPBB_TEST_DBNAME" value="phpbb_tests" />
<server name="PHPBB_TEST_DBUSER" value="postgres" />
<server name="PHPBB_TEST_DBPASSWD" value="" />
<server name="PHPBB_TEST_REDIS_HOST" value="localhost" />
<server name="PHPBB_TEST_TABLE_PREFIX" value="phpbb_"/>
<server name="PHPBB_FUNCTIONAL_URL" value="http://localhost/" />
</php>
</phpunit>

54
travis/setup-webserver.sh Executable file
View File

@@ -0,0 +1,54 @@
#!/bin/bash
#
# @copyright (c) 2013 phpBB Group
# @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
#
set -e
sudo apt-get update -qq
sudo apt-get install -qq nginx realpath
sudo service nginx stop
DIR=$(dirname "$0")
PHPBB_ROOT_PATH=$(realpath "$DIR/../../../..")
NGINX_CONF="/etc/nginx/sites-enabled/default"
PHP_FPM_BIN="$HOME/.phpenv/versions/$TRAVIS_PHP_VERSION/sbin/php-fpm"
PHP_FPM_CONF="$DIR/php-fpm.conf"
PHP_FPM_SOCK=$(realpath "$DIR")/php-fpm.sock
USER=$(whoami)
# php-fpm configuration
echo "
[global]
[travis]
user = $USER
group = $USER
listen = $PHP_FPM_SOCK
pm = static
pm.max_children = 2
php_admin_value[memory_limit] = 128M
" > $PHP_FPM_CONF
# nginx configuration
echo "
server {
listen 80;
root $PHPBB_ROOT_PATH/;
index index.php index.html;
location ~ \.php$ {
fastcgi_pass unix:$PHP_FPM_SOCK;
include fastcgi_params;
}
}
" | sudo tee $NGINX_CONF > /dev/null
# Start daemons
sudo $PHP_FPM_BIN --fpm-config "$DIR/php-fpm.conf"
sudo service nginx start