mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
Merge branch 'develop' of https://github.com/phpbb/phpbb3 into feature/softdelete-1-permission-rebase
* 'develop' of https://github.com/phpbb/phpbb3: (544 commits) [feature/events] Fix improperly named event in documentation [feature/events] Fix alphabetization of events [feature/events] Put events in alphabetical order [feature/events] Make EVENTS.md lowercase [ticket/11285] Use more granularity in dependency checks in compress test [ticket/10880] The m_approve permisson no longer implies f_noapprove. [ticket/10803] Show failure message until user dismisses it [ticket/10954] Add missing semi-colon [ticket/10954] Make sure to mark subforums unread and add small fixes [feature/events] Use ` to escape HTML tags in markdown [feature/events] Remove HTML tags from markdown so they don't get parsed [ticket/10954] Miscellaneous coding fixes [feature/events] Remove extraneous space [feature/events] Add markdown template event documentation file [feature/events] forumlist_body_last_post_title_after -> _prepend (subsilver2) [feature/events] Fix overall_footer_end -> overall_footer_after (subsilver2) [feature/events] Fix typo in event name [ticket/10763] Use self when calling get_extension() in filespec class [feature/events] Fix more subsilver2 events [feature/events] Fix some subsilver2 events ... Conflicts: phpBB/install/database_update.php phpBB/posting.php
This commit is contained in:
@@ -30,7 +30,7 @@ example for mysqli can be found below. More information on configuration
|
||||
options can be found on the wiki (see below).
|
||||
|
||||
<?php
|
||||
$dbms = 'mysqli';
|
||||
$dbms = 'phpbb_db_driver_mysqli';
|
||||
$dbhost = 'localhost';
|
||||
$dbport = '';
|
||||
$dbname = 'database';
|
||||
@@ -72,6 +72,21 @@ to connect to that database in phpBB.
|
||||
Additionally, you will need to be running the DbUnit fork from
|
||||
https://github.com/phpbb/dbunit/tree/phpbb.
|
||||
|
||||
Redis
|
||||
-----
|
||||
|
||||
In order to run tests for the Redis cache driver, at least one of Redis host
|
||||
or port must be specified in test configuration. This can be done via
|
||||
test_config.php as follows:
|
||||
|
||||
<?php
|
||||
$phpbb_redis_host = 'localhost';
|
||||
$phpbb_redis_port = 6379;
|
||||
|
||||
Or via environment variables as follows:
|
||||
|
||||
$ PHPBB_TEST_REDIS_HOST=localhost PHPBB_TEST_REDIS_PORT=6379 phpunit
|
||||
|
||||
Running
|
||||
=======
|
||||
|
||||
|
@@ -2,28 +2,264 @@
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @version $Id$
|
||||
* @copyright (c) 2008 phpBB Group
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
// require_once dirname(__FILE__) . '/../../phpBB/includes/bbcode/bbcode_parser_base.php';
|
||||
// require_once dirname(__FILE__) . '/../../phpBB/includes/bbcode/bbcode_parser.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/bbcode.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/message_parser.php';
|
||||
|
||||
class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function test_both_passes()
|
||||
public function bbcode_firstpass_data()
|
||||
{
|
||||
$this->markTestIncomplete('New bbcode parser has not been backported from feature/ascraeus-experiment yet.');
|
||||
|
||||
$parser = new phpbb_bbcode_parser();
|
||||
return array(
|
||||
// Default bbcodes from in their simplest way
|
||||
array(
|
||||
'Test default bbcodes: simple bold',
|
||||
'[b]bold[/b]',
|
||||
'[b:]bold[/b:]',
|
||||
),
|
||||
array(
|
||||
'Test default bbcodes: simple underlined',
|
||||
'[u]underlined[/u]',
|
||||
'[u:]underlined[/u:]',
|
||||
),
|
||||
array(
|
||||
'Test default bbcodes: simple italic',
|
||||
'[i]italic[/i]',
|
||||
'[i:]italic[/i:]',
|
||||
),
|
||||
array(
|
||||
'Test default bbcodes: simple color rgb',
|
||||
'[color=#FF0000]colored[/color]',
|
||||
'[color=#FF0000:]colored[/color:]',
|
||||
),
|
||||
array(
|
||||
'Test default bbcodes: simple color name',
|
||||
'[color=red]colored[/color]',
|
||||
'[color=red:]colored[/color:]',
|
||||
),
|
||||
array(
|
||||
'Test default bbcodes: simple size',
|
||||
'[size=75]smaller[/size]',
|
||||
'[size=75:]smaller[/size:]',
|
||||
),
|
||||
array(
|
||||
'Test default bbcodes: simple quote',
|
||||
'[quote]quoted[/quote]',
|
||||
'[quote:]quoted[/quote:]',
|
||||
),
|
||||
array(
|
||||
'Test default bbcodes: simple quote with username',
|
||||
'[quote="username"]quoted[/quote]',
|
||||
'[quote="username":]quoted[/quote:]',
|
||||
),
|
||||
array(
|
||||
'Test default bbcodes: simple code',
|
||||
'[code]unparsed code[/code]',
|
||||
'[code:]unparsed code[/code:]',
|
||||
),
|
||||
array(
|
||||
'Test default bbcodes: simple php code',
|
||||
'[code=php]unparsed code[/code]',
|
||||
'[code=php:]<span class="syntaxdefault">unparsed code</span>[/code:]',
|
||||
),
|
||||
array(
|
||||
'Test default bbcodes: simple list',
|
||||
'[list]no item[/list]',
|
||||
'[list:]no item[/list:u:]',
|
||||
),
|
||||
array(
|
||||
'Test default bbcodes: simple list-item only',
|
||||
'[*]unparsed',
|
||||
'[*]unparsed',
|
||||
),
|
||||
array(
|
||||
'Test default bbcodes: simple list-item',
|
||||
'[list][*]item[/list]',
|
||||
'[list:][*:]item[/*:m:][/list:u:]',
|
||||
),
|
||||
array(
|
||||
'Test default bbcodes: simple list-item closed',
|
||||
'[list][*]item[/*][/list]',
|
||||
'[list:][*:]item[/*:][/list:u:]',
|
||||
),
|
||||
array(
|
||||
'Test default bbcodes: simple list-item numbered',
|
||||
'[list=1][*]item[/list]',
|
||||
'[list=1:][*:]item[/*:m:][/list:o:]',
|
||||
),
|
||||
array(
|
||||
'Test default bbcodes: simple list-item alpha',
|
||||
'[list=a][*]item[/list]',
|
||||
'[list=a:][*:]item[/*:m:][/list:o:]',
|
||||
),
|
||||
array(
|
||||
'Test default bbcodes: simple list-item roman',
|
||||
'[list=i][*]item[/list]',
|
||||
'[list=i:][*:]item[/*:m:][/list:o:]',
|
||||
),
|
||||
array(
|
||||
'Test default bbcodes: simple list-item disc',
|
||||
'[list=disc][*]item[/list]',
|
||||
'[list=disc:][*:]item[/*:m:][/list:u:]',
|
||||
),
|
||||
array(
|
||||
'Test default bbcodes: simple list-item circle',
|
||||
'[list=circle][*]item[/list]',
|
||||
'[list=circle:][*:]item[/*:m:][/list:u:]',
|
||||
),
|
||||
array(
|
||||
'Test default bbcodes: simple list-item square',
|
||||
'[list=square][*]item[/list]',
|
||||
'[list=square:][*:]item[/*:m:][/list:u:]',
|
||||
),
|
||||
array(
|
||||
'Test default bbcodes: simple img',
|
||||
'[img]https://area51.phpbb.com/images/area51.png[/img]',
|
||||
'[img:]https://area51.phpbb.com/images/area51.png[/img:]',
|
||||
),
|
||||
array(
|
||||
'Test default bbcodes: simple url',
|
||||
'[url]https://area51.phpbb.com/[/url]',
|
||||
'[url:]https://area51.phpbb.com/[/url:]',
|
||||
),
|
||||
array(
|
||||
'Test default bbcodes: simple url with description',
|
||||
'[url=https://area51.phpbb.com/]Area51[/url]',
|
||||
'[url=https://area51.phpbb.com/:]Area51[/url:]',
|
||||
),
|
||||
array(
|
||||
'Test default bbcodes: simple email',
|
||||
'[email]bbcode-test@phpbb.com[/email]',
|
||||
'[email:]bbcode-test@phpbb.com[/email:]',
|
||||
),
|
||||
array(
|
||||
'Test default bbcodes: simple email with description',
|
||||
'[email=bbcode-test@phpbb.com]Email[/email]',
|
||||
'[email=bbcode-test@phpbb.com:]Email[/email:]',
|
||||
),
|
||||
array(
|
||||
'Test default bbcodes: simple attachment',
|
||||
'[attachment=0]filename[/attachment]',
|
||||
'[attachment=0:]<!-- ia0 -->filename<!-- ia0 -->[/attachment:]',
|
||||
),
|
||||
|
||||
$result = $parser->first_pass('[i]Italic [u]underlined text[/u][/i]');
|
||||
$result = $parser->second_pass($result);
|
||||
// Special cases for quote which were reported as bugs before
|
||||
array(
|
||||
'PHPBB3-1401 - correct: parsed',
|
||||
'[quote="[test]test"]test [ test[/quote]',
|
||||
'[quote="[test]test":]test [ test[/quote:]',
|
||||
),
|
||||
array(
|
||||
'PHPBB3-6117 - correct: parsed',
|
||||
'[quote]test[/quote] test ] and [ test [quote]test[/quote]',
|
||||
'[quote:]test[/quote:] test ] and [ test [quote:]test[/quote:]',
|
||||
),
|
||||
array(
|
||||
'PHPBB3-6200 - correct: parsed',
|
||||
'[quote="["]test[/quote]',
|
||||
'[quote="[":]test[/quote:]',
|
||||
),
|
||||
array(
|
||||
'PHPBB3-9364 - quoted: "test[/[/b]quote] test" / non-quoted: "[/quote] test" - also failed if layout distorted',
|
||||
'[quote]test[/[/b]quote] test [/quote][/quote] test',
|
||||
'[quote:]test[/[/b]quote] test [/quote:][/quote] test',
|
||||
),
|
||||
array(
|
||||
'PHPBB3-8096 - first quote tag parsed, second quote tag unparsed',
|
||||
'[quote="a"]a[/quote][quote="a]a[/quote]',
|
||||
'[quote="a":]a[/quote:][quote="a]a[/quote]',
|
||||
),
|
||||
|
||||
$expected = '<span style="font-style: italic">Italic <span style="text-decoration: underline">underlined text</span></span>';
|
||||
// Simple bbcodes nesting
|
||||
array(
|
||||
'Allow textual bbcodes in textual bbcodes',
|
||||
'[b]bold [i]bold + italic[/i][/b]',
|
||||
'[b:]bold [i:]bold + italic[/i:][/b:]',
|
||||
),
|
||||
array(
|
||||
'Allow textual bbcodes in url with description',
|
||||
'[url=https://area51.phpbb.com/]Area51 [i]italic[/i][/url]',
|
||||
'[url=https://area51.phpbb.com/:]Area51 [i:]italic[/i:][/url:]',
|
||||
),
|
||||
array(
|
||||
'Allow url with description in textual bbcodes',
|
||||
'[i]italic [url=https://area51.phpbb.com/]Area51[/url][/i]',
|
||||
'[i:]italic [url=https://area51.phpbb.com/:]Area51[/url:][/i:]',
|
||||
),
|
||||
|
||||
$this->assertEquals($expected, $result, 'Simple nested BBCode first+second pass');
|
||||
// Nesting bbcodes into quote usernames
|
||||
array(
|
||||
'Allow textual bbcodes in usernames',
|
||||
'[quote="[i]test[/i]"]test[/quote]',
|
||||
'[quote="[i:]test[/i:]":]test[/quote:]',
|
||||
),
|
||||
array(
|
||||
'Allow links bbcodes in usernames',
|
||||
'[quote="[url=https://area51.phpbb.com/]test[/url]"]test[/quote]',
|
||||
'[quote="[url=https://area51.phpbb.com/:]test[/url:]":]test[/quote:]',
|
||||
),
|
||||
array(
|
||||
'Allow img bbcodes in usernames - Username displayed the image',
|
||||
'[quote="[img]https://area51.phpbb.com/images/area51.png[/img]"]test[/quote]',
|
||||
'[quote="[img:]https://area51.phpbb.com/images/area51.png[/img:]":]test[/quote:]',
|
||||
),
|
||||
array(
|
||||
'Disallow flash bbcodes in usernames - Username displayed as [flash]http://www.phpbb.com/[/flash]',
|
||||
'[quote="[flash]http://www.phpbb.com/[/flash]"]test[/quote]',
|
||||
'[quote="[flash]http://www.phpbb.com/[/flash]":]test[/quote:]',
|
||||
),
|
||||
array(
|
||||
'Disallow quote bbcodes in usernames - Username displayed as [quote]test[/quote]',
|
||||
'[quote="[quote]test[/quote]"]test[/quote]',
|
||||
'[quote="[quote]test[/quote]":]test[/quote:]',
|
||||
),
|
||||
|
||||
// Do not parse bbcodes in code boxes
|
||||
array(
|
||||
'Do not parse textual bbcodes in code',
|
||||
'[code]unparsed code [b]bold [i]bold + italic[/i][/b][/code]',
|
||||
'[code:]unparsed code [b]bold [i]bold + italic[/i][/b][/code:]',
|
||||
),
|
||||
array(
|
||||
'Do not parse quote bbcodes in code',
|
||||
'[code]unparsed code [quote="username"]quoted[/quote][/code]',
|
||||
'[code:]unparsed code [quote="username"]quoted[/quote][/code:]',
|
||||
),
|
||||
|
||||
// New user friendly mixed nesting
|
||||
array(
|
||||
'Textual bbcode nesting into textual bbcode',
|
||||
'[b]bold [i]bold + italic[/b] italic[/i]',
|
||||
'[b:]bold [i:]bold + italic[/b:] italic[/i:]',
|
||||
'Incomplete test case: secondpass parses as [b:]bold [i:]bold + italic[/i:] italic[/b:]',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider bbcode_firstpass_data
|
||||
*/
|
||||
public function test_bbcode_firstpass($description, $message, $expected, $incomplete = false)
|
||||
{
|
||||
if ($incomplete)
|
||||
{
|
||||
$this->markTestIncomplete($incomplete);
|
||||
}
|
||||
|
||||
global $user, $request;
|
||||
$user = new phpbb_mock_user;
|
||||
$request = new phpbb_mock_request;
|
||||
|
||||
$bbcode = new bbcode_firstpass();
|
||||
$bbcode->message = $message;
|
||||
$bbcode->bbcode_init(false);
|
||||
$bbcode->parse_bbcode();
|
||||
$this->assertEquals($expected, $bbcode->message);
|
||||
}
|
||||
}
|
||||
|
53
tests/cache/apc_driver_test.php
vendored
Normal file
53
tests/cache/apc_driver_test.php
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
// Important: apc.enable_cli=1 must be in php.ini.
|
||||
// http://forums.devshed.com/php-development-5/apc-problem-561290.html
|
||||
// http://php.net/manual/en/apc.configuration.php
|
||||
|
||||
require_once dirname(__FILE__) . '/common_test_case.php';
|
||||
|
||||
class phpbb_cache_apc_driver_test extends phpbb_cache_common_test_case
|
||||
{
|
||||
protected static $config;
|
||||
protected $driver;
|
||||
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
|
||||
}
|
||||
|
||||
static public function setUpBeforeClass()
|
||||
{
|
||||
if (!extension_loaded('apc'))
|
||||
{
|
||||
self::markTestSkipped('APC extension is not loaded');
|
||||
}
|
||||
|
||||
$php_ini = new phpbb_php_ini;
|
||||
|
||||
if (!$php_ini->get_bool('apc.enabled'))
|
||||
{
|
||||
self::markTestSkipped('APC is not enabled. Make sure apc.enabled=1 in php.ini');
|
||||
}
|
||||
|
||||
if (PHP_SAPI == 'cli' && !$php_ini->get_bool('apc.enable_cli'))
|
||||
{
|
||||
self::markTestSkipped('APC is not enabled for CLI. Set apc.enable_cli=1 in php.ini');
|
||||
}
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->driver = new phpbb_cache_driver_apc;
|
||||
$this->driver->purge();
|
||||
}
|
||||
}
|
109
tests/cache/cache_test.php
vendored
109
tests/cache/cache_test.php
vendored
@@ -1,109 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2010 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
|
||||
class phpbb_cache_test extends phpbb_database_test_case
|
||||
{
|
||||
private $cache_dir;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->cache_dir = dirname(__FILE__) . '/../tmp/cache/';
|
||||
}
|
||||
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
if (file_exists($this->cache_dir))
|
||||
{
|
||||
// cache directory possibly left after aborted
|
||||
// or failed run earlier
|
||||
$this->remove_cache_dir();
|
||||
}
|
||||
$this->create_cache_dir();
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
if (file_exists($this->cache_dir))
|
||||
{
|
||||
$this->remove_cache_dir();
|
||||
}
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
private function create_cache_dir()
|
||||
{
|
||||
$this->get_test_case_helpers()->makedirs($this->cache_dir);
|
||||
}
|
||||
|
||||
private function remove_cache_dir()
|
||||
{
|
||||
$iterator = new DirectoryIterator($this->cache_dir);
|
||||
foreach ($iterator as $file)
|
||||
{
|
||||
if ($file != '.' && $file != '..')
|
||||
{
|
||||
unlink($this->cache_dir . '/' . $file);
|
||||
}
|
||||
}
|
||||
rmdir($this->cache_dir);
|
||||
}
|
||||
|
||||
public function test_cache_driver_file()
|
||||
{
|
||||
$driver = new phpbb_cache_driver_file($this->cache_dir);
|
||||
$driver->put('test_key', 'test_value');
|
||||
$driver->save();
|
||||
|
||||
$this->assertEquals(
|
||||
'test_value',
|
||||
$driver->get('test_key'),
|
||||
'File ACM put and get'
|
||||
);
|
||||
}
|
||||
|
||||
public function test_cache_sql()
|
||||
{
|
||||
$driver = new phpbb_cache_driver_file($this->cache_dir);
|
||||
|
||||
global $db, $cache;
|
||||
$db = $this->new_dbal();
|
||||
$cache = new phpbb_cache_service($driver);
|
||||
|
||||
$sql = "SELECT * FROM phpbb_config
|
||||
WHERE config_name = 'foo'";
|
||||
$result = $db->sql_query($sql, 300);
|
||||
$first_result = $db->sql_fetchrow($result);
|
||||
|
||||
$this->assertFileExists($this->cache_dir . 'sql_' . md5(preg_replace('/[\n\r\s\t]+/', ' ', $sql)) . '.php');
|
||||
|
||||
$sql = "SELECT * FROM phpbb_config
|
||||
WHERE config_name = 'foo'";
|
||||
$result = $db->sql_query($sql, 300);
|
||||
|
||||
$this->assertEquals($first_result, $db->sql_fetchrow($result));
|
||||
|
||||
$sql = "SELECT * FROM phpbb_config
|
||||
WHERE config_name = 'bar'";
|
||||
$result = $db->sql_query($sql, 300);
|
||||
|
||||
$this->assertNotEquals($first_result, $db->sql_fetchrow($result));
|
||||
|
||||
$db->sql_close();
|
||||
}
|
||||
}
|
97
tests/cache/common_test_case.php
vendored
Normal file
97
tests/cache/common_test_case.php
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
abstract class phpbb_cache_common_test_case extends phpbb_database_test_case
|
||||
{
|
||||
public function test_get_put_exists()
|
||||
{
|
||||
$this->assertFalse($this->driver->_exists('test_key'));
|
||||
$this->assertSame(false, $this->driver->get('test_key'));
|
||||
|
||||
$this->driver->put('test_key', 'test_value');
|
||||
|
||||
$this->assertTrue($this->driver->_exists('test_key'));
|
||||
$this->assertEquals(
|
||||
'test_value',
|
||||
$this->driver->get('test_key'),
|
||||
'File ACM put and get'
|
||||
);
|
||||
}
|
||||
|
||||
public function test_purge()
|
||||
{
|
||||
$this->driver->put('test_key', 'test_value');
|
||||
|
||||
$this->assertEquals(
|
||||
'test_value',
|
||||
$this->driver->get('test_key'),
|
||||
'File ACM put and get'
|
||||
);
|
||||
|
||||
$this->driver->purge();
|
||||
|
||||
$this->assertSame(false, $this->driver->get('test_key'));
|
||||
}
|
||||
|
||||
public function test_destroy()
|
||||
{
|
||||
$this->driver->put('first_key', 'first_value');
|
||||
$this->driver->put('second_key', 'second_value');
|
||||
|
||||
$this->assertEquals(
|
||||
'first_value',
|
||||
$this->driver->get('first_key')
|
||||
);
|
||||
$this->assertEquals(
|
||||
'second_value',
|
||||
$this->driver->get('second_key')
|
||||
);
|
||||
|
||||
$this->driver->destroy('first_key');
|
||||
|
||||
$this->assertFalse($this->driver->_exists('first_key'));
|
||||
$this->assertEquals(
|
||||
'second_value',
|
||||
$this->driver->get('second_key')
|
||||
);
|
||||
}
|
||||
|
||||
public function test_cache_sql()
|
||||
{
|
||||
global $db, $cache;
|
||||
$db = $this->new_dbal();
|
||||
$cache = new phpbb_cache_service($this->driver);
|
||||
|
||||
$sql = "SELECT * FROM phpbb_config
|
||||
WHERE config_name = 'foo'";
|
||||
|
||||
$result = $db->sql_query($sql, 300);
|
||||
$first_result = $db->sql_fetchrow($result);
|
||||
$expected = array('config_name' => 'foo', 'config_value' => '23', 'is_dynamic' => 0);
|
||||
$this->assertEquals($expected, $first_result);
|
||||
|
||||
$sql = 'DELETE FROM phpbb_config';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$sql = "SELECT * FROM phpbb_config
|
||||
WHERE config_name = 'foo'";
|
||||
$result = $db->sql_query($sql, 300);
|
||||
|
||||
$this->assertEquals($expected, $db->sql_fetchrow($result));
|
||||
|
||||
$sql = "SELECT * FROM phpbb_config
|
||||
WHERE config_name = 'foo'";
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
$no_cache_result = $db->sql_fetchrow($result);
|
||||
$this->assertSame(false, $no_cache_result);
|
||||
|
||||
$db->sql_close();
|
||||
}
|
||||
}
|
69
tests/cache/file_driver_test.php
vendored
Normal file
69
tests/cache/file_driver_test.php
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2010 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/common_test_case.php';
|
||||
|
||||
class phpbb_cache_file_driver_test extends phpbb_cache_common_test_case
|
||||
{
|
||||
private $cache_dir;
|
||||
protected $driver;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->cache_dir = dirname(__FILE__) . '/../tmp/cache/';
|
||||
}
|
||||
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
if (file_exists($this->cache_dir))
|
||||
{
|
||||
// cache directory possibly left after aborted
|
||||
// or failed run earlier
|
||||
$this->remove_cache_dir();
|
||||
}
|
||||
$this->create_cache_dir();
|
||||
|
||||
$this->driver = new phpbb_cache_driver_file($this->cache_dir);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
if (file_exists($this->cache_dir))
|
||||
{
|
||||
$this->remove_cache_dir();
|
||||
}
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
private function create_cache_dir()
|
||||
{
|
||||
$this->get_test_case_helpers()->makedirs($this->cache_dir);
|
||||
}
|
||||
|
||||
private function remove_cache_dir()
|
||||
{
|
||||
$iterator = new DirectoryIterator($this->cache_dir);
|
||||
foreach ($iterator as $file)
|
||||
{
|
||||
if ($file != '.' && $file != '..')
|
||||
{
|
||||
unlink($this->cache_dir . '/' . $file);
|
||||
}
|
||||
}
|
||||
rmdir($this->cache_dir);
|
||||
}
|
||||
}
|
74
tests/cache/null_driver_test.php
vendored
Normal file
74
tests/cache/null_driver_test.php
vendored
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_cache_null_driver_test extends phpbb_database_test_case
|
||||
{
|
||||
protected $driver;
|
||||
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->driver = new phpbb_cache_driver_null;
|
||||
}
|
||||
|
||||
public function test_get_put()
|
||||
{
|
||||
$this->assertSame(false, $this->driver->get('key'));
|
||||
|
||||
$this->driver->put('key', 'value');
|
||||
|
||||
// null driver does not cache
|
||||
$this->assertSame(false, $this->driver->get('key'));
|
||||
}
|
||||
|
||||
public function test_purge()
|
||||
{
|
||||
// does nothing
|
||||
$this->driver->purge();
|
||||
}
|
||||
|
||||
public function test_destroy()
|
||||
{
|
||||
// does nothing
|
||||
$this->driver->destroy('foo');
|
||||
}
|
||||
|
||||
public function test_cache_sql()
|
||||
{
|
||||
global $db, $cache;
|
||||
$db = $this->new_dbal();
|
||||
$cache = new phpbb_cache_service($this->driver);
|
||||
|
||||
$sql = "SELECT * FROM phpbb_config
|
||||
WHERE config_name = 'foo'";
|
||||
$result = $db->sql_query($sql, 300);
|
||||
$first_result = $db->sql_fetchrow($result);
|
||||
$expected = array('config_name' => 'foo', 'config_value' => '23', 'is_dynamic' => 0);
|
||||
$this->assertEquals($expected, $first_result);
|
||||
|
||||
$sql = 'DELETE FROM phpbb_config';
|
||||
$result = $db->sql_query($sql);
|
||||
|
||||
// As null cache driver does not actually cache,
|
||||
// this should return no results
|
||||
$sql = "SELECT * FROM phpbb_config
|
||||
WHERE config_name = 'foo'";
|
||||
$result = $db->sql_query($sql, 300);
|
||||
|
||||
$this->assertSame(false, $db->sql_fetchrow($result));
|
||||
|
||||
$db->sql_close();
|
||||
}
|
||||
}
|
49
tests/cache/redis_driver_test.php
vendored
Normal file
49
tests/cache/redis_driver_test.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/common_test_case.php';
|
||||
|
||||
class phpbb_cache_redis_driver_test extends phpbb_cache_common_test_case
|
||||
{
|
||||
protected static $config;
|
||||
protected $driver;
|
||||
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/config.xml');
|
||||
}
|
||||
|
||||
static public function setUpBeforeClass()
|
||||
{
|
||||
if (!extension_loaded('redis'))
|
||||
{
|
||||
self::markTestSkipped('redis extension is not loaded');
|
||||
}
|
||||
|
||||
$config = phpbb_test_case_helpers::get_test_config();
|
||||
if (isset($config['redis_host']) || isset($config['redis_port']))
|
||||
{
|
||||
$host = isset($config['redis_host']) ? $config['redis_host'] : 'localhost';
|
||||
$port = isset($config['redis_port']) ? $config['redis_port'] : 6379;
|
||||
self::$config = array('host' => $host, 'port' => $port);
|
||||
}
|
||||
else
|
||||
{
|
||||
self::markTestSkipped('Test redis host/port is not specified');
|
||||
}
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->driver = new phpbb_cache_driver_redis(self::$config['host'], self::$config['port']);
|
||||
$this->driver->purge();
|
||||
}
|
||||
}
|
@@ -38,10 +38,16 @@ class phpbb_compress_test extends phpbb_test_case
|
||||
$phpbb_root_path = '';
|
||||
|
||||
$this->path = dirname(__FILE__) . '/fixtures/';
|
||||
}
|
||||
|
||||
if (!@extension_loaded('zlib') || !@extension_loaded('bz2'))
|
||||
protected function check_extensions($extensions)
|
||||
{
|
||||
foreach ($extensions as $extension)
|
||||
{
|
||||
$this->markTestSkipped('PHP needs to be compiled with --with-zlib and --with-bz2 in order to run these tests');
|
||||
if (!@extension_loaded($extension))
|
||||
{
|
||||
$this->markTestSkipped("$extension extension is not loaded");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,17 +120,18 @@ class phpbb_compress_test extends phpbb_test_case
|
||||
public function tar_archive_list()
|
||||
{
|
||||
return array(
|
||||
array('archive.tar', '.tar'),
|
||||
array('archive.tar.gz', '.tar.gz'),
|
||||
array('archive.tar.bz2', '.tar.bz2'),
|
||||
array('archive.tar', '.tar', array()),
|
||||
array('archive.tar.gz', '.tar.gz', array('zlib')),
|
||||
array('archive.tar.bz2', '.tar.bz2', array('bz2')),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider tar_archive_list
|
||||
*/
|
||||
public function test_extract_tar($filename, $type)
|
||||
public function test_extract_tar($filename, $type, $extensions)
|
||||
{
|
||||
$this->check_extensions($extensions);
|
||||
$compress = new compress_tar('r', $this->path . $filename);
|
||||
$compress->extract('tests/compress/' . self::EXTRACT_DIR);
|
||||
$this->valid_extraction();
|
||||
@@ -141,8 +148,10 @@ class phpbb_compress_test extends phpbb_test_case
|
||||
* @depends test_extract_tar
|
||||
* @dataProvider tar_archive_list
|
||||
*/
|
||||
public function test_compress_tar($filename, $type)
|
||||
public function test_compress_tar($filename, $type, $extensions)
|
||||
{
|
||||
$this->check_extensions($extensions);
|
||||
|
||||
$tar = dirname(__FILE__) . self::ARCHIVE_DIR . $filename;
|
||||
$compress = new compress_tar('w', $tar);
|
||||
$this->archive_files($compress);
|
||||
@@ -160,6 +169,8 @@ class phpbb_compress_test extends phpbb_test_case
|
||||
*/
|
||||
public function test_compress_zip()
|
||||
{
|
||||
$this->check_extensions(array('zlib'));
|
||||
|
||||
$zip = dirname(__FILE__) . self::ARCHIVE_DIR . 'archive.zip';
|
||||
$compress = new compress_zip('w', $zip);
|
||||
$this->archive_files($compress);
|
||||
|
3
tests/controller/config/routing.yml
Normal file
3
tests/controller/config/routing.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
core_controller:
|
||||
pattern: /core_foo
|
||||
defaults: { _controller: core_foo.controller:bar }
|
3
tests/controller/config/services.yml
Normal file
3
tests/controller/config/services.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
services:
|
||||
core_foo.controller:
|
||||
class: phpbb_controller_foo
|
76
tests/controller/controller_test.php
Normal file
76
tests/controller/controller_test.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?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\HttpFoundation\Request;
|
||||
use Symfony\Component\Routing\Route;
|
||||
use Symfony\Component\Routing\RouteCollection;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
|
||||
|
||||
class phpbb_controller_test extends phpbb_test_case
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
$this->extension_manager = new phpbb_mock_extension_manager(
|
||||
dirname(__FILE__) . '/',
|
||||
array(
|
||||
'foo' => array(
|
||||
'ext_name' => 'foo',
|
||||
'ext_active' => '1',
|
||||
'ext_path' => 'ext/foo/',
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
public function test_provider()
|
||||
{
|
||||
$provider = new phpbb_controller_provider;
|
||||
$routes = $provider
|
||||
->import_paths_from_finder($this->extension_manager->get_finder())
|
||||
->find('./tests/controller/');
|
||||
|
||||
// This will need to be updated if any new routes are defined
|
||||
$this->assertEquals(2, sizeof($routes));
|
||||
}
|
||||
|
||||
public function test_controller_resolver()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
// YamlFileLoader only uses one path at a time, so we need to loop
|
||||
// through all of the ones we are using.
|
||||
foreach (array(__DIR__.'/config', __DIR__.'/ext/foo/config') as $path)
|
||||
{
|
||||
$loader = new YamlFileLoader($container, new FileLocator($path));
|
||||
$loader->load('services.yml');
|
||||
}
|
||||
|
||||
// Autoloading classes within the tests folder does not work
|
||||
// so I'll include them manually.
|
||||
if (!class_exists('phpbb_ext_foo_controller'))
|
||||
{
|
||||
include(__DIR__.'/ext/foo/controller.php');
|
||||
}
|
||||
if (!class_exists('phpbb_controller_foo'))
|
||||
{
|
||||
include(__DIR__.'/includes/controller/foo.php');
|
||||
}
|
||||
|
||||
$resolver = new phpbb_controller_resolver(new phpbb_user, $container);
|
||||
$symfony_request = new Request();
|
||||
$symfony_request->attributes->set('_controller', 'foo.controller:handle');
|
||||
|
||||
$this->assertEquals($resolver->getController($symfony_request), array(new phpbb_ext_foo_controller, 'handle'));
|
||||
|
||||
$symfony_request = new Request();
|
||||
$symfony_request->attributes->set('_controller', 'core_foo.controller:bar');
|
||||
|
||||
$this->assertEquals($resolver->getController($symfony_request), array(new phpbb_controller_foo, 'bar'));
|
||||
}
|
||||
}
|
3
tests/controller/ext/foo/config/routing.yml
Normal file
3
tests/controller/ext/foo/config/routing.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
controller1:
|
||||
pattern: /foo
|
||||
defaults: { _controller: foo.controller:handle }
|
3
tests/controller/ext/foo/config/services.yml
Normal file
3
tests/controller/ext/foo/config/services.yml
Normal file
@@ -0,0 +1,3 @@
|
||||
services:
|
||||
foo.controller:
|
||||
class: phpbb_ext_foo_controller
|
16
tests/controller/ext/foo/controller.php
Normal file
16
tests/controller/ext/foo/controller.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class phpbb_ext_foo_controller
|
||||
{
|
||||
/**
|
||||
* Handle method
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
return new Response('Test', 200);
|
||||
}
|
||||
}
|
16
tests/controller/includes/controller/foo.php
Normal file
16
tests/controller/includes/controller/foo.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class phpbb_controller_foo
|
||||
{
|
||||
/**
|
||||
* Bar method
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function bar()
|
||||
{
|
||||
return new Response('bar()', 200);
|
||||
}
|
||||
}
|
@@ -1,50 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2010 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_cron_task_provider_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
$this->tasks = array(
|
||||
'phpbb_cron_task_core_dummy_task',
|
||||
'phpbb_cron_task_core_second_dummy_task',
|
||||
'phpbb_ext_testext_cron_dummy_task',
|
||||
);
|
||||
|
||||
$container = $this->getMock('Symfony\Component\DependencyInjection\TaggedContainerInterface');
|
||||
$container
|
||||
->expects($this->once())
|
||||
->method('findTaggedServiceIds')
|
||||
->will($this->returnValue(array_flip($this->tasks)));
|
||||
$container
|
||||
->expects($this->any())
|
||||
->method('get')
|
||||
->will($this->returnCallback(function ($name) {
|
||||
return new $name;
|
||||
}));
|
||||
|
||||
$this->provider = new phpbb_cron_task_provider($container);
|
||||
}
|
||||
|
||||
public function test_manager_finds_shipped_tasks()
|
||||
{
|
||||
$task_names = array();
|
||||
foreach ($this->provider as $task)
|
||||
{
|
||||
$task_names[] = $task->get_name();
|
||||
}
|
||||
sort($task_names);
|
||||
|
||||
$this->assertEquals(array(
|
||||
'phpbb_cron_task_core_dummy_task',
|
||||
'phpbb_cron_task_core_second_dummy_task',
|
||||
'phpbb_ext_testext_cron_dummy_task',
|
||||
), $task_names);
|
||||
}
|
||||
}
|
41
tests/dbal/connect_test.php
Normal file
41
tests/dbal/connect_test.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
|
||||
class phpbb_dbal_connect_test extends phpbb_database_test_case
|
||||
{
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__) . '/../fixtures/empty.xml');
|
||||
}
|
||||
|
||||
public function test_failing_connect()
|
||||
{
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
||||
$config = $this->get_database_config();
|
||||
|
||||
$db = new $config['dbms']();
|
||||
|
||||
// Failure to connect results in a trigger_error call in dbal.
|
||||
// phpunit converts triggered errors to exceptions.
|
||||
// In particular there should be no fatals here.
|
||||
try
|
||||
{
|
||||
$db->sql_connect($config['dbhost'], 'phpbbogus', 'phpbbogus', 'phpbbogus', $config['dbport']);
|
||||
$this->assertFalse(true);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
// should have a legitimate message
|
||||
$this->assertNotEmpty($e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
59
tests/dbal/write_sequence_test.php
Normal file
59
tests/dbal/write_sequence_test.php
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
|
||||
class phpbb_dbal_write_sequence_test extends phpbb_database_test_case
|
||||
{
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/three_users.xml');
|
||||
}
|
||||
|
||||
static public function write_sequence_data()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'ticket/11219',
|
||||
4,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider write_sequence_data
|
||||
*/
|
||||
public function test_write_sequence($username, $expected)
|
||||
{
|
||||
$db = $this->new_dbal();
|
||||
|
||||
// dbal uses cache
|
||||
global $cache;
|
||||
$cache = new phpbb_mock_cache();
|
||||
|
||||
$sql = 'INSERT INTO phpbb_users ' . $db->sql_build_array('INSERT', array(
|
||||
'username' => $username,
|
||||
'username_clean' => $username,
|
||||
'user_permissions' => '',
|
||||
'user_sig' => '',
|
||||
'user_occ' => '',
|
||||
'user_interests' => '',
|
||||
));
|
||||
$db->sql_query($sql);
|
||||
|
||||
$this->assertEquals($expected, $db->sql_nextid());
|
||||
|
||||
$sql = "SELECT user_id
|
||||
FROM phpbb_users
|
||||
WHERE username_clean = '" . $db->sql_escape($username) . "'";
|
||||
$result = $db->sql_query_limit($sql, 1);
|
||||
|
||||
$this->assertEquals($expected, $db->sql_fetchfield('user_id'));
|
||||
}
|
||||
}
|
71
tests/di/create_container_test.php
Normal file
71
tests/di/create_container_test.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_container.php';
|
||||
|
||||
class phpbb_di_container_test extends phpbb_test_case
|
||||
{
|
||||
public function test_phpbb_create_container()
|
||||
{
|
||||
$phpbb_root_path = __DIR__ . '/../../phpBB/';
|
||||
$extensions = array(
|
||||
new phpbb_di_extension_config(__DIR__ . '/fixtures/config.php'),
|
||||
new phpbb_di_extension_core($phpbb_root_path),
|
||||
);
|
||||
$container = phpbb_create_container($extensions, $phpbb_root_path, 'php');
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container);
|
||||
}
|
||||
|
||||
public function test_phpbb_create_install_container()
|
||||
{
|
||||
$phpbb_root_path = __DIR__ . '/../../phpBB/';
|
||||
$extensions = array(
|
||||
new phpbb_di_extension_config(__DIR__ . '/fixtures/config.php'),
|
||||
new phpbb_di_extension_core($phpbb_root_path),
|
||||
);
|
||||
$container = phpbb_create_install_container($phpbb_root_path, 'php');
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container);
|
||||
$this->assertTrue($container->isFrozen());
|
||||
}
|
||||
|
||||
public function test_phpbb_create_compiled_container()
|
||||
{
|
||||
$phpbb_root_path = __DIR__ . '/../../phpBB/';
|
||||
$extensions = array(
|
||||
new phpbb_di_extension_config(__DIR__ . '/fixtures/config.php'),
|
||||
new phpbb_di_extension_core($phpbb_root_path),
|
||||
);
|
||||
$container = phpbb_create_compiled_container($extensions, array(), $phpbb_root_path, 'php');
|
||||
|
||||
$this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container);
|
||||
$this->assertTrue($container->isFrozen());
|
||||
}
|
||||
}
|
||||
|
||||
class phpbb_db_driver_container_mock extends phpbb_db_driver
|
||||
{
|
||||
public function sql_connect()
|
||||
{
|
||||
}
|
||||
|
||||
public function sql_query()
|
||||
{
|
||||
}
|
||||
|
||||
public function sql_fetchrow()
|
||||
{
|
||||
}
|
||||
|
||||
public function sql_freeresult()
|
||||
{
|
||||
}
|
||||
}
|
11
tests/di/fixtures/config.php
Normal file
11
tests/di/fixtures/config.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
// phpBB 3.1.x auto-generated configuration file
|
||||
// Do not change anything in this file!
|
||||
$dbms = 'container_mock';
|
||||
$dbhost = '127.0.0.1';
|
||||
$dbport = '';
|
||||
$dbname = 'phpbb';
|
||||
$dbuser = 'root';
|
||||
$dbpasswd = '';
|
||||
$table_prefix = 'phpbb_';
|
||||
$acm_type = 'phpbb_cache_driver_null';
|
@@ -11,7 +11,7 @@ class phpbb_event_dispatcher_test extends phpbb_test_case
|
||||
{
|
||||
public function test_trigger_event()
|
||||
{
|
||||
$dispatcher = new phpbb_event_dispatcher();
|
||||
$dispatcher = new phpbb_event_dispatcher(new phpbb_mock_container_builder());
|
||||
|
||||
$dispatcher->addListener('core.test_event', function (phpbb_event_data $event) {
|
||||
$event['foo'] = $event['foo'] . '2';
|
||||
|
9
tests/fixtures/empty.xml
vendored
Normal file
9
tests/fixtures/empty.xml
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_sessions">
|
||||
<column>session_id</column>
|
||||
<column>session_user_id</column>
|
||||
<column>session_ip</column>
|
||||
<column>session_browser</column>
|
||||
</table>
|
||||
</dataset>
|
@@ -18,9 +18,19 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case
|
||||
|
||||
// check for logout link
|
||||
$crawler = $this->request('GET', 'index.php');
|
||||
$this->assert_response_success();
|
||||
$this->assertContains($this->lang('LOGOUT_USER', 'admin'), $crawler->filter('.navbar')->text());
|
||||
}
|
||||
|
||||
public function test_login_other()
|
||||
{
|
||||
$this->create_user('anothertestuser');
|
||||
$this->login('anothertestuser');
|
||||
$crawler = $this->request('GET', 'index.php');
|
||||
$this->assert_response_success();
|
||||
$this->assertContains('anothertestuser', $crawler->filter('.icon-logout')->text());
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends test_login
|
||||
*/
|
||||
@@ -31,10 +41,12 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case
|
||||
|
||||
// logout
|
||||
$crawler = $this->request('GET', 'ucp.php?sid=' . $this->sid . '&mode=logout');
|
||||
$this->assert_response_success();
|
||||
$this->assertContains($this->lang('LOGOUT_REDIRECT'), $crawler->filter('#message')->text());
|
||||
|
||||
// look for a register link, which should be visible only when logged out
|
||||
$crawler = $this->request('GET', 'index.php');
|
||||
$this->assert_response_success();
|
||||
$this->assertContains($this->lang('REGISTER'), $crawler->filter('.navbar')->text());
|
||||
}
|
||||
}
|
||||
|
@@ -15,18 +15,21 @@ class phpbb_functional_browse_test extends phpbb_functional_test_case
|
||||
public function test_index()
|
||||
{
|
||||
$crawler = $this->request('GET', 'index.php');
|
||||
$this->assert_response_success();
|
||||
$this->assertGreaterThan(0, $crawler->filter('.topiclist')->count());
|
||||
}
|
||||
|
||||
public function test_viewforum()
|
||||
{
|
||||
$crawler = $this->request('GET', 'viewforum.php?f=2');
|
||||
$this->assert_response_success();
|
||||
$this->assertGreaterThan(0, $crawler->filter('.topiclist')->count());
|
||||
}
|
||||
|
||||
public function test_viewtopic()
|
||||
{
|
||||
$crawler = $this->request('GET', 'viewtopic.php?t=1');
|
||||
$this->assert_response_success();
|
||||
$this->assertGreaterThan(0, $crawler->filter('.postbody')->count());
|
||||
}
|
||||
}
|
||||
|
@@ -13,6 +13,14 @@
|
||||
class phpbb_functional_extension_controller_test extends phpbb_functional_test_case
|
||||
{
|
||||
protected $phpbb_extension_manager;
|
||||
|
||||
static protected $fixtures = array(
|
||||
'foo/bar/config/routing.yml',
|
||||
'foo/bar/config/services.yml',
|
||||
'foo/bar/controller/controller.php',
|
||||
'foo/bar/styles/prosilver/template/foo_bar_body.html',
|
||||
);
|
||||
|
||||
/**
|
||||
* This should only be called once before the tests are run.
|
||||
* This is used to copy the fixtures to the phpBB install
|
||||
@@ -22,15 +30,11 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
|
||||
global $phpbb_root_path;
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
// these directories need to be created before the files can be copied
|
||||
$directories = array(
|
||||
$phpbb_root_path . 'ext/error/class/',
|
||||
$phpbb_root_path . 'ext/error/classtype/',
|
||||
$phpbb_root_path . 'ext/error/disabled/',
|
||||
$phpbb_root_path . 'ext/foo/bar/',
|
||||
$phpbb_root_path . 'ext/foo/bar/styles/prosilver/template/',
|
||||
$phpbb_root_path . 'ext/foobar/',
|
||||
$phpbb_root_path . 'ext/foobar/styles/prosilver/template/',
|
||||
$phpbb_root_path . 'ext/foo/bar/config/',
|
||||
$phpbb_root_path . 'ext/foo/bar/controller/',
|
||||
$phpbb_root_path . 'ext/foo/bar/styles/prosilver/template',
|
||||
);
|
||||
|
||||
foreach ($directories as $dir)
|
||||
@@ -41,30 +45,36 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
|
||||
}
|
||||
}
|
||||
|
||||
$fixtures = array(
|
||||
'error/class/controller.php',
|
||||
'error/class/ext.php',
|
||||
'error/classtype/controller.php',
|
||||
'error/classtype/ext.php',
|
||||
'error/disabled/controller.php',
|
||||
'error/disabled/ext.php',
|
||||
'foo/bar/controller.php',
|
||||
'foo/bar/ext.php',
|
||||
'foo/bar/styles/prosilver/template/foobar_body.html',
|
||||
'foobar/controller.php',
|
||||
'foobar/ext.php',
|
||||
'foobar/styles/prosilver/template/foobar_body.html',
|
||||
);
|
||||
|
||||
foreach ($fixtures as $fixture)
|
||||
foreach (self::$fixtures as $fixture)
|
||||
{
|
||||
if (!copy("tests/functional/fixtures/ext/$fixture", "{$phpbb_root_path}ext/$fixture"))
|
||||
{
|
||||
echo 'Could not copy file ' . $fixture;
|
||||
}
|
||||
copy(
|
||||
"tests/functional/fixtures/ext/$fixture",
|
||||
"{$phpbb_root_path}ext/$fixture");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This should only be called once after the tests are run.
|
||||
* This is used to remove the fixtures from the phpBB install
|
||||
*/
|
||||
static public function tearDownAfterClass()
|
||||
{
|
||||
global $phpbb_root_path;
|
||||
|
||||
foreach (self::$fixtures as $fixture)
|
||||
{
|
||||
unlink("{$phpbb_root_path}ext/$fixture");
|
||||
}
|
||||
|
||||
rmdir("{$phpbb_root_path}ext/foo/bar/config");
|
||||
rmdir("{$phpbb_root_path}ext/foo/bar/controller");
|
||||
rmdir("{$phpbb_root_path}ext/foo/bar/styles/prosilver/template");
|
||||
rmdir("{$phpbb_root_path}ext/foo/bar/styles/prosilver");
|
||||
rmdir("{$phpbb_root_path}ext/foo/bar/styles");
|
||||
rmdir("{$phpbb_root_path}ext/foo/bar");
|
||||
rmdir("{$phpbb_root_path}ext/foo");
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
@@ -75,70 +85,67 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
|
||||
}
|
||||
|
||||
/**
|
||||
* Check an extension at ./ext/foobar/ which should have the class
|
||||
* phpbb_ext_foobar_controller
|
||||
*/
|
||||
public function test_foobar()
|
||||
{
|
||||
$this->phpbb_extension_manager->enable('foobar');
|
||||
$crawler = $this->request('GET', 'index.php?ext=foobar');
|
||||
$this->assertContains("This is for testing purposes.", $crawler->filter('#page-body')->text());
|
||||
$this->phpbb_extension_manager->purge('foobar');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check an extension at ./ext/foo/bar/ which should have the class
|
||||
* phpbb_ext_foo_bar_controller
|
||||
* Check a controller for extension foo/bar.
|
||||
*/
|
||||
public function test_foo_bar()
|
||||
{
|
||||
$this->phpbb_extension_manager->enable('foo/bar');
|
||||
$crawler = $this->request('GET', 'index.php?ext=foo/bar');
|
||||
$this->assertContains("This is for testing purposes.", $crawler->filter('#page-body')->text());
|
||||
$crawler = $this->request('GET', 'app.php?controller=foo/bar');
|
||||
$this->assert_response_success();
|
||||
$this->assertContains("foo/bar controller handle() method", $crawler->filter('body')->text());
|
||||
$this->phpbb_extension_manager->purge('foo/bar');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the error produced by extension at ./ext/error/class which has class
|
||||
* phpbb_ext_foobar_controller
|
||||
* Check the output of a controller using the template system
|
||||
*/
|
||||
public function test_error_class_name()
|
||||
public function test_controller_with_template()
|
||||
{
|
||||
$this->phpbb_extension_manager->enable('error/class');
|
||||
$crawler = $this->request('GET', 'index.php?ext=error/class');
|
||||
$this->assertContains("The extension error/class is missing a controller class and cannot be accessed through the front-end.", $crawler->filter('#message')->text());
|
||||
$this->phpbb_extension_manager->purge('error/class');
|
||||
$this->phpbb_extension_manager->enable('foo/bar');
|
||||
$crawler = $this->request('GET', 'app.php?controller=foo/template');
|
||||
$this->assert_response_success();
|
||||
$this->assertContains("I am a variable", $crawler->filter('#content')->text());
|
||||
$this->phpbb_extension_manager->purge('foo/bar');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the error produced by extension at ./ext/error/classtype which has class
|
||||
* phpbb_ext_error_classtype_controller but does not implement phpbb_extension_controller_interface
|
||||
* Check the error produced by calling a controller without a required
|
||||
* argument.
|
||||
*/
|
||||
public function test_error_class_type()
|
||||
public function test_missing_argument()
|
||||
{
|
||||
$this->phpbb_extension_manager->enable('error/classtype');
|
||||
$crawler = $this->request('GET', 'index.php?ext=error/classtype');
|
||||
$this->assertContains("The extension controller class phpbb_ext_error_classtype_controller is not an instance of the phpbb_extension_controller_interface.", $crawler->filter('#message')->text());
|
||||
$this->phpbb_extension_manager->purge('error/classtype');
|
||||
$this->phpbb_extension_manager->enable('foo/bar');
|
||||
$crawler = $this->request('GET', 'app.php?controller=foo/baz');
|
||||
$this->assertEquals(500, $this->client->getResponse()->getStatus());
|
||||
$this->assertContains('Missing value for argument #1: test in class phpbb_ext_foo_bar_controller:baz', $crawler->filter('body')->text());
|
||||
$this->phpbb_extension_manager->purge('foo/bar');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the error produced by extension at ./ext/error/disabled that is (obviously)
|
||||
* a disabled extension
|
||||
* Check the status code resulting from an exception thrown by a controller
|
||||
*/
|
||||
public function test_error_ext_disabled()
|
||||
public function test_exception_should_result_in_500_status_code()
|
||||
{
|
||||
$crawler = $this->request('GET', 'index.php?ext=error/disabled');
|
||||
$this->assertContains("The extension error/disabled is not enabled", $crawler->filter('#message')->text());
|
||||
$this->phpbb_extension_manager->enable('foo/bar');
|
||||
$crawler = $this->request('GET', 'app.php?controller=foo/exception');
|
||||
$this->assertEquals(500, $this->client->getResponse()->getStatus());
|
||||
$this->assertContains('Exception thrown from foo/exception route', $crawler->filter('body')->text());
|
||||
$this->phpbb_extension_manager->purge('foo/bar');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the error produced by extension at ./ext/error/404 that is (obviously)
|
||||
* not existant
|
||||
* Check the error produced by extension at ./ext/does/not/exist.
|
||||
*
|
||||
* If an extension is disabled, its routes are not loaded. Because we
|
||||
* are not looking for a controller based on a specified extension,
|
||||
* we don't know the difference between a route in a disabled
|
||||
* extension and a route that is not defined anyway; it is the same
|
||||
* error message.
|
||||
*/
|
||||
public function test_error_ext_missing()
|
||||
public function test_error_ext_disabled_or_404()
|
||||
{
|
||||
$crawler = $this->request('GET', 'index.php?ext=error/404');
|
||||
$this->assertContains("The extension error/404 does not exist.", $crawler->filter('#message')->text());
|
||||
$crawler = $this->request('GET', 'app.php?controller=does/not/exist');
|
||||
$this->assertEquals(404, $this->client->getResponse()->getStatus());
|
||||
$this->assertContains('No route found for "GET /does/not/exist"', $crawler->filter('body')->text());
|
||||
}
|
||||
}
|
||||
|
@@ -64,6 +64,9 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case
|
||||
public function test_valid_file()
|
||||
{
|
||||
$crawler = $this->upload_file('valid.jpg', 'image/jpeg');
|
||||
$this->assert_response_success();
|
||||
// ensure there was no error message rendered
|
||||
$this->assertNotContains('<h2>' . $this->lang('INFORMATION') . '</h2>', $this->client->getResponse()->getContent());
|
||||
$this->assertContains($this->lang('POSTED_ATTACHMENTS'), $crawler->filter('#postform h3')->eq(1)->text());
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
class phpbb_ext_foobar_controller extends phpbb_extension_controller
|
||||
{
|
||||
public function handle()
|
||||
{
|
||||
$this->template->set_filenames(array(
|
||||
'body' => 'index_body.html'
|
||||
));
|
||||
|
||||
page_header('Test extension');
|
||||
page_footer();
|
||||
}
|
||||
}
|
@@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class phpbb_ext_error_class_ext extends phpbb_extension_base
|
||||
{
|
||||
|
||||
}
|
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
class phpbb_ext_error_classtype_controller
|
||||
{
|
||||
public function handle()
|
||||
{
|
||||
global $template;
|
||||
$template->set_filenames(array(
|
||||
'body' => 'index_body.html'
|
||||
));
|
||||
|
||||
page_header('Test extension');
|
||||
page_footer();
|
||||
}
|
||||
}
|
@@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class phpbb_ext_error_classtype_ext extends phpbb_extension_base
|
||||
{
|
||||
|
||||
}
|
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
class phpbb_ext_error_disabled_controller extends phpbb_extension_controller
|
||||
{
|
||||
public function handle()
|
||||
{
|
||||
$this->template->set_filenames(array(
|
||||
'body' => 'index_body.html'
|
||||
));
|
||||
|
||||
page_header('Test extension');
|
||||
page_footer();
|
||||
}
|
||||
}
|
@@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class phpbb_ext_error_disabled_ext extends phpbb_extension_base
|
||||
{
|
||||
|
||||
}
|
15
tests/functional/fixtures/ext/foo/bar/config/routing.yml
Normal file
15
tests/functional/fixtures/ext/foo/bar/config/routing.yml
Normal file
@@ -0,0 +1,15 @@
|
||||
foo_bar_controller:
|
||||
pattern: /foo/bar
|
||||
defaults: { _controller: foo_bar.controller:handle }
|
||||
|
||||
foo_baz_controller:
|
||||
pattern: /foo/baz
|
||||
defaults: { _controller: foo_bar.controller:baz }
|
||||
|
||||
foo_template_controller:
|
||||
pattern: /foo/template
|
||||
defaults: { _controller: foo_bar.controller:template }
|
||||
|
||||
foo_exception_controller:
|
||||
pattern: /foo/exception
|
||||
defaults: { _controller: foo_bar.controller:exception }
|
@@ -0,0 +1,6 @@
|
||||
services:
|
||||
foo_bar.controller:
|
||||
class: phpbb_ext_foo_bar_controller
|
||||
arguments:
|
||||
- @controller.helper
|
||||
- @template
|
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
class phpbb_ext_foo_bar_controller extends phpbb_extension_controller
|
||||
{
|
||||
public function handle()
|
||||
{
|
||||
$this->template->set_filenames(array(
|
||||
'body' => 'foobar_body.html'
|
||||
));
|
||||
|
||||
page_header('Test extension');
|
||||
page_footer();
|
||||
}
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class phpbb_ext_foo_bar_controller
|
||||
{
|
||||
protected $template;
|
||||
|
||||
public function __construct(phpbb_controller_helper $helper, phpbb_template $template)
|
||||
{
|
||||
$this->template = $template;
|
||||
$this->helper = $helper;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
return new Response('foo/bar controller handle() method', 200);
|
||||
}
|
||||
|
||||
public function baz($test)
|
||||
{
|
||||
return new Response('Value of "test" URL argument is: ' . $test);
|
||||
}
|
||||
|
||||
public function template()
|
||||
{
|
||||
$this->template->assign_var('A_VARIABLE', 'I am a variable');
|
||||
|
||||
return $this->helper->render('foo_bar_body.html');
|
||||
}
|
||||
|
||||
public function exception()
|
||||
{
|
||||
throw new phpbb_controller_exception('Exception thrown from foo/exception route');
|
||||
}
|
||||
}
|
@@ -2,5 +2,5 @@
|
||||
|
||||
class phpbb_ext_foo_bar_ext extends phpbb_extension_base
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
@@ -1,5 +1,3 @@
|
||||
<!-- INCLUDE overall_header.html -->
|
||||
|
||||
<div id="welcome">This is for testing purposes.</div>
|
||||
|
||||
<div id="content">{A_VARIABLE}</div>
|
||||
<!-- INCLUDE overall_footer.html -->
|
@@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
class phpbb_ext_foobar_controller extends phpbb_extension_controller
|
||||
{
|
||||
public function handle()
|
||||
{
|
||||
$this->template->set_filenames(array(
|
||||
'body' => 'foobar_body.html'
|
||||
));
|
||||
|
||||
page_header('Test extension');
|
||||
page_footer();
|
||||
}
|
||||
}
|
@@ -1,6 +0,0 @@
|
||||
<?php
|
||||
|
||||
class phpbb_ext_foobar_ext extends phpbb_extension_base
|
||||
{
|
||||
|
||||
}
|
@@ -1,5 +0,0 @@
|
||||
<!-- INCLUDE overall_header.html -->
|
||||
|
||||
<div id="welcome">This is for testing purposes.</div>
|
||||
|
||||
<!-- INCLUDE overall_footer.html -->
|
43
tests/functional/memberlist_test.php
Normal file
43
tests/functional/memberlist_test.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group functional
|
||||
*/
|
||||
class phpbb_functional_memberlist_test extends phpbb_functional_test_case
|
||||
{
|
||||
public function test_memberlist()
|
||||
{
|
||||
$this->create_user('memberlist-test-user');
|
||||
// logs in as admin
|
||||
$this->login();
|
||||
$crawler = $this->request('GET', 'memberlist.php?sid=' . $this->sid);
|
||||
$this->assert_response_success();
|
||||
$this->assertContains('memberlist-test-user', $crawler->text());
|
||||
|
||||
// restrict by first character
|
||||
$crawler = $this->request('GET', 'memberlist.php?first_char=m&sid=' . $this->sid);
|
||||
$this->assert_response_success();
|
||||
$this->assertContains('memberlist-test-user', $crawler->text());
|
||||
|
||||
// make sure results for wrong character are not returned
|
||||
$crawler = $this->request('GET', 'memberlist.php?first_char=a&sid=' . $this->sid);
|
||||
$this->assert_response_success();
|
||||
$this->assertNotContains('memberlist-test-user', $crawler->text());
|
||||
}
|
||||
|
||||
public function test_viewprofile()
|
||||
{
|
||||
$this->login();
|
||||
// XXX hardcoded user id
|
||||
$crawler = $this->request('GET', 'memberlist.php?mode=viewprofile&u=2&sid=' . $this->sid);
|
||||
$this->assert_response_success();
|
||||
$this->assertContains('admin', $crawler->filter('h2')->text());
|
||||
}
|
||||
}
|
@@ -15,24 +15,93 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
|
||||
public function test_post_new_topic()
|
||||
{
|
||||
$this->login();
|
||||
|
||||
// Test creating topic
|
||||
$post = $this->create_topic(2, 'Test Topic 1', 'This is a test topic posted by the testing framework.');
|
||||
|
||||
$crawler = $this->request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
|
||||
$this->assertContains('This is a test topic posted by the testing framework.', $crawler->filter('html')->text());
|
||||
|
||||
// Test creating a reply
|
||||
$post2 = $this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', 'This is a test post posted by the testing framework.');
|
||||
|
||||
$crawler = $this->request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}");
|
||||
$this->assertContains('This is a test post posted by the testing framework.', $crawler->filter('html')->text());
|
||||
|
||||
// Test quoting a message
|
||||
$crawler = $this->request('GET', "posting.php?mode=quote&f=2&t={$post2['topic_id']}&p={$post2['post_id']}&sid={$this->sid}");
|
||||
$this->assert_response_success();
|
||||
$this->assertContains('This is a test post posted by the testing framework.', $crawler->filter('html')->text());
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a topic
|
||||
*
|
||||
* Be sure to login before creating
|
||||
*
|
||||
* @param int $forum_id
|
||||
* @param string $subject
|
||||
* @param string $message
|
||||
* @param array $additional_form_data Any additional form data to be sent in the request
|
||||
* @return array post_id, topic_id
|
||||
*/
|
||||
public function create_topic($forum_id, $subject, $message, $additional_form_data = array())
|
||||
{
|
||||
$posting_url = "posting.php?mode=post&f={$forum_id}&sid={$this->sid}";
|
||||
|
||||
$form_data = array_merge(array(
|
||||
'subject' => $subject,
|
||||
'message' => $message,
|
||||
'post' => true,
|
||||
), $additional_form_data);
|
||||
|
||||
return $this->submit_post($posting_url, 'POST_TOPIC', $form_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a post
|
||||
*
|
||||
* Be sure to login before creating
|
||||
*
|
||||
* @param int $forum_id
|
||||
* @param string $subject
|
||||
* @param string $message
|
||||
* @param array $additional_form_data Any additional form data to be sent in the request
|
||||
* @return array post_id, topic_id
|
||||
*/
|
||||
public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array())
|
||||
{
|
||||
$posting_url = "posting.php?mode=reply&f={$forum_id}&t={$topic_id}&sid={$this->sid}";
|
||||
|
||||
$form_data = array_merge(array(
|
||||
'subject' => $subject,
|
||||
'message' => $message,
|
||||
'post' => true,
|
||||
), $additional_form_data);
|
||||
|
||||
return $this->submit_post($posting_url, 'POST_REPLY', $form_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper for submitting posts
|
||||
*
|
||||
* @param string $posting_url
|
||||
* @param string $posting_contains
|
||||
* @param array $form_data
|
||||
* @return array post_id, topic_id
|
||||
*/
|
||||
protected function submit_post($posting_url, $posting_contains, $form_data)
|
||||
{
|
||||
$this->add_lang('posting');
|
||||
|
||||
$crawler = $this->request('GET', 'posting.php?mode=post&f=2&sid=' . $this->sid);
|
||||
$this->assertContains($this->lang('POST_TOPIC'), $crawler->filter('html')->text());
|
||||
$crawler = $this->request('GET', $posting_url);
|
||||
$this->assert_response_success();
|
||||
$this->assertContains($this->lang($posting_contains), $crawler->filter('html')->text());
|
||||
|
||||
$hidden_fields = array();
|
||||
$hidden_fields[] = $crawler->filter('[type="hidden"]')->each(function ($node, $i) {
|
||||
return array('name' => $node->getAttribute('name'), 'value' => $node->getAttribute('value'));
|
||||
});
|
||||
|
||||
$test_message = 'This is a test topic posted by the testing framework.';
|
||||
$form_data = array(
|
||||
'subject' => 'Test Topic 1',
|
||||
'message' => $test_message,
|
||||
'post' => true,
|
||||
'f' => 2,
|
||||
'mode' => 'post',
|
||||
'sid' => $this->sid,
|
||||
$hidden_fields = array(
|
||||
$crawler->filter('[type="hidden"]')->each(function ($node, $i) {
|
||||
return array('name' => $node->getAttribute('name'), 'value' => $node->getAttribute('value'));
|
||||
}),
|
||||
);
|
||||
|
||||
foreach ($hidden_fields as $fields)
|
||||
@@ -50,53 +119,21 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
|
||||
// I use a request because the form submission method does not allow you to send data that is not
|
||||
// contained in one of the actual form fields that the browser sees (i.e. it ignores "hidden" inputs)
|
||||
// Instead, I send it as a request with the submit button "post" set to true.
|
||||
$crawler = $this->client->request('POST', 'posting.php', $form_data);
|
||||
$crawler = $this->client->request('POST', $posting_url, $form_data);
|
||||
$this->assert_response_success();
|
||||
$this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text());
|
||||
|
||||
$crawler = $this->request('GET', 'viewtopic.php?t=2&sid=' . $this->sid);
|
||||
$this->assertContains($test_message, $crawler->filter('html')->text());
|
||||
}
|
||||
$url = $crawler->selectLink($this->lang('VIEW_MESSAGE', '', ''))->link()->getUri();
|
||||
|
||||
$matches = $topic_id = $post_id = false;
|
||||
preg_match_all('#&t=([0-9]+)(&p=([0-9]+))?#', $url, $matches);
|
||||
|
||||
$topic_id = (int) (isset($matches[1][0])) ? $matches[1][0] : 0;
|
||||
$post_id = (int) (isset($matches[3][0])) ? $matches[3][0] : 0;
|
||||
|
||||
public function test_post_reply()
|
||||
{
|
||||
$this->login();
|
||||
$this->add_lang('posting');
|
||||
|
||||
$crawler = $this->request('GET', 'posting.php?mode=reply&t=2&f=2&sid=' . $this->sid);
|
||||
$this->assertContains($this->lang('POST_REPLY'), $crawler->filter('html')->text());
|
||||
|
||||
$hidden_fields = array();
|
||||
$hidden_fields[] = $crawler->filter('[type="hidden"]')->each(function ($node, $i) {
|
||||
return array('name' => $node->getAttribute('name'), 'value' => $node->getAttribute('value'));
|
||||
});
|
||||
|
||||
$test_message = 'This is a test post posted by the testing framework.';
|
||||
$form_data = array(
|
||||
'subject' => 'Re: Test Topic 1',
|
||||
'message' => $test_message,
|
||||
'post' => true,
|
||||
't' => 2,
|
||||
'f' => 2,
|
||||
'mode' => 'reply',
|
||||
'sid' => $this->sid,
|
||||
return array(
|
||||
'topic_id' => $topic_id,
|
||||
'post_id' => $post_id,
|
||||
);
|
||||
|
||||
foreach ($hidden_fields as $fields)
|
||||
{
|
||||
foreach($fields as $field)
|
||||
{
|
||||
$form_data[$field['name']] = $field['value'];
|
||||
}
|
||||
}
|
||||
|
||||
// For reasoning behind the following command, see the test_post_new_topic() test
|
||||
$form_data['lastclick'] = 0;
|
||||
|
||||
// Submit the post
|
||||
$crawler = $this->client->request('POST', 'posting.php', $form_data);
|
||||
$this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text());
|
||||
|
||||
$crawler = $this->request('GET', 'viewtopic.php?t=2&sid=' . $this->sid);
|
||||
$this->assertContains($test_message, $crawler->filter('html')->text());
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
|
||||
class phpbb_build_hidden_fields_for_query_params_test extends phpbb_test_case
|
||||
{
|
||||
public function build_hidden_fields_for_query_params_test_data()
|
||||
{
|
||||
return array(
|
||||
// get
|
||||
// post
|
||||
// exclude
|
||||
// expected
|
||||
array(
|
||||
array('foo' => 'bar'),
|
||||
array(),
|
||||
array(),
|
||||
"<input type='hidden' name=\"foo\" value=\"bar\" />",
|
||||
),
|
||||
array(
|
||||
array('foo' => 'bar', 'a' => 'b'),
|
||||
array(),
|
||||
array(),
|
||||
"<input type='hidden' name=\"foo\" value=\"bar\" /><input type='hidden' name=\"a\" value=\"b\" />",
|
||||
),
|
||||
array(
|
||||
array('a' => 'quote"', 'b' => '<less>'),
|
||||
array(),
|
||||
array(),
|
||||
"<input type='hidden' name=\"a\" value='quote\"' /><input type='hidden' name=\"b\" value=\"<less>\" />",
|
||||
),
|
||||
array(
|
||||
array('a' => "quotes'\""),
|
||||
array(),
|
||||
array(),
|
||||
"<input type='hidden' name=\"a\" value=\"quotes'"\" />",
|
||||
),
|
||||
array(
|
||||
array('foo' => 'bar', 'a' => 'b'),
|
||||
array('a' => 'c'),
|
||||
array(),
|
||||
"<input type='hidden' name=\"foo\" value=\"bar\" />",
|
||||
),
|
||||
// strict equality check
|
||||
array(
|
||||
array('foo' => 'bar', 'a' => '0'),
|
||||
array('a' => ''),
|
||||
array(),
|
||||
"<input type='hidden' name=\"foo\" value=\"bar\" />",
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider build_hidden_fields_for_query_params_test_data
|
||||
*/
|
||||
public function test_build_hidden_fields_for_query_params($get, $post, $exclude, $expected)
|
||||
{
|
||||
$request = new phpbb_mock_request($get, $post);
|
||||
$result = phpbb_build_hidden_fields_for_query_params($request, $exclude);
|
||||
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
}
|
40
tests/functions/convert_30_dbms_to_31_test.php
Normal file
40
tests/functions/convert_30_dbms_to_31_test.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
|
||||
class phpbb_convert_30_dbms_to_31_test extends phpbb_test_case
|
||||
{
|
||||
public function convert_30_dbms_to_31_data()
|
||||
{
|
||||
return array(
|
||||
array('firebird'),
|
||||
array('mssql'),
|
||||
array('mssql_odbc'),
|
||||
array('mssqlnative'),
|
||||
array('mysql'),
|
||||
array('mysqli'),
|
||||
array('oracle'),
|
||||
array('postgres'),
|
||||
array('sqlite'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider convert_30_dbms_to_31_data
|
||||
*/
|
||||
public function test_convert_30_dbms_to_31($input)
|
||||
{
|
||||
$expected = "phpbb_db_driver_$input";
|
||||
|
||||
$output = phpbb_convert_30_dbms_to_31($input);
|
||||
|
||||
$this->assertEquals($expected, $output);
|
||||
}
|
||||
}
|
71
tests/functions/get_formatted_filesize_test.php
Normal file
71
tests/functions/get_formatted_filesize_test.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
|
||||
class phpbb_get_formatted_filesize_test extends phpbb_test_case
|
||||
{
|
||||
public function get_formatted_filesize_test_data()
|
||||
{
|
||||
return array(
|
||||
// exact powers of 2
|
||||
array(1, '1 BYTES'),
|
||||
array(1024, '1 KIB'),
|
||||
array(1048576, '1 MIB'),
|
||||
array(1073741824, '1 GIB'),
|
||||
array(1099511627776, '1 TIB'),
|
||||
|
||||
// exact powers of 10
|
||||
array(1000, '1000 BYTES'),
|
||||
array(1000000, '976.56 KIB'),
|
||||
array(1000000000, '953.67 MIB'),
|
||||
array(1000000000000, '931.32 GIB'),
|
||||
array(100000000000000, '90.95 TIB'),
|
||||
|
||||
array(0, '0 BYTES'),
|
||||
array(2, '2 BYTES'),
|
||||
|
||||
array(1023, '1023 BYTES'),
|
||||
array(1025, '1 KIB'),
|
||||
array(1048575, '1024 KIB'),
|
||||
|
||||
// String values
|
||||
// exact powers of 2
|
||||
array('1', '1 BYTES'),
|
||||
array('1024', '1 KIB'),
|
||||
array('1048576', '1 MIB'),
|
||||
array('1073741824', '1 GIB'),
|
||||
array('1099511627776', '1 TIB'),
|
||||
|
||||
// exact powers of 10
|
||||
array('1000', '1000 BYTES'),
|
||||
array('1000000', '976.56 KIB'),
|
||||
array('1000000000', '953.67 MIB'),
|
||||
array('1000000000000', '931.32 GIB'),
|
||||
array('100000000000000', '90.95 TIB'),
|
||||
|
||||
array('0', '0 BYTES'),
|
||||
array('2', '2 BYTES'),
|
||||
|
||||
array('1023', '1023 BYTES'),
|
||||
array('1025', '1 KIB'),
|
||||
array('1048575', '1024 KIB'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider get_formatted_filesize_test_data
|
||||
*/
|
||||
public function test_get_formatted_filesize($input, $expected)
|
||||
{
|
||||
$output = get_formatted_filesize($input);
|
||||
|
||||
$this->assertEquals($expected, $output);
|
||||
}
|
||||
}
|
44
tests/functions/quoteattr_test.php
Normal file
44
tests/functions/quoteattr_test.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
|
||||
class phpbb_quoteattr_test extends phpbb_test_case
|
||||
{
|
||||
public function quoteattr_test_data()
|
||||
{
|
||||
return array(
|
||||
array('foo', null, '"foo"'),
|
||||
array('', null, '""'),
|
||||
array(' ', null, '" "'),
|
||||
array('<a>', null, '"<a>"'),
|
||||
array('&', null, '"&amp;"'),
|
||||
array('"hello"', null, "'\"hello\"'"),
|
||||
array("'hello'", null, "\"'hello'\""),
|
||||
array("\"'", null, "\""'\""),
|
||||
array("a\nb", null, '"a b"'),
|
||||
array("a\r\nb", null, '"a b"'),
|
||||
array("a\tb", null, '"a	b"'),
|
||||
array('a b', null, '"a b"'),
|
||||
array('"a<b"', null, "'\"a<b\"'"),
|
||||
array('foo', array('f' => 'z'), '"zoo"'),
|
||||
array('<a>', array('a' => '&'), '"<&>"'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider quoteattr_test_data
|
||||
*/
|
||||
public function test_quoteattr($input, $entities, $expected)
|
||||
{
|
||||
$output = phpbb_quoteattr($input, $entities);
|
||||
|
||||
$this->assertEquals($expected, $output);
|
||||
}
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_bookmarks">
|
||||
<column>user_id</column>
|
||||
<column>topic_id</column>
|
||||
|
||||
<!-- one entry for this topic -->
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
|
||||
<!-- non-conflicting entries -->
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>2</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>3</value>
|
||||
<value>3</value>
|
||||
</row>
|
||||
|
||||
<!-- conflicting entries -->
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>4</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>5</value>
|
||||
</row>
|
||||
|
||||
<!-- conflicting and non-conflicting entries -->
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>6</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>7</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>6</value>
|
||||
</row>
|
||||
</table>
|
||||
</dataset>
|
@@ -0,0 +1,80 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<dataset>
|
||||
<table name="phpbb_topics_watch">
|
||||
<column>user_id</column>
|
||||
<column>topic_id</column>
|
||||
<column>notify_status</column>
|
||||
|
||||
<!-- one entry for this topic -->
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
|
||||
<!-- non-conflicting entries -->
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>2</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>3</value>
|
||||
<value>0</value>
|
||||
</row>
|
||||
|
||||
<!-- conflicting entries, same notify status -->
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>4</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>5</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
|
||||
<!-- conflicting entries, notify status 0 into 1 -->
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>6</value>
|
||||
<value>0</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>7</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
|
||||
<!-- conflicting entries, notify status 1 into 0 -->
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>8</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>9</value>
|
||||
<value>0</value>
|
||||
</row>
|
||||
|
||||
<!-- conflicting and non-conflicting entries -->
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>10</value>
|
||||
<value>0</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>1</value>
|
||||
<value>11</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
<row>
|
||||
<value>2</value>
|
||||
<value>10</value>
|
||||
<value>1</value>
|
||||
</row>
|
||||
</table>
|
||||
</dataset>
|
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_database_helper.php';
|
||||
|
||||
class phpbb_update_rows_avoiding_duplicates_notify_status_test extends phpbb_database_test_case
|
||||
{
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/topics_watch_duplicates.xml');
|
||||
}
|
||||
|
||||
public static function fixture_data()
|
||||
{
|
||||
return array(
|
||||
// description
|
||||
// from array
|
||||
// to value
|
||||
// expected count with to value post update
|
||||
// expected notify_status values
|
||||
array(
|
||||
'trivial',
|
||||
array(1),
|
||||
1000,
|
||||
1,
|
||||
1,
|
||||
),
|
||||
array(
|
||||
'no conflict',
|
||||
array(2),
|
||||
3,
|
||||
2,
|
||||
1,
|
||||
),
|
||||
array(
|
||||
'conflict, same notify status',
|
||||
array(4),
|
||||
5,
|
||||
1,
|
||||
1,
|
||||
),
|
||||
array(
|
||||
'conflict, notify status 0 into 1',
|
||||
array(6),
|
||||
7,
|
||||
1,
|
||||
0,
|
||||
),
|
||||
array(
|
||||
'conflict, notify status 1 into 0',
|
||||
array(8),
|
||||
9,
|
||||
1,
|
||||
0,
|
||||
),
|
||||
array(
|
||||
'conflict and no conflict',
|
||||
array(10),
|
||||
11,
|
||||
2,
|
||||
0,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider fixture_data
|
||||
*/
|
||||
public function test_update($description, $from, $to, $expected_result_count, $expected_notify_status)
|
||||
{
|
||||
$db = $this->new_dbal();
|
||||
|
||||
phpbb_update_rows_avoiding_duplicates_notify_status($db, TOPICS_WATCH_TABLE, 'topic_id', $from, $to);
|
||||
|
||||
$sql = 'SELECT COUNT(*) AS remaining_rows
|
||||
FROM ' . TOPICS_WATCH_TABLE . '
|
||||
WHERE topic_id = ' . (int) $to;
|
||||
$result = $db->sql_query($sql);
|
||||
$result_count = $db->sql_fetchfield('remaining_rows');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$this->assertEquals($expected_result_count, $result_count);
|
||||
|
||||
// user id of 1 is the user being updated
|
||||
$sql = 'SELECT notify_status
|
||||
FROM ' . TOPICS_WATCH_TABLE . '
|
||||
WHERE topic_id = ' . (int) $to . '
|
||||
AND user_id = 1';
|
||||
$result = $db->sql_query($sql);
|
||||
$notify_status = $db->sql_fetchfield('notify_status');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$this->assertEquals($expected_notify_status, $notify_status);
|
||||
}
|
||||
}
|
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions_database_helper.php';
|
||||
|
||||
class phpbb_update_rows_avoiding_duplicates_test extends phpbb_database_test_case
|
||||
{
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__).'/fixtures/bookmarks_duplicates.xml');
|
||||
}
|
||||
|
||||
public static function fixture_data()
|
||||
{
|
||||
return array(
|
||||
// description
|
||||
// from array
|
||||
// to value
|
||||
// expected count with to value post update
|
||||
array(
|
||||
'trivial',
|
||||
array(1),
|
||||
10,
|
||||
1,
|
||||
),
|
||||
array(
|
||||
'no conflict',
|
||||
array(2),
|
||||
3,
|
||||
2,
|
||||
),
|
||||
array(
|
||||
'conflict',
|
||||
array(4),
|
||||
5,
|
||||
1,
|
||||
),
|
||||
array(
|
||||
'conflict and no conflict',
|
||||
array(6),
|
||||
7,
|
||||
2,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider fixture_data
|
||||
*/
|
||||
public function test_update($description, $from, $to, $expected_result_count)
|
||||
{
|
||||
$db = $this->new_dbal();
|
||||
|
||||
phpbb_update_rows_avoiding_duplicates($db, BOOKMARKS_TABLE, 'topic_id', $from, $to);
|
||||
|
||||
$sql = 'SELECT COUNT(*) AS remaining_rows
|
||||
FROM ' . BOOKMARKS_TABLE . '
|
||||
WHERE topic_id = ' . (int) $to;
|
||||
$result = $db->sql_query($sql);
|
||||
$result_count = $db->sql_fetchfield('remaining_rows');
|
||||
$db->sql_freeresult($result);
|
||||
|
||||
$this->assertEquals($expected_result_count, $result_count);
|
||||
}
|
||||
}
|
74
tests/lint_test.php
Normal file
74
tests/lint_test.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_lint_test extends phpbb_test_case
|
||||
{
|
||||
static protected $exclude;
|
||||
|
||||
static public function setUpBeforeClass()
|
||||
{
|
||||
$output = array();
|
||||
$status = 1;
|
||||
exec('(php -v) 2>&1', $output, $status);
|
||||
if ($status)
|
||||
{
|
||||
$output = implode("\n", $output);
|
||||
self::markTestSkipped("php is not in PATH or broken: $output");
|
||||
}
|
||||
|
||||
self::$exclude = array(
|
||||
// PHP Fatal error: Cannot declare class Container because the name is already in use in /var/www/projects/phpbb3/tests/../phpBB/vendor/symfony/dependency-injection/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php on line 20
|
||||
// https://gist.github.com/e003913ffd493da63cbc
|
||||
dirname(__FILE__) . '/../phpBB/vendor',
|
||||
);
|
||||
}
|
||||
|
||||
public function test_lint()
|
||||
{
|
||||
if (version_compare(PHP_VERSION, '5.3.0', '<'))
|
||||
{
|
||||
$this->markTestSkipped('phpBB uses PHP 5.3 syntax in some files, linting on PHP < 5.3 will fail');
|
||||
}
|
||||
|
||||
$root = dirname(__FILE__) . '/..';
|
||||
$this->check($root);
|
||||
}
|
||||
|
||||
protected function check($root)
|
||||
{
|
||||
$dh = opendir($root);
|
||||
while (($filename = readdir($dh)) !== false)
|
||||
{
|
||||
if ($filename == '.' || $filename == '..' || $filename == 'git')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$path = $root . '/' . $filename;
|
||||
// skip symlinks to avoid infinite loops
|
||||
if (is_link($path))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (is_dir($path) && !in_array($path, self::$exclude))
|
||||
{
|
||||
$this->check($path);
|
||||
}
|
||||
else if (substr($filename, strlen($filename)-4) == '.php')
|
||||
{
|
||||
// assume php binary is called php and it is in PATH
|
||||
$cmd = '(php -l ' . escapeshellarg($path) . ') 2>&1';
|
||||
$output = array();
|
||||
$status = 1;
|
||||
exec($cmd, $output, $status);
|
||||
$output = implode("\n", $output);
|
||||
$this->assertEquals(0, $status, "php -l failed for $path:\n$output");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
109
tests/lock/flock_test.php
Normal file
109
tests/lock/flock_test.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_lock_flock_test extends phpbb_test_case
|
||||
{
|
||||
public function test_lock()
|
||||
{
|
||||
$path = __DIR__ . '/../tmp/precious';
|
||||
|
||||
$lock = new phpbb_lock_flock($path);
|
||||
$ok = $lock->acquire();
|
||||
$this->assertTrue($ok);
|
||||
$lock->release();
|
||||
}
|
||||
|
||||
public function test_consecutive_locking()
|
||||
{
|
||||
$path = __DIR__ . '/../tmp/precious';
|
||||
|
||||
$lock = new phpbb_lock_flock($path);
|
||||
$ok = $lock->acquire();
|
||||
$this->assertTrue($ok);
|
||||
$lock->release();
|
||||
|
||||
$ok = $lock->acquire();
|
||||
$this->assertTrue($ok);
|
||||
$lock->release();
|
||||
|
||||
$ok = $lock->acquire();
|
||||
$this->assertTrue($ok);
|
||||
$lock->release();
|
||||
}
|
||||
|
||||
/* This hangs the process.
|
||||
public function test_concurrent_locking_fail()
|
||||
{
|
||||
$path = __DIR__ . '/../tmp/precious';
|
||||
|
||||
$lock1 = new phpbb_lock_flock($path);
|
||||
$ok = $lock1->acquire();
|
||||
$this->assertTrue($ok);
|
||||
|
||||
$lock2 = new phpbb_lock_flock($path);
|
||||
$ok = $lock2->acquire();
|
||||
$this->assertFalse($ok);
|
||||
|
||||
$lock->release();
|
||||
$ok = $lock2->acquire();
|
||||
$this->assertTrue($ok);
|
||||
}
|
||||
*/
|
||||
|
||||
public function test_concurrent_locking()
|
||||
{
|
||||
if (!function_exists('pcntl_fork'))
|
||||
{
|
||||
$this->markTestSkipped('pcntl extension and pcntl_fork are required for this test');
|
||||
}
|
||||
|
||||
$path = __DIR__ . '/../tmp/precious';
|
||||
|
||||
$pid = pcntl_fork();
|
||||
if ($pid)
|
||||
{
|
||||
// parent
|
||||
// wait 0.5 s, acquire the lock, note how long it took
|
||||
sleep(1);
|
||||
|
||||
$lock = new phpbb_lock_flock($path);
|
||||
$start = time();
|
||||
$ok = $lock->acquire();
|
||||
$delta = time() - $start;
|
||||
$this->assertTrue($ok);
|
||||
$this->assertGreaterThan(0.5, $delta, 'First lock acquired too soon');
|
||||
|
||||
$lock->release();
|
||||
|
||||
// acquire again, this should be instantaneous
|
||||
$start = time();
|
||||
$ok = $lock->acquire();
|
||||
$delta = time() - $start;
|
||||
$this->assertTrue($ok);
|
||||
$this->assertLessThan(0.1, $delta, 'Second lock not acquired instantaneously');
|
||||
|
||||
// reap the child
|
||||
$status = null;
|
||||
pcntl_waitpid($pid, $status);
|
||||
}
|
||||
else
|
||||
{
|
||||
// child
|
||||
// immediately acquire the lock and sleep for 2 s
|
||||
$lock = new phpbb_lock_flock($path);
|
||||
$ok = $lock->acquire();
|
||||
$this->assertTrue($ok);
|
||||
sleep(2);
|
||||
$lock->release();
|
||||
|
||||
// and go away silently
|
||||
pcntl_exec('/usr/bin/env', array('true'));
|
||||
}
|
||||
}
|
||||
}
|
@@ -123,6 +123,7 @@ class phpbb_mock_cache implements phpbb_cache_driver_interface
|
||||
}
|
||||
public function sql_save($query, $query_result, $ttl)
|
||||
{
|
||||
return $query_result;
|
||||
}
|
||||
public function sql_exists($query_id)
|
||||
{
|
||||
|
160
tests/mock/container_builder.php
Normal file
160
tests/mock/container_builder.php
Normal file
@@ -0,0 +1,160 @@
|
||||
<?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
|
||||
{
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a parameter exists.
|
||||
*
|
||||
* @param string $name The parameter name
|
||||
*
|
||||
* @return Boolean The presence of parameter in container
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function hasParameter($name)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a parameter.
|
||||
*
|
||||
* @param string $name The parameter name
|
||||
* @param mixed $value The parameter value
|
||||
*
|
||||
* @api
|
||||
*/
|
||||
public function setParameter($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)
|
||||
{
|
||||
}
|
||||
}
|
32
tests/mock/filesystem_extension_manager.php
Normal file
32
tests/mock/filesystem_extension_manager.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_mock_filesystem_extension_manager extends phpbb_mock_extension_manager
|
||||
{
|
||||
public function __construct($phpbb_root_path)
|
||||
{
|
||||
$extensions = array();
|
||||
$iterator = new DirectoryIterator($phpbb_root_path . 'ext/');
|
||||
foreach ($iterator as $fileinfo)
|
||||
{
|
||||
if ($fileinfo->isDir() && substr($fileinfo->getFilename(), 0, 1) != '.')
|
||||
{
|
||||
$name = $fileinfo->getFilename();
|
||||
$extension = array(
|
||||
'ext_name' => $name,
|
||||
'ext_active' => true,
|
||||
'ext_path' => 'ext/' . $name . '/',
|
||||
);
|
||||
$extensions[$name] = $extension;
|
||||
}
|
||||
}
|
||||
ksort($extensions);
|
||||
parent::__construct($phpbb_root_path, $extensions);
|
||||
}
|
||||
}
|
@@ -20,33 +20,4 @@ class phpbb_mock_fileupload
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copied verbatim from phpBB/includes/functions_upload.php's fileupload
|
||||
* class to ensure the correct behaviour of filespec::move_file.
|
||||
*
|
||||
* Maps file extensions to the constant in second index of the array
|
||||
* returned by getimagesize()
|
||||
*/
|
||||
public function image_types()
|
||||
{
|
||||
return array(
|
||||
IMAGETYPE_GIF => array('gif'),
|
||||
IMAGETYPE_JPEG => array('jpg', 'jpeg'),
|
||||
IMAGETYPE_PNG => array('png'),
|
||||
IMAGETYPE_SWF => array('swf'),
|
||||
IMAGETYPE_PSD => array('psd'),
|
||||
IMAGETYPE_BMP => array('bmp'),
|
||||
IMAGETYPE_TIFF_II => array('tif', 'tiff'),
|
||||
IMAGETYPE_TIFF_MM => array('tif', 'tiff'),
|
||||
IMAGETYPE_JPC => array('jpg', 'jpeg'),
|
||||
IMAGETYPE_JP2 => array('jpg', 'jpeg'),
|
||||
IMAGETYPE_JPX => array('jpg', 'jpeg'),
|
||||
IMAGETYPE_JB2 => array('jpg', 'jpeg'),
|
||||
IMAGETYPE_SWC => array('swc'),
|
||||
IMAGETYPE_IFF => array('iff'),
|
||||
IMAGETYPE_WBMP => array('wbmp'),
|
||||
IMAGETYPE_XBM => array('xbm'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
47
tests/mock/null_cache.php
Normal file
47
tests/mock/null_cache.php
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
class phpbb_mock_null_cache
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function get($var_name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function put($var_name, $var, $ttl = 0)
|
||||
{
|
||||
}
|
||||
|
||||
public function destroy($var_name, $table = '')
|
||||
{
|
||||
}
|
||||
|
||||
public function obtain_bots()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
public function obtain_word_list()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
public function set_bots($bots)
|
||||
{
|
||||
}
|
||||
|
||||
public function sql_exists($query_id)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
@@ -11,13 +11,14 @@ class phpbb_mock_request implements phpbb_request_interface
|
||||
{
|
||||
protected $data;
|
||||
|
||||
public function __construct($get = array(), $post = array(), $cookie = array(), $server = array(), $request = false)
|
||||
public function __construct($get = array(), $post = array(), $cookie = array(), $server = array(), $request = false, $files = array())
|
||||
{
|
||||
$this->data[phpbb_request_interface::GET] = $get;
|
||||
$this->data[phpbb_request_interface::POST] = $post;
|
||||
$this->data[phpbb_request_interface::COOKIE] = $cookie;
|
||||
$this->data[phpbb_request_interface::REQUEST] = ($request === false) ? $post + $get : $request;
|
||||
$this->data[phpbb_request_interface::SERVER] = $server;
|
||||
$this->data[phpbb_request_interface::FILES] = $files;
|
||||
}
|
||||
|
||||
public function overwrite($var_name, $value, $super_global = phpbb_request_interface::REQUEST)
|
||||
@@ -42,6 +43,12 @@ class phpbb_mock_request implements phpbb_request_interface
|
||||
return $this->server($var_name, $default);
|
||||
}
|
||||
|
||||
public function file($form_name)
|
||||
{
|
||||
$super_global = phpbb_request_interface::FILES;
|
||||
return isset($this->data[$super_global][$form_name]) ? $this->data[$super_global][$form_name] : array();
|
||||
}
|
||||
|
||||
public function is_set_post($name)
|
||||
{
|
||||
return $this->is_set($name, phpbb_request_interface::POST);
|
||||
|
@@ -21,6 +21,13 @@ class phpbb_request_test extends phpbb_test_case
|
||||
$_COOKIE['test'] = 3;
|
||||
$_REQUEST['test'] = 3;
|
||||
$_GET['unset'] = '';
|
||||
$_FILES['test'] = array(
|
||||
'name' => 'file',
|
||||
'tmp_name' => 'tmp',
|
||||
'size' => 256,
|
||||
'type' => 'application/octet-stream',
|
||||
'error' => UPLOAD_ERR_OK,
|
||||
);
|
||||
|
||||
$_SERVER['HTTP_HOST'] = 'example.com';
|
||||
$_SERVER['HTTP_ACCEPT'] = 'application/json';
|
||||
@@ -42,6 +49,7 @@ class phpbb_request_test extends phpbb_test_case
|
||||
$this->assertEquals(2, $_GET['test'], 'Checking $_GET after enable_super_globals');
|
||||
$this->assertEquals(3, $_COOKIE['test'], 'Checking $_COOKIE after enable_super_globals');
|
||||
$this->assertEquals(3, $_REQUEST['test'], 'Checking $_REQUEST after enable_super_globals');
|
||||
$this->assertEquals(256, $_FILES['test']['size']);
|
||||
|
||||
$_POST['x'] = 2;
|
||||
$this->assertEquals($_POST, $GLOBALS['_POST'], 'Checking whether $_POST can still be accessed via $GLOBALS[\'_POST\']');
|
||||
@@ -85,6 +93,23 @@ class phpbb_request_test extends phpbb_test_case
|
||||
$this->request->header('SOMEVAR');
|
||||
}
|
||||
|
||||
public function test_file()
|
||||
{
|
||||
$file = $this->request->file('test');
|
||||
$this->assertEquals('file', $file['name']);
|
||||
$this->assertEquals('tmp', $file['tmp_name']);
|
||||
$this->assertEquals(256, $file['size']);
|
||||
$this->assertEquals('application/octet-stream', $file['type']);
|
||||
$this->assertEquals(UPLOAD_ERR_OK, $file['error']);
|
||||
}
|
||||
|
||||
public function test_file_not_exists()
|
||||
{
|
||||
$file = $this->request->file('404');
|
||||
$this->assertTrue(is_array($file));
|
||||
$this->assertTrue(empty($file));
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that directly accessing $_POST will trigger
|
||||
* an error.
|
||||
|
106
tests/search/common_test_case.php
Normal file
106
tests/search/common_test_case.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/../test_framework/phpbb_search_test_case.php';
|
||||
|
||||
abstract class phpbb_search_common_test_case extends phpbb_search_test_case
|
||||
{
|
||||
public function keywords()
|
||||
{
|
||||
return array(
|
||||
// keywords
|
||||
// terms
|
||||
// ok
|
||||
// split words
|
||||
// common words
|
||||
array(
|
||||
'fooo',
|
||||
'all',
|
||||
true,
|
||||
array('fooo'),
|
||||
array(),
|
||||
),
|
||||
array(
|
||||
'fooo baar',
|
||||
'all',
|
||||
true,
|
||||
array('fooo', 'baar'),
|
||||
array(),
|
||||
),
|
||||
// leading, trailing and multiple spaces
|
||||
array(
|
||||
' fooo baar ',
|
||||
'all',
|
||||
true,
|
||||
array('fooo', 'baar'),
|
||||
array(),
|
||||
),
|
||||
// words too short
|
||||
array(
|
||||
'f',
|
||||
'all',
|
||||
false,
|
||||
null,
|
||||
// short words count as "common" words
|
||||
array('f'),
|
||||
),
|
||||
array(
|
||||
'f o o',
|
||||
'all',
|
||||
false,
|
||||
null,
|
||||
array('f', 'o', 'o'),
|
||||
),
|
||||
array(
|
||||
'f -o -o',
|
||||
'all',
|
||||
false,
|
||||
null,
|
||||
array('f', '-o', '-o'),
|
||||
),
|
||||
array(
|
||||
'fooo -baar',
|
||||
'all',
|
||||
true,
|
||||
array('-baar', 'fooo'),
|
||||
array(),
|
||||
),
|
||||
// all negative
|
||||
array(
|
||||
'-fooo',
|
||||
'all',
|
||||
true,
|
||||
array('-fooo'),
|
||||
array(),
|
||||
),
|
||||
array(
|
||||
'-fooo -baar',
|
||||
'all',
|
||||
true,
|
||||
array('-fooo', '-baar'),
|
||||
array(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider keywords
|
||||
*/
|
||||
public function test_split_keywords($keywords, $terms, $ok, $split_words, $common)
|
||||
{
|
||||
$rv = $this->search->split_keywords($keywords, $terms);
|
||||
$this->assertEquals($ok, $rv);
|
||||
if ($ok)
|
||||
{
|
||||
// only check criteria if the search is going to be performed
|
||||
$this->assert_array_content_equals($split_words, $this->search->get_split_words());
|
||||
}
|
||||
$this->assert_array_content_equals($common, $this->search->get_common_words());
|
||||
}
|
||||
}
|
40
tests/search/mysql_test.php
Normal file
40
tests/search/mysql_test.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/common_test_case.php';
|
||||
|
||||
class phpbb_search_mysql_test extends phpbb_search_common_test_case
|
||||
{
|
||||
protected $db;
|
||||
protected $search;
|
||||
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__) . '/../fixtures/empty.xml');
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
global $phpbb_root_path, $phpEx, $config, $user, $cache;
|
||||
|
||||
parent::setUp();
|
||||
|
||||
// dbal uses cache
|
||||
$cache = new phpbb_mock_cache();
|
||||
|
||||
// set config values
|
||||
$config['fulltext_mysql_min_word_len'] = 4;
|
||||
$config['fulltext_mysql_max_word_len'] = 254;
|
||||
|
||||
$this->db = $this->new_dbal();
|
||||
$error = null;
|
||||
$class = self::get_search_wrapper('phpbb_search_fulltext_mysql');
|
||||
$this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $user);
|
||||
}
|
||||
}
|
@@ -7,24 +7,9 @@
|
||||
*
|
||||
*/
|
||||
|
||||
function phpbb_search_wrapper($class)
|
||||
{
|
||||
$wrapped = $class . '_wrapper';
|
||||
if (!class_exists($wrapped))
|
||||
{
|
||||
$code = "
|
||||
class $wrapped extends $class
|
||||
{
|
||||
public function get_must_contain_ids() { return \$this->must_contain_ids; }
|
||||
public function get_must_not_contain_ids() { return \$this->must_not_contain_ids; }
|
||||
}
|
||||
";
|
||||
eval($code);
|
||||
}
|
||||
return $wrapped;
|
||||
}
|
||||
require_once dirname(__FILE__) . '/../test_framework/phpbb_search_test_case.php';
|
||||
|
||||
class phpbb_search_native_test extends phpbb_database_test_case
|
||||
class phpbb_search_native_test extends phpbb_search_test_case
|
||||
{
|
||||
protected $db;
|
||||
protected $search;
|
||||
@@ -41,19 +26,14 @@ class phpbb_search_native_test extends phpbb_database_test_case
|
||||
parent::setUp();
|
||||
|
||||
// dbal uses cache
|
||||
$cache = new phpbb_cache_driver_null;
|
||||
$cache = new phpbb_mock_cache();
|
||||
|
||||
$this->db = $this->new_dbal();
|
||||
$error = null;
|
||||
$class = phpbb_search_wrapper('phpbb_search_fulltext_native');
|
||||
$class = self::get_search_wrapper('phpbb_search_fulltext_native');
|
||||
$this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $user);
|
||||
}
|
||||
|
||||
protected function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function keywords()
|
||||
{
|
||||
return array(
|
||||
@@ -106,6 +86,14 @@ class phpbb_search_native_test extends phpbb_database_test_case
|
||||
null,
|
||||
array('f', 'o', 'o'),
|
||||
),
|
||||
array(
|
||||
'f -o -o',
|
||||
'all',
|
||||
false,
|
||||
null,
|
||||
null,
|
||||
array('f', 'o', 'o'),
|
||||
),
|
||||
array(
|
||||
'foo -bar',
|
||||
'all',
|
||||
@@ -167,20 +155,4 @@ class phpbb_search_native_test extends phpbb_database_test_case
|
||||
}
|
||||
$this->assert_array_content_equals($common, $this->search->get_common_words());
|
||||
}
|
||||
|
||||
public function assert_array_content_equals($one, $two)
|
||||
{
|
||||
// http://stackoverflow.com/questions/3838288/phpunit-assert-two-arrays-are-equal-but-order-of-elements-not-important
|
||||
// but one array_diff is not enough!
|
||||
if (sizeof(array_diff($one, $two)) || sizeof(array_diff($two, $one)))
|
||||
{
|
||||
// get a nice error message
|
||||
$this->assertEquals($one, $two);
|
||||
}
|
||||
else
|
||||
{
|
||||
// increase assertion count
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
40
tests/search/postgres_test.php
Normal file
40
tests/search/postgres_test.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/common_test_case.php';
|
||||
|
||||
class phpbb_search_postgres_test extends phpbb_search_common_test_case
|
||||
{
|
||||
protected $db;
|
||||
protected $search;
|
||||
|
||||
public function getDataSet()
|
||||
{
|
||||
return $this->createXMLDataSet(dirname(__FILE__) . '/../fixtures/empty.xml');
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
global $phpbb_root_path, $phpEx, $config, $user, $cache;
|
||||
|
||||
parent::setUp();
|
||||
|
||||
// dbal uses cache
|
||||
$cache = new phpbb_mock_cache();
|
||||
|
||||
// set config values
|
||||
$config['fulltext_postgres_min_word_len'] = 4;
|
||||
$config['fulltext_postgres_max_word_len'] = 254;
|
||||
|
||||
$this->db = $this->new_dbal();
|
||||
$error = null;
|
||||
$class = self::get_search_wrapper('phpbb_search_fulltext_postgres');
|
||||
$this->search = new $class($error, $phpbb_root_path, $phpEx, null, $config, $this->db, $user);
|
||||
}
|
||||
}
|
@@ -59,10 +59,10 @@ class phpbb_session_testable_factory
|
||||
/**
|
||||
* Retrieve the configured session class instance
|
||||
*
|
||||
* @param dbal $dbal The database connection to use for session data
|
||||
* @param phpbb_db_driver $dbal The database connection to use for session data
|
||||
* @return phpbb_mock_session_testable A session instance
|
||||
*/
|
||||
public function get_session(dbal $dbal)
|
||||
public function get_session(phpbb_db_driver $dbal)
|
||||
{
|
||||
// set up all the global variables used by session
|
||||
global $SID, $_SID, $db, $config, $cache, $request;
|
||||
|
@@ -0,0 +1 @@
|
||||
Kappa test event in all
|
@@ -0,0 +1 @@
|
||||
Kappa test event in silver
|
@@ -0,0 +1 @@
|
||||
Kappa test event in silver_inherit
|
@@ -0,0 +1 @@
|
||||
Omega test event in all
|
@@ -0,0 +1 @@
|
||||
Omega test event in silver
|
@@ -0,0 +1 @@
|
||||
two in silver in omega
|
@@ -0,0 +1 @@
|
||||
Zeta test event in all
|
@@ -0,0 +1 @@
|
||||
<!-- EVENT test -->
|
@@ -0,0 +1 @@
|
||||
<!-- EVENT two -->
|
@@ -0,0 +1 @@
|
||||
<!-- EVENT test -->
|
@@ -0,0 +1 @@
|
||||
Universal in trivial extension.
|
@@ -0,0 +1 @@
|
||||
Simple in trivial extension.
|
@@ -0,0 +1 @@
|
||||
<!-- EVENT simple -->
|
@@ -0,0 +1 @@
|
||||
<!-- EVENT universal -->
|
@@ -23,6 +23,18 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case
|
||||
$this->assertEquals("Path is relative to board root.\ntesting included php", $this->display('test'), "Testing INCLUDEPHP");
|
||||
}
|
||||
|
||||
public function test_includephp_variables()
|
||||
{
|
||||
$this->setup_engine(array('tpl_allow_php' => true));
|
||||
|
||||
$cache_file = $this->template->cachepath . 'includephp_variables.html.php';
|
||||
|
||||
$this->run_template('includephp_variables.html', array('TEMPLATES' => 'templates'), array(), array(), "Path includes variables.\ntesting included php", $cache_file);
|
||||
|
||||
$this->template->set_filenames(array('test' => 'includephp_variables.html'));
|
||||
$this->assertEquals("Path includes variables.\ntesting included php", $this->display('test'), "Testing INCLUDEPHP");
|
||||
}
|
||||
|
||||
public function test_includephp_absolute()
|
||||
{
|
||||
$path_to_php = dirname(__FILE__) . '/templates/_dummy_include.php.inc';
|
||||
@@ -36,7 +48,7 @@ class phpbb_template_includephp_test extends phpbb_template_template_test_case
|
||||
|
||||
$this->setup_engine(array('tpl_allow_php' => true));
|
||||
|
||||
$this->style->set_custom_style('tests', $cache_dir, '');
|
||||
$this->style->set_custom_style('tests', $cache_dir, array(), '');
|
||||
$cache_file = $this->template->cachepath . 'includephp_absolute.html.php';
|
||||
|
||||
$this->run_template('includephp_absolute.html', array(), array(), array(), "Path is absolute.\ntesting included php", $cache_file);
|
||||
|
@@ -16,7 +16,7 @@ class phpbb_template_template_compile_test extends phpbb_test_case
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
$this->template_compile = new phpbb_template_compile(false, null, '');
|
||||
$this->template_compile = new phpbb_template_compile(false, null, $this->style_resource_locator, '');
|
||||
$this->template_path = dirname(__FILE__) . '/templates';
|
||||
}
|
||||
|
||||
|
118
tests/template/template_events_test.php
Normal file
118
tests/template/template_events_test.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2011 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/template_test_case.php';
|
||||
|
||||
class phpbb_template_template_events_test extends phpbb_template_template_test_case
|
||||
{
|
||||
public function template_data()
|
||||
{
|
||||
return array(
|
||||
/*
|
||||
array(
|
||||
'', // file
|
||||
'', // dataset
|
||||
array(), // style names
|
||||
array(), // vars
|
||||
array(), // block vars
|
||||
array(), // destroy
|
||||
'', // expected result
|
||||
),
|
||||
*/
|
||||
array(
|
||||
'Simple template event',
|
||||
'ext_trivial',
|
||||
array(),
|
||||
'event_simple.html',
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
"Simple in trivial extension.",
|
||||
),
|
||||
array(
|
||||
'Universal template event ("all" style)',
|
||||
'ext_trivial',
|
||||
array(),
|
||||
'event_universal.html',
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
"Universal in trivial extension.",
|
||||
),
|
||||
array(
|
||||
'Template event with inheritance - parent',
|
||||
'event_inheritance',
|
||||
array('silver'),
|
||||
'event_test.html',
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
'Kappa test event in all
|
||||
Omega test event in all
|
||||
Zeta test event in all
|
||||
Kappa test event in silver
|
||||
Omega test event in silver',
|
||||
),
|
||||
array(
|
||||
'Template event with inheritance - child',
|
||||
'event_inheritance',
|
||||
array('silver_inherit', 'silver'),
|
||||
'event_test.html',
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
'Kappa test event in all
|
||||
Omega test event in all
|
||||
Zeta test event in all
|
||||
Kappa test event in silver_inherit',
|
||||
),
|
||||
array(
|
||||
'Definition in parent style',
|
||||
'event_inheritance',
|
||||
array('silver_inherit', 'silver'),
|
||||
'event_two.html',
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
'two in silver in omega',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider template_data
|
||||
*/
|
||||
public function test_event($desc, $dataset, $style_names, $file, array $vars, array $block_vars, array $destroy, $expected)
|
||||
{
|
||||
// Reset the engine state
|
||||
$this->setup_engine_for_events($dataset, $style_names);
|
||||
|
||||
// Run test
|
||||
$cache_file = $this->template->cachepath . str_replace('/', '.', $file) . '.php';
|
||||
$this->run_template($file, $vars, $block_vars, $destroy, $expected, $cache_file);
|
||||
}
|
||||
|
||||
protected function setup_engine_for_events($dataset, $style_names, array $new_config = array())
|
||||
{
|
||||
global $phpbb_root_path, $phpEx, $user;
|
||||
|
||||
$defaults = $this->config_defaults();
|
||||
$config = new phpbb_config(array_merge($defaults, $new_config));
|
||||
|
||||
$this->template_path = dirname(__FILE__) . "/datasets/$dataset/styles/silver/template";
|
||||
$this->style_resource_locator = new phpbb_style_resource_locator();
|
||||
$this->extension_manager = new phpbb_mock_filesystem_extension_manager(
|
||||
dirname(__FILE__) . "/datasets/$dataset/"
|
||||
);
|
||||
$this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, new phpbb_template_context, $this->extension_manager);
|
||||
$this->style_provider = new phpbb_style_path_provider();
|
||||
$this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template);
|
||||
$this->style->set_custom_style('silver', array($this->template_path), $style_names, '');
|
||||
}
|
||||
}
|
@@ -20,11 +20,14 @@ class phpbb_template_template_includejs_test extends phpbb_template_template_tes
|
||||
$scripts = array(
|
||||
'<script src="' . $this->test_path . '/templates/parent_and_child.js?assets_version=1"></script>',
|
||||
'<script src="' . $this->test_path . '/parent_templates/parent_only.js?assets_version=1"></script>',
|
||||
'<script src="' . $this->test_path . '/templates/child_only.js?assets_version=1"></script>'
|
||||
'<script src="' . $this->test_path . '/templates/child_only.js?assets_version=1"></script>',
|
||||
'<script src="' . $this->test_path . '/templates/subdir/parent_only.js?assets_version=1"></script>',
|
||||
'<script src="' . $this->test_path . '/templates/subdir/subsubdir/parent_only.js?assets_version=1"></script>',
|
||||
'<script src="' . $this->test_path . '/templates/subdir/parent_only.js?assets_version=1"></script>',
|
||||
);
|
||||
|
||||
// Run test
|
||||
$cache_file = $this->template->cachepath . 'includejs.html.php';
|
||||
$this->run_template('includejs.html', array('PARENT' => 'parent_only.js'), array(), array(), implode('', $scripts), $cache_file);
|
||||
$this->run_template('includejs.html', array('PARENT' => 'parent_only.js', 'SUBDIR' => 'subdir', 'EXT' => 'js'), array(), array(), implode('', $scripts), $cache_file);
|
||||
}
|
||||
}
|
||||
|
@@ -62,7 +62,7 @@ class phpbb_template_template_locate_test extends phpbb_template_template_test_c
|
||||
$this->setup_engine();
|
||||
|
||||
// Locate template
|
||||
$result = $this->template->locate($files, $return_default, $return_full_path);
|
||||
$result = $this->style_resource_locator->get_first_template_location($files, $return_default, $return_full_path);
|
||||
$this->assertSame($expected, $result);
|
||||
}
|
||||
}
|
||||
|
@@ -183,6 +183,13 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
|
||||
array(),
|
||||
'value',
|
||||
),
|
||||
array(
|
||||
'include_variables.html',
|
||||
array('SUBDIR' => 'subdir', 'VARIABLE' => 'value'),
|
||||
array(),
|
||||
array(),
|
||||
'value',
|
||||
),
|
||||
array(
|
||||
'loop_vars.html',
|
||||
array(),
|
||||
|
@@ -69,7 +69,7 @@ class phpbb_template_template_test_case extends phpbb_test_case
|
||||
$this->style_provider = new phpbb_style_path_provider();
|
||||
$this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, new phpbb_template_context());
|
||||
$this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template);
|
||||
$this->style->set_custom_style('tests', $this->template_path, '');
|
||||
$this->style->set_custom_style('tests', $this->template_path, array(), '');
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
|
@@ -24,6 +24,6 @@ class phpbb_template_template_test_case_with_tree extends phpbb_template_templat
|
||||
$this->style_provider = new phpbb_style_path_provider();
|
||||
$this->template = new phpbb_template($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, new phpbb_template_context());
|
||||
$this->style = new phpbb_style($phpbb_root_path, $phpEx, $config, $user, $this->style_resource_locator, $this->style_provider, $this->template);
|
||||
$this->style->set_custom_style('tests', array($this->template_path, $this->parent_template_path), '');
|
||||
$this->style->set_custom_style('tests', array($this->template_path, $this->parent_template_path), array(), '');
|
||||
}
|
||||
}
|
||||
|
4
tests/template/templates/events.html
Normal file
4
tests/template/templates/events.html
Normal file
@@ -0,0 +1,4 @@
|
||||
<!-- EVENT child_only -->
|
||||
<!-- EVENT parent_only -->
|
||||
<!-- EVENT parent_and_child -->
|
||||
<!-- EVENT random_event -->
|
1
tests/template/templates/include_variables.html
Normal file
1
tests/template/templates/include_variables.html
Normal file
@@ -0,0 +1 @@
|
||||
<!-- INCLUDE {SUBDIR}/variable.html -->
|
@@ -2,4 +2,7 @@
|
||||
<!-- INCLUDEJS {PARENT} -->
|
||||
<!-- DEFINE $TEST = 'child_only.js' -->
|
||||
<!-- INCLUDEJS {$TEST} -->
|
||||
{SCRIPTS}
|
||||
<!-- INCLUDEJS subdir/{PARENT} -->
|
||||
<!-- INCLUDEJS {SUBDIR}/subsubdir/{PARENT} -->
|
||||
<!-- INCLUDEJS {SUBDIR}/parent_only.{EXT} -->
|
||||
{SCRIPTS}
|
||||
|
2
tests/template/templates/includephp_variables.html
Normal file
2
tests/template/templates/includephp_variables.html
Normal file
@@ -0,0 +1,2 @@
|
||||
Path includes variables.
|
||||
<!-- INCLUDEPHP ../tests/template/{TEMPLATES}/_dummy_include.php.inc -->
|
0
tests/template/templates/subdir/parent_only.js
Normal file
0
tests/template/templates/subdir/parent_only.js
Normal file
1
tests/template/templates/subdir/variable.html
Normal file
1
tests/template/templates/subdir/variable.html
Normal file
@@ -0,0 +1 @@
|
||||
{VARIABLE}
|
@@ -13,6 +13,8 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
|
||||
|
||||
protected $test_case_helpers;
|
||||
|
||||
protected $fixture_xml_data;
|
||||
|
||||
public function __construct($name = NULL, array $data = array(), $dataName = '')
|
||||
{
|
||||
parent::__construct($name, $data, $dataName);
|
||||
@@ -28,12 +30,26 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
|
||||
);
|
||||
}
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
// Resynchronise tables if a fixture was loaded
|
||||
if (isset($this->fixture_xml_data))
|
||||
{
|
||||
$config = $this->get_database_config();
|
||||
$manager = $this->create_connection_manager($config);
|
||||
$manager->connect();
|
||||
$manager->post_setup_synchronisation($this->fixture_xml_data);
|
||||
}
|
||||
}
|
||||
|
||||
public function createXMLDataSet($path)
|
||||
{
|
||||
$db_config = $this->get_database_config();
|
||||
|
||||
// Firebird requires table and column names to be uppercase
|
||||
if ($db_config['dbms'] == 'firebird')
|
||||
if ($db_config['dbms'] == 'phpbb_db_driver_firebird')
|
||||
{
|
||||
$xml_data = file_get_contents($path);
|
||||
$xml_data = preg_replace_callback('/(?:(<table name="))([a-z_]+)(?:(">))/', 'phpbb_database_test_case::to_upper', $xml_data);
|
||||
@@ -47,7 +63,9 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
|
||||
$path = $meta_data['uri'];
|
||||
}
|
||||
|
||||
return parent::createXMLDataSet($path);
|
||||
$this->fixture_xml_data = parent::createXMLDataSet($path);
|
||||
|
||||
return $this->fixture_xml_data;
|
||||
}
|
||||
|
||||
public function get_test_case_helpers()
|
||||
@@ -100,9 +118,7 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
|
||||
|
||||
$config = $this->get_database_config();
|
||||
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/db/' . $config['dbms'] . '.php';
|
||||
$dbal = 'dbal_' . $config['dbms'];
|
||||
$db = new $dbal();
|
||||
$db = new $config['dbms']();
|
||||
$db->sql_connect($config['dbhost'], $config['dbuser'], $config['dbpasswd'], $config['dbname'], $config['dbport']);
|
||||
|
||||
return $db;
|
||||
@@ -141,4 +157,20 @@ abstract class phpbb_database_test_case extends PHPUnit_Extensions_Database_Test
|
||||
{
|
||||
return $matches[1] . strtoupper($matches[2]) . $matches[3];
|
||||
}
|
||||
|
||||
public function assert_array_content_equals($one, $two)
|
||||
{
|
||||
// http://stackoverflow.com/questions/3838288/phpunit-assert-two-arrays-are-equal-but-order-of-elements-not-important
|
||||
// but one array_diff is not enough!
|
||||
if (sizeof(array_diff($one, $two)) || sizeof(array_diff($two, $one)))
|
||||
{
|
||||
// get a nice error message
|
||||
$this->assertEquals($one, $two);
|
||||
}
|
||||
else
|
||||
{
|
||||
// increase assertion count
|
||||
$this->assertTrue(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -108,7 +108,7 @@ class phpbb_database_test_connection_manager
|
||||
|
||||
// These require different connection strings on the phpBB side than they do in PDO
|
||||
// so you must provide a DSN string for ODBC separately
|
||||
if (!empty($this->config['custom_dsn']) && ($this->config['dbms'] == 'mssql' || $this->config['dbms'] == 'firebird'))
|
||||
if (!empty($this->config['custom_dsn']) && ($this->config['dbms'] == 'phpbb_db_driver_mssql' || $this->config['dbms'] == 'phpbb_db_driver_firebird'))
|
||||
{
|
||||
$dsn = 'odbc:' . $this->config['custom_dsn'];
|
||||
}
|
||||
@@ -117,12 +117,12 @@ class phpbb_database_test_connection_manager
|
||||
{
|
||||
switch ($this->config['dbms'])
|
||||
{
|
||||
case 'mssql':
|
||||
case 'mssql_odbc':
|
||||
case 'phpbb_db_driver_mssql':
|
||||
case 'phpbb_db_driver_mssql_odbc':
|
||||
$this->pdo = new phpbb_database_connection_odbc_pdo_wrapper('mssql', 0, $dsn, $this->config['dbuser'], $this->config['dbpasswd']);
|
||||
break;
|
||||
|
||||
case 'firebird':
|
||||
case 'phpbb_db_driver_firebird':
|
||||
if (!empty($this->config['custom_dsn']))
|
||||
{
|
||||
$this->pdo = new phpbb_database_connection_odbc_pdo_wrapper('firebird', 0, $dsn, $this->config['dbuser'], $this->config['dbpasswd']);
|
||||
@@ -165,14 +165,8 @@ class phpbb_database_test_connection_manager
|
||||
{
|
||||
switch ($this->config['dbms'])
|
||||
{
|
||||
case 'sqlite':
|
||||
if (file_exists($this->config['dbhost']))
|
||||
{
|
||||
unlink($this->config['dbhost']);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'firebird':
|
||||
case 'phpbb_db_driver_sqlite':
|
||||
case 'phpbb_db_driver_firebird':
|
||||
$this->connect();
|
||||
// Drop all of the tables
|
||||
foreach ($this->get_tables() as $table)
|
||||
@@ -182,7 +176,7 @@ class phpbb_database_test_connection_manager
|
||||
$this->purge_extras();
|
||||
break;
|
||||
|
||||
case 'oracle':
|
||||
case 'phpbb_db_driver_oracle':
|
||||
$this->connect();
|
||||
// Drop all of the tables
|
||||
foreach ($this->get_tables() as $table)
|
||||
@@ -232,39 +226,38 @@ class phpbb_database_test_connection_manager
|
||||
|
||||
switch ($this->config['dbms'])
|
||||
{
|
||||
case 'mysql':
|
||||
case 'mysql4':
|
||||
case 'mysqli':
|
||||
case 'phpbb_db_driver_mysql':
|
||||
case 'phpbb_db_driver_mysqli':
|
||||
$sql = 'SHOW TABLES';
|
||||
break;
|
||||
|
||||
case 'sqlite':
|
||||
case 'phpbb_db_driver_sqlite':
|
||||
$sql = 'SELECT name
|
||||
FROM sqlite_master
|
||||
WHERE type = "table"';
|
||||
break;
|
||||
|
||||
case 'mssql':
|
||||
case 'mssql_odbc':
|
||||
case 'mssqlnative':
|
||||
case 'phpbb_db_driver_mssql':
|
||||
case 'phpbb_db_driver_mssql_odbc':
|
||||
case 'phpbb_db_driver_mssqlnative':
|
||||
$sql = "SELECT name
|
||||
FROM sysobjects
|
||||
WHERE type='U'";
|
||||
break;
|
||||
|
||||
case 'postgres':
|
||||
case 'phpbb_db_driver_postgres':
|
||||
$sql = 'SELECT relname
|
||||
FROM pg_stat_user_tables';
|
||||
break;
|
||||
|
||||
case 'firebird':
|
||||
case 'phpbb_db_driver_firebird':
|
||||
$sql = 'SELECT rdb$relation_name
|
||||
FROM rdb$relations
|
||||
WHERE rdb$view_source is null
|
||||
AND rdb$system_flag = 0';
|
||||
break;
|
||||
|
||||
case 'oracle':
|
||||
case 'phpbb_db_driver_oracle':
|
||||
$sql = 'SELECT table_name
|
||||
FROM USER_TABLES';
|
||||
break;
|
||||
@@ -299,8 +292,8 @@ class phpbb_database_test_connection_manager
|
||||
protected function load_schema_from_file($directory)
|
||||
{
|
||||
$schema = $this->dbms['SCHEMA'];
|
||||
|
||||
if ($this->config['dbms'] == 'mysql')
|
||||
|
||||
if ($this->config['dbms'] == 'phpbb_db_driver_mysql')
|
||||
{
|
||||
$sth = $this->pdo->query('SELECT VERSION() AS version');
|
||||
$row = $sth->fetch(PDO::FETCH_ASSOC);
|
||||
@@ -319,7 +312,7 @@ class phpbb_database_test_connection_manager
|
||||
|
||||
$queries = file_get_contents($filename);
|
||||
$sql = phpbb_remove_comments($queries);
|
||||
|
||||
|
||||
$sql = split_sql_file($sql, $this->dbms['DELIM']);
|
||||
|
||||
foreach ($sql as $query)
|
||||
@@ -334,47 +327,47 @@ class phpbb_database_test_connection_manager
|
||||
protected function get_dbms_data($dbms)
|
||||
{
|
||||
$available_dbms = array(
|
||||
'firebird' => array(
|
||||
'phpbb_db_driver_firebird' => array(
|
||||
'SCHEMA' => 'firebird',
|
||||
'DELIM' => ';;',
|
||||
'PDO' => 'firebird',
|
||||
),
|
||||
'mysqli' => array(
|
||||
'phpbb_db_driver_mysqli' => array(
|
||||
'SCHEMA' => 'mysql_41',
|
||||
'DELIM' => ';',
|
||||
'PDO' => 'mysql',
|
||||
),
|
||||
'mysql' => array(
|
||||
'phpbb_db_driver_mysql' => array(
|
||||
'SCHEMA' => 'mysql',
|
||||
'DELIM' => ';',
|
||||
'PDO' => 'mysql',
|
||||
),
|
||||
'mssql' => array(
|
||||
'phpbb_db_driver_mssql' => array(
|
||||
'SCHEMA' => 'mssql',
|
||||
'DELIM' => 'GO',
|
||||
'PDO' => 'odbc',
|
||||
),
|
||||
'mssql_odbc'=> array(
|
||||
'phpbb_db_driver_mssql_odbc'=> array(
|
||||
'SCHEMA' => 'mssql',
|
||||
'DELIM' => 'GO',
|
||||
'PDO' => 'odbc',
|
||||
),
|
||||
'mssqlnative' => array(
|
||||
'phpbb_db_driver_mssqlnative' => array(
|
||||
'SCHEMA' => 'mssql',
|
||||
'DELIM' => 'GO',
|
||||
'PDO' => 'sqlsrv',
|
||||
),
|
||||
'oracle' => array(
|
||||
'phpbb_db_driver_oracle' => array(
|
||||
'SCHEMA' => 'oracle',
|
||||
'DELIM' => '/',
|
||||
'PDO' => 'oci',
|
||||
),
|
||||
'postgres' => array(
|
||||
'phpbb_db_driver_postgres' => array(
|
||||
'SCHEMA' => 'postgres',
|
||||
'DELIM' => ';',
|
||||
'PDO' => 'pgsql',
|
||||
),
|
||||
'sqlite' => array(
|
||||
'phpbb_db_driver_sqlite' => array(
|
||||
'SCHEMA' => 'sqlite',
|
||||
'DELIM' => ';',
|
||||
'PDO' => 'sqlite2',
|
||||
@@ -403,7 +396,7 @@ class phpbb_database_test_connection_manager
|
||||
|
||||
switch ($this->config['dbms'])
|
||||
{
|
||||
case 'firebird':
|
||||
case 'phpbb_db_driver_firebird':
|
||||
$sql = 'SELECT RDB$GENERATOR_NAME
|
||||
FROM RDB$GENERATORS
|
||||
WHERE RDB$SYSTEM_FLAG = 0';
|
||||
@@ -415,7 +408,7 @@ class phpbb_database_test_connection_manager
|
||||
}
|
||||
break;
|
||||
|
||||
case 'oracle':
|
||||
case 'phpbb_db_driver_oracle':
|
||||
$sql = 'SELECT sequence_name
|
||||
FROM USER_SEQUENCES';
|
||||
$result = $this->pdo->query($sql);
|
||||
@@ -432,4 +425,111 @@ class phpbb_database_test_connection_manager
|
||||
$this->pdo->exec($query);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs synchronisations on the database after a fixture has been loaded
|
||||
*
|
||||
* @param PHPUnit_Extensions_Database_DataSet_XmlDataSet $xml_data_set Information about the tables contained within the loaded fixture
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function post_setup_synchronisation($xml_data_set)
|
||||
{
|
||||
$this->ensure_connected(__METHOD__);
|
||||
$queries = array();
|
||||
|
||||
// Get escaped versions of the table names used in the fixture
|
||||
$table_names = array_map(array($this->pdo, 'PDO::quote'), $xml_data_set->getTableNames());
|
||||
|
||||
switch ($this->config['dbms'])
|
||||
{
|
||||
case 'phpbb_db_driver_oracle':
|
||||
// Get all of the information about the sequences
|
||||
$sql = "SELECT t.table_name, tc.column_name, d.referenced_name as sequence_name, s.increment_by, s.min_value
|
||||
FROM USER_TRIGGERS t
|
||||
JOIN USER_DEPENDENCIES d ON (d.name = t.trigger_name)
|
||||
JOIN USER_TRIGGER_COLS tc ON (tc.trigger_name = t.trigger_name)
|
||||
JOIN USER_SEQUENCES s ON (s.sequence_name = d.referenced_name)
|
||||
WHERE d.referenced_type = 'SEQUENCE'
|
||||
AND d.type = 'TRIGGER'
|
||||
AND t.table_name IN (" . implode(', ', array_map('strtoupper', $table_names)) . ')';
|
||||
|
||||
$result = $this->pdo->query($sql);
|
||||
|
||||
while ($row = $result->fetch(PDO::FETCH_ASSOC))
|
||||
{
|
||||
// Get the current max value of the table
|
||||
$sql = "SELECT MAX({$row['COLUMN_NAME']}) AS max FROM {$row['TABLE_NAME']}";
|
||||
$max_result = $this->pdo->query($sql);
|
||||
$max_row = $max_result->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$max_row)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$max_val = (int) $max_row['MAX'];
|
||||
$max_val++;
|
||||
|
||||
/**
|
||||
* This is not the "proper" way, but the proper way does not allow you to completely reset
|
||||
* tables with no rows since you have to select the next value to make the change go into effect.
|
||||
* You would have to go past the minimum value to set it correctly, but that's illegal.
|
||||
* Since we have no objects attached to our sequencers (triggers aren't attached), this works fine.
|
||||
*/
|
||||
$queries[] = 'DROP SEQUENCE ' . $row['SEQUENCE_NAME'];
|
||||
$queries[] = "CREATE SEQUENCE {$row['SEQUENCE_NAME']}
|
||||
MINVALUE {$row['MIN_VALUE']}
|
||||
INCREMENT BY {$row['INCREMENT_BY']}
|
||||
START WITH $max_val";
|
||||
}
|
||||
break;
|
||||
|
||||
case 'phpbb_db_driver_postgres':
|
||||
// Get the sequences attached to the tables
|
||||
$sql = 'SELECT column_name, table_name FROM information_schema.columns
|
||||
WHERE table_name IN (' . implode(', ', $table_names) . ")
|
||||
AND strpos(column_default, '_seq''::regclass') > 0";
|
||||
$result = $this->pdo->query($sql);
|
||||
|
||||
$setval_queries = array();
|
||||
while ($row = $result->fetch(PDO::FETCH_ASSOC))
|
||||
{
|
||||
// Get the columns used in the fixture for this table
|
||||
$column_names = $xml_data_set->getTableMetaData($row['table_name'])->getColumns();
|
||||
|
||||
// Skip sequences that weren't specified in the fixture
|
||||
if (!in_array($row['column_name'], $column_names))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the old value if it exists, or use 1 if it doesn't
|
||||
$sql = "SELECT COALESCE((SELECT MAX({$row['column_name']}) + 1 FROM {$row['table_name']}), 1) AS val";
|
||||
$result_max = $this->pdo->query($sql);
|
||||
$row_max = $result_max->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($row_max)
|
||||
{
|
||||
$seq_name = $this->pdo->quote($row['table_name'] . '_seq');
|
||||
$max_val = (int) $row_max['val'];
|
||||
|
||||
// The last parameter is false so that the system doesn't increment it again
|
||||
$setval_queries[] = "SETVAL($seq_name, $max_val, false)";
|
||||
}
|
||||
}
|
||||
|
||||
// Combine all of the SETVALs into one query
|
||||
if (sizeof($setval_queries))
|
||||
{
|
||||
$queries[] = 'SELECT ' . implode(', ', $setval_queries);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($queries as $query)
|
||||
{
|
||||
$this->pdo->exec($query);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -34,13 +34,36 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||
static protected $config = array();
|
||||
static protected $already_installed = false;
|
||||
|
||||
public function setUp()
|
||||
static public function setUpBeforeClass()
|
||||
{
|
||||
parent::setUpBeforeClass();
|
||||
|
||||
self::$config = phpbb_test_case_helpers::get_test_config();
|
||||
|
||||
// Important: this is used both for installation and by
|
||||
// test cases for querying the tables.
|
||||
// Therefore table prefix must be set before a board is
|
||||
// installed, and also before each test case is run.
|
||||
self::$config['table_prefix'] = 'phpbb_';
|
||||
|
||||
if (!isset(self::$config['phpbb_functional_url']))
|
||||
{
|
||||
$this->markTestSkipped('phpbb_functional_url was not set in test_config and wasn\'t set as PHPBB_FUNCTIONAL_URL environment variable either.');
|
||||
self::markTestSkipped('phpbb_functional_url was not set in test_config and wasn\'t set as PHPBB_FUNCTIONAL_URL environment variable either.');
|
||||
}
|
||||
|
||||
if (!self::$already_installed)
|
||||
{
|
||||
self::install_board();
|
||||
self::$already_installed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->bootstrap();
|
||||
|
||||
$this->cookieJar = new CookieJar;
|
||||
$this->client = new Goutte\Client(array(), null, $this->cookieJar);
|
||||
// Reset the curl handle because it is 0 at this point and not a valid
|
||||
@@ -51,6 +74,7 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||
// that were added in other tests are gone
|
||||
$this->lang = array();
|
||||
$this->add_lang('common');
|
||||
$this->purge_cache();
|
||||
}
|
||||
|
||||
public function request($method, $path)
|
||||
@@ -72,27 +96,16 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||
$this->backupStaticAttributesBlacklist += array(
|
||||
'phpbb_functional_test_case' => array('config', 'already_installed'),
|
||||
);
|
||||
|
||||
if (!static::$already_installed)
|
||||
{
|
||||
$this->install_board();
|
||||
$this->bootstrap();
|
||||
static::$already_installed = true;
|
||||
}
|
||||
}
|
||||
|
||||
protected function get_db()
|
||||
{
|
||||
global $phpbb_root_path, $phpEx;
|
||||
// so we don't reopen an open connection
|
||||
if (!($this->db instanceof dbal))
|
||||
if (!($this->db instanceof phpbb_db_driver))
|
||||
{
|
||||
if (!class_exists('dbal_' . self::$config['dbms']))
|
||||
{
|
||||
include($phpbb_root_path . 'includes/db/' . self::$config['dbms'] . ".$phpEx");
|
||||
}
|
||||
$sql_db = 'dbal_' . self::$config['dbms'];
|
||||
$this->db = new $sql_db();
|
||||
$dbms = self::$config['dbms'];
|
||||
$this->db = new $dbms();
|
||||
$this->db->sql_connect(self::$config['dbhost'], self::$config['dbuser'], self::$config['dbpasswd'], self::$config['dbname'], self::$config['dbport']);
|
||||
}
|
||||
return $this->db;
|
||||
@@ -125,7 +138,7 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||
{
|
||||
$this->extension_manager = new phpbb_extension_manager(
|
||||
$this->get_db(),
|
||||
new phpbb_config(),
|
||||
new phpbb_config(array()),
|
||||
self::$config['table_prefix'] . 'ext',
|
||||
$phpbb_root_path,
|
||||
".$phpEx",
|
||||
@@ -136,19 +149,11 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||
return $this->extension_manager;
|
||||
}
|
||||
|
||||
protected function install_board()
|
||||
static protected function install_board()
|
||||
{
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
||||
self::$config = phpbb_test_case_helpers::get_test_config();
|
||||
|
||||
if (!isset(self::$config['phpbb_functional_url']))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
self::$config['table_prefix'] = 'phpbb_';
|
||||
$this->recreate_database(self::$config);
|
||||
self::recreate_database(self::$config);
|
||||
|
||||
if (file_exists($phpbb_root_path . "config.$phpEx"))
|
||||
{
|
||||
@@ -193,19 +198,30 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||
));
|
||||
// end data
|
||||
|
||||
$content = $this->do_request('install');
|
||||
$this->assertContains('Welcome to Installation', $content);
|
||||
$content = self::do_request('install');
|
||||
self::assertNotSame(false, $content);
|
||||
self::assertContains('Welcome to Installation', $content);
|
||||
|
||||
$this->do_request('create_table', $data);
|
||||
// Installer uses 3.0-style dbms name
|
||||
$data['dbms'] = str_replace('phpbb_db_driver_', '', $data['dbms']);
|
||||
$content = self::do_request('create_table', $data);
|
||||
self::assertNotSame(false, $content);
|
||||
self::assertContains('The database tables used by phpBB', $content);
|
||||
// 3.0 or 3.1
|
||||
self::assertContains('have been created and populated with some initial data.', $content);
|
||||
|
||||
$this->do_request('config_file', $data);
|
||||
file_put_contents($phpbb_root_path . "config.$phpEx", phpbb_create_config_file_data($data, self::$config['dbms'], array(), true, true));
|
||||
$content = self::do_request('config_file', $data);
|
||||
self::assertNotSame(false, $content);
|
||||
self::assertContains('Configuration file', $content);
|
||||
file_put_contents($phpbb_root_path . "config.$phpEx", phpbb_create_config_file_data($data, self::$config['dbms'], true, true));
|
||||
|
||||
$this->do_request('final', $data);
|
||||
$content = self::do_request('final', $data);
|
||||
self::assertNotSame(false, $content);
|
||||
self::assertContains('You have successfully installed', $content);
|
||||
copy($phpbb_root_path . "config.$phpEx", $phpbb_root_path . "config_test.$phpEx");
|
||||
}
|
||||
|
||||
private function do_request($sub, $post_data = null)
|
||||
static private function do_request($sub, $post_data = null)
|
||||
{
|
||||
$context = null;
|
||||
|
||||
@@ -224,13 +240,62 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||
return file_get_contents(self::$config['phpbb_functional_url'] . 'install/index.php?mode=install&sub=' . $sub, false, $context);
|
||||
}
|
||||
|
||||
private function recreate_database($config)
|
||||
static private function recreate_database($config)
|
||||
{
|
||||
$db_conn_mgr = new phpbb_database_test_connection_manager($config);
|
||||
$db_conn_mgr->recreate_db();
|
||||
}
|
||||
|
||||
protected function login()
|
||||
/**
|
||||
* Creates a new user with limited permissions
|
||||
*
|
||||
* @param string $username Also doubles up as the user's password
|
||||
* @return int ID of created user
|
||||
*/
|
||||
protected function create_user($username)
|
||||
{
|
||||
// Required by unique_id
|
||||
global $config;
|
||||
|
||||
$config = new phpbb_config(array());
|
||||
$config['rand_seed'] = '';
|
||||
$config['rand_seed_last_update'] = time() + 600;
|
||||
|
||||
// Required by user_add
|
||||
global $db, $cache, $phpbb_dispatcher;
|
||||
$db = $this->get_db();
|
||||
if (!function_exists('phpbb_mock_null_cache'))
|
||||
{
|
||||
require_once(__DIR__ . '/../mock/null_cache.php');
|
||||
}
|
||||
$cache = new phpbb_mock_null_cache;
|
||||
|
||||
if (!function_exists('utf_clean_string'))
|
||||
{
|
||||
require_once(__DIR__ . '/../../phpBB/includes/utf/utf_tools.php');
|
||||
}
|
||||
if (!function_exists('user_add'))
|
||||
{
|
||||
require_once(__DIR__ . '/../../phpBB/includes/functions_user.php');
|
||||
}
|
||||
set_config(null, null, null, $config);
|
||||
set_config_count(null, null, null, $config);
|
||||
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
|
||||
|
||||
$user_row = array(
|
||||
'username' => $username,
|
||||
'group_id' => 2,
|
||||
'user_email' => 'nobody@example.com',
|
||||
'user_type' => 0,
|
||||
'user_lang' => 'en',
|
||||
'user_timezone' => 0,
|
||||
'user_dateformat' => '',
|
||||
'user_password' => phpbb_hash($username),
|
||||
);
|
||||
return user_add($user_row);
|
||||
}
|
||||
|
||||
protected function login($username = 'admin')
|
||||
{
|
||||
$this->add_lang('ucp');
|
||||
|
||||
@@ -238,7 +303,9 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||
$this->assertContains($this->lang('LOGIN_EXPLAIN_UCP'), $crawler->filter('html')->text());
|
||||
|
||||
$form = $crawler->selectButton($this->lang('LOGIN'))->form();
|
||||
$login = $this->client->submit($form, array('username' => 'admin', 'password' => 'admin'));
|
||||
$crawler = $this->client->submit($form, array('username' => $username, 'password' => $username));
|
||||
$this->assert_response_success();
|
||||
$this->assertContains($this->lang('LOGIN_REDIRECT'), $crawler->filter('html')->text());
|
||||
|
||||
$cookies = $this->cookieJar->all();
|
||||
|
||||
@@ -331,15 +398,30 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||
return call_user_func_array('sprintf', $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* assertContains for language strings
|
||||
*
|
||||
* @param string $needle Search string
|
||||
* @param string $haystack Search this
|
||||
* @param string $message Optional failure message
|
||||
*/
|
||||
public function assertContainsLang($needle, $haystack, $message = null)
|
||||
{
|
||||
$this->assertContains(html_entity_decode($this->lang($needle), ENT_QUOTES), $haystack, $message);
|
||||
}
|
||||
/**
|
||||
* assertContains for language strings
|
||||
*
|
||||
* @param string $needle Search string
|
||||
* @param string $haystack Search this
|
||||
* @param string $message Optional failure message
|
||||
*/
|
||||
public function assertContainsLang($needle, $haystack, $message = null)
|
||||
{
|
||||
$this->assertContains(html_entity_decode($this->lang($needle), ENT_QUOTES), $haystack, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Heuristic function to check that the response is success.
|
||||
*
|
||||
* When php decides to die with a fatal error, it still sends 200 OK
|
||||
* status code. This assertion tries to catch that.
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
public function assert_response_success()
|
||||
{
|
||||
$this->assertEquals(200, $this->client->getResponse()->getStatus());
|
||||
$content = $this->client->getResponse()->getContent();
|
||||
$this->assertNotContains('Fatal error:', $content);
|
||||
}
|
||||
}
|
||||
|
29
tests/test_framework/phpbb_search_test_case.php
Normal file
29
tests/test_framework/phpbb_search_test_case.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
abstract class phpbb_search_test_case extends phpbb_database_test_case
|
||||
{
|
||||
static protected function get_search_wrapper($class)
|
||||
{
|
||||
$wrapped = $class . '_wrapper';
|
||||
if (!class_exists($wrapped))
|
||||
{
|
||||
$code = "
|
||||
class $wrapped extends $class
|
||||
{
|
||||
public function get_must_contain_ids() { return \$this->must_contain_ids; }
|
||||
public function get_must_not_contain_ids() { return \$this->must_not_contain_ids; }
|
||||
public function get_split_words() { return \$this->split_words; }
|
||||
}
|
||||
";
|
||||
eval($code);
|
||||
}
|
||||
return $wrapped;
|
||||
}
|
||||
}
|
@@ -54,7 +54,7 @@ class phpbb_test_case_helpers
|
||||
if (extension_loaded('sqlite') && version_compare(PHPUnit_Runner_Version::id(), '3.4.15', '>='))
|
||||
{
|
||||
$config = array_merge($config, array(
|
||||
'dbms' => 'sqlite',
|
||||
'dbms' => 'phpbb_db_driver_sqlite',
|
||||
'dbhost' => dirname(__FILE__) . '/../phpbb_unit_tests.sqlite2', // filename
|
||||
'dbport' => '',
|
||||
'dbname' => '',
|
||||
@@ -78,7 +78,7 @@ class phpbb_test_case_helpers
|
||||
include($test_config);
|
||||
|
||||
$config = array_merge($config, array(
|
||||
'dbms' => $dbms,
|
||||
'dbms' => phpbb_convert_30_dbms_to_31($dbms),
|
||||
'dbhost' => $dbhost,
|
||||
'dbport' => $dbport,
|
||||
'dbname' => $dbname,
|
||||
@@ -91,12 +91,26 @@ class phpbb_test_case_helpers
|
||||
{
|
||||
$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'))
|
||||
{
|
||||
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
|
||||
}
|
||||
|
||||
$config = array_merge($config, array(
|
||||
'dbms' => isset($_SERVER['PHPBB_TEST_DBMS']) ? $_SERVER['PHPBB_TEST_DBMS'] : '',
|
||||
'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'] : '',
|
||||
@@ -113,6 +127,16 @@ class phpbb_test_case_helpers
|
||||
));
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user