1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-09 02:06:32 +02:00

Merge branch 'develop' of https://github.com/phpbb/phpbb3 into ticket/10714

* 'develop' of https://github.com/phpbb/phpbb3: (205 commits)
  [ticket/10786] Javascript toggle member search panel in memberlist.php
  [ticket/10786] Javascript toggle member search panel in memberlist.php
  [ticket/10786] Javascript toggle member search panel in memberlist.php
  [ticket/11201] Remove database column on update
  [ticket/10431] Remove .left class from reply-all
  [ticket/10431] Remove reply-all custom css
  [ticket/10431] Adjustments for large buttons
  [ticket/11323] Add tests for inclusion of defined variables
  [ticket/11324] Add PHP 5.5 environment to travis and allow it to fail.
  [ticket/11201] Remove MSN/WLM fields
  [ticket/11321] Recreate schema files with develop/create_schema_files.php
  [ticket/11320] Include functions file as we need phpbb_convert_30_dbms_to_31
  [ticket/11313] Use correct object el instead of eel in alt_text callback
  [ticket/11301] Guidelines: Add spaces in front and after the / operator.
  [ticket/11301] Explicitly cast str offset to int to prevent E_NOTICE on 5.4.
  [ticket/11311] Include asset core.js in subsilver2 overall_footer.html
  [ticket/10949] Remove not needed comma
  [ticket/11309] phpbb_extension_interface::disable_step correct docblock.
  [ticket/10949] Converted missing code to new JS coding guidelines
  [ticket/11302] Correctly select first timezone or selected timezone
  ...
This commit is contained in:
Joas Schilling
2013-01-16 16:15:31 +01:00
163 changed files with 3879 additions and 2907 deletions

View File

@@ -17,7 +17,27 @@ PHP extensions
Unit tests use several PHP extensions that board code does not use. Currently
the following PHP extensions must be installed and enabled to run unit tests:
- ctype
- ctype (also a PHPUnit dependency)
- dom (PHPUnit dependency)
- json (also a phpBB dependency)
Some of the functionality in phpBB and/or the test suite uses additional
PHP extensions. If these extensions are not loaded, respective tests
will be skipped:
- apc (APC cache driver)
- bz2 (compress tests)
- interbase, pdo_firebird (Firebird database driver)
- mysql, pdo_mysql (MySQL database driver)
- mysqli, pdo_mysql (MySQLi database driver)
- pcntl (flock class)
- pdo (any database tests)
- pgsql, pdo_pgsql (PostgreSQL database driver)
- redis (https://github.com/nicolasff/phpredis, Redis cache driver)
- simplexml (any database tests)
- sqlite, pdo_sqlite (SQLite database driver, requires SQLite 2.x support
in pdo_sqlite)
- zlib (compress tests)
Database Tests
--------------
@@ -44,7 +64,7 @@ to use in the environment as follows:
$ PHPBB_TEST_CONFIG=tests/test_config.php phpunit
Alternatively you can specify parameters in the environment, so e.g. the
following will run phpunit with the same parameters as in the shown
following will run PHPUnit with the same parameters as in the shown
test_config.php file:
$ PHPBB_TEST_DBMS='mysqli' PHPBB_TEST_DBHOST='localhost' \

View File

@@ -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&nbsp;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&#58;//area51&#46;phpbb&#46;com/images/area51&#46;png[/img:]',
),
array(
'Test default bbcodes: simple url',
'[url]https://area51.phpbb.com/[/url]',
'[url:]https&#58;//area51&#46;phpbb&#46;com/[/url:]',
),
array(
'Test default bbcodes: simple url with description',
'[url=https://area51.phpbb.com/]Area51[/url]',
'[url=https&#58;//area51&#46;phpbb&#46;com/:]Area51[/url:]',
),
array(
'Test default bbcodes: simple email',
'[email]bbcode-test@phpbb.com[/email]',
'[email:]bbcode-test@phpbb&#46;com[/email:]',
),
array(
'Test default bbcodes: simple email with description',
'[email=bbcode-test@phpbb.com]Email[/email]',
'[email=bbcode-test@phpbb&#46;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=&quot;&#91;test]test&quot;]test [ test[/quote]',
'[quote=&quot;&#91;test]test&quot;:]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=&quot;[&quot;]test[/quote]',
'[quote=&quot;&#91;&quot;:]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=&quot;a&quot;]a[/quote][quote=&quot;a]a[/quote]',
'[quote=&quot;a&quot;:]a[/quote:][quote=&quot;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&#58;//area51&#46;phpbb&#46;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&#58;//area51&#46;phpbb&#46;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=&quot;[i]test[/i]&quot;]test[/quote]',
'[quote=&quot;[i:]test[/i:]&quot;:]test[/quote:]',
),
array(
'Allow links bbcodes in usernames',
'[quote=&quot;[url=https://area51.phpbb.com/]test[/url]&quot;]test[/quote]',
'[quote=&quot;[url=https&#58;//area51&#46;phpbb&#46;com/:]test[/url:]&quot;:]test[/quote:]',
),
array(
'Allow img bbcodes in usernames - Username displayed the image',
'[quote=&quot;[img]https://area51.phpbb.com/images/area51.png[/img]&quot;]test[/quote]',
'[quote=&quot;[img:]https&#58;//area51&#46;phpbb&#46;com/images/area51&#46;png[/img:]&quot;:]test[/quote:]',
),
array(
'Disallow flash bbcodes in usernames - Username displayed as [flash]http://www.phpbb.com/[/flash]',
'[quote=&quot;[flash]http://www.phpbb.com/[/flash]&quot;]test[/quote]',
'[quote=&quot;&#91;flash]http://www.phpbb.com/&#91;/flash]&quot;:]test[/quote:]',
),
array(
'Disallow quote bbcodes in usernames - Username displayed as [quote]test[/quote]',
'[quote=&quot;[quote]test[/quote]&quot;]test[/quote]',
'[quote=&quot;&#91;quote]test&#91;/quote]&quot;:]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 &#91;b&#93;bold &#91;i&#93;bold + italic&#91;/i&#93;&#91;/b&#93;[/code:]',
),
array(
'Do not parse quote bbcodes in code',
'[code]unparsed code [quote=&quot;username&quot;]quoted[/quote][/code]',
'[code:]unparsed code &#91;quote=&quot;username&quot;&#93;quoted&#91;/quote&#93;[/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);
}
}

View File

@@ -64,9 +64,10 @@ abstract class phpbb_cache_common_test_case extends phpbb_database_test_case
public function test_cache_sql()
{
global $db, $cache;
global $db, $cache, $phpbb_root_path, $phpEx;
$config = new phpbb_config(array());
$db = $this->new_dbal();
$cache = new phpbb_cache_service($this->driver);
$cache = new phpbb_cache_service($this->driver, $config, $db, $phpbb_root_path, $phpEx);
$sql = "SELECT * FROM phpbb_config
WHERE config_name = 'foo'";

View File

@@ -47,9 +47,10 @@ class phpbb_cache_null_driver_test extends phpbb_database_test_case
public function test_cache_sql()
{
global $db, $cache;
global $db, $cache, $phpbb_root_path, $phpEx;
$config = new phpbb_config(array());
$db = $this->new_dbal();
$cache = new phpbb_cache_service($this->driver);
$cache = new phpbb_cache_service($this->driver, $config, $db, $phpbb_root_path, $phpEx);
$sql = "SELECT * FROM phpbb_config
WHERE config_name = 'foo'";

View File

@@ -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);

View File

@@ -0,0 +1,128 @@
<?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_acp_permissions_test extends phpbb_functional_test_case
{
public function setUp()
{
parent::setUp();
$this->login();
$this->admin_login();
$this->add_lang('acp/permissions');
}
public function test_permissions_tab()
{
// Permissions tab
// XXX hardcoded id
$crawler = $this->request('GET', 'adm/index.php?i=16&sid=' . $this->sid);
$this->assert_response_success();
// these language strings are html
$this->assertContains($this->lang('ACP_PERMISSIONS_EXPLAIN'), $this->client->getResponse()->getContent());
}
public function test_select_user()
{
// User permissions
$crawler = $this->request('GET', 'adm/index.php?i=acp_permissions&icat=16&mode=setting_user_global&sid=' . $this->sid);
$this->assert_response_success();
$this->assertContains($this->lang('ACP_USERS_PERMISSIONS_EXPLAIN'), $this->client->getResponse()->getContent());
// Select admin
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
$data = array('username[0]' => 'admin');
$form->setValues($data);
$crawler = $this->client->submit($form);
$this->assert_response_success();
$this->assertContains($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text());
}
public function permissions_data()
{
return array(
// description
// permission type
// permission name
// mode
// object name
// object id
array(
'user permission',
'u_',
'u_hideonline',
'setting_user_global',
'user_id',
2,
),
array(
'moderator permission',
'm_',
'm_ban',
'setting_mod_global',
'group_id',
4,
),
/* Admin does not work yet, probably because founder can do everything
array(
'admin permission',
'a_',
'a_forum',
'setting_admin_global',
'group_id',
5,
),
*/
);
}
/**
* @dataProvider permissions_data
*/
public function test_change_permission($description, $permission_type, $permission, $mode, $object_name, $object_id)
{
// Get the form
$crawler = $this->request('GET', "adm/index.php?i=acp_permissions&icat=16&mode=$mode&${object_name}[0]=$object_id&type=$permission_type&sid=" . $this->sid);
$this->assert_response_success();
$this->assertContains($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text());
// XXX globals for phpbb_auth, refactor it later
global $db, $cache;
$db = $this->get_db();
$cache = new phpbb_mock_null_cache;
$auth = new phpbb_auth;
// XXX hardcoded id
$user_data = $auth->obtain_user_data(2);
$auth->acl($user_data);
$this->assertEquals(1, $auth->acl_get($permission));
// Set u_hideonline to never
$form = $crawler->selectButton($this->lang('APPLY_PERMISSIONS'))->form();
// initially it should be a yes
$values = $form->getValues();
$this->assertEquals(1, $values["setting[$object_id][0][$permission]"]);
// set to never
$data = array("setting[$object_id][0][$permission]" => '0');
$form->setValues($data);
$crawler = $this->client->submit($form);
$this->assert_response_success();
$this->assertContains($this->lang('AUTH_UPDATED'), $crawler->text());
// check acl again
$auth = new phpbb_auth;
// XXX hardcoded id
$user_data = $auth->obtain_user_data(2);
$auth->acl($user_data);
$this->assertEquals(0, $auth->acl_get($permission));
}
}

View File

@@ -49,4 +49,15 @@ class phpbb_functional_auth_test extends phpbb_functional_test_case
$this->assert_response_success();
$this->assertContains($this->lang('REGISTER'), $crawler->filter('.navbar')->text());
}
public function test_acp_login()
{
$this->login();
$this->admin_login();
// check that we are logged in
$crawler = $this->request('GET', 'adm/index.php?sid=' . $this->sid);
$this->assert_response_success();
$this->assertContains($this->lang('ADMIN_PANEL'), $crawler->filter('h1')->text());
}
}

View File

@@ -44,8 +44,9 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case
public function test_empty_file()
{
$this->markTestIncomplete('Test fails intermittently.');
$crawler = $this->upload_file('empty.png', 'image/png');
$this->assertEquals($this->lang('ATTACHED_IMAGE_NOT_IMAGE'), $crawler->filter('div#message p')->text());
$this->assertEquals($this->lang('ATTACHED_IMAGE_NOT_IMAGE'), $this->assert_filter($crawler, 'div#message p')->text());
}
public function test_invalid_extension()
@@ -63,6 +64,7 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case
public function test_valid_file()
{
$this->markTestIncomplete('Test fails intermittently.');
$crawler = $this->upload_file('valid.jpg', 'image/jpeg');
$this->assert_response_success();
// ensure there was no error message rendered

View File

@@ -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());
}
}

View File

@@ -121,7 +121,11 @@ class phpbb_mock_cache implements phpbb_cache_driver_interface
public function sql_load($query)
{
}
public function sql_save($query, $query_result, $ttl)
/**
* {@inheritDoc}
*/
public function sql_save(phpbb_db_driver $db, $query, $query_result, $ttl)
{
return $query_result;
}

View File

@@ -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'),
);
}
}

View File

@@ -1,54 +1,54 @@
<?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__) . '/../../phpBB/includes/functions.php';
class phpbb_session_append_sid_test extends phpbb_test_case
{
public function append_sid_data()
{
return array(
array('viewtopic.php?t=1&amp;f=2', false, true, false, 'viewtopic.php?t=1&amp;f=2', 'parameters in url-argument'),
array('viewtopic.php', 't=1&amp;f=2', true, false, 'viewtopic.php?t=1&amp;f=2', 'parameters in params-argument using amp'),
array('viewtopic.php', 't=1&f=2', false, false, 'viewtopic.php?t=1&f=2', 'parameters in params-argument using &'),
array('viewtopic.php', array('t' => 1, 'f' => 2), true, false, 'viewtopic.php?t=1&amp;f=2', 'parameters in params-argument as array'),
// Custom sid parameter
array('viewtopic.php', 't=1&amp;f=2', true, 'custom-sid', 'viewtopic.php?t=1&amp;f=2&amp;sid=custom-sid', 'using session_id'),
// Testing anchors
array('viewtopic.php?t=1&amp;f=2#anchor', false, true, false, 'viewtopic.php?t=1&amp;f=2#anchor', 'anchor in url-argument'),
array('viewtopic.php', 't=1&amp;f=2#anchor', true, false, 'viewtopic.php?t=1&amp;f=2#anchor', 'anchor in params-argument'),
array('viewtopic.php', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'viewtopic.php?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
// Anchors and custom sid
array('viewtopic.php?t=1&amp;f=2#anchor', false, true, 'custom-sid', 'viewtopic.php?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in url-argument using session_id'),
array('viewtopic.php', 't=1&amp;f=2#anchor', true, 'custom-sid', 'viewtopic.php?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument using session_id'),
array('viewtopic.php', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'viewtopic.php?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
// Empty parameters should not append the ?
array('viewtopic.php', false, true, false, 'viewtopic.php', 'no params using bool false'),
array('viewtopic.php', '', true, false, 'viewtopic.php', 'no params using empty string'),
array('viewtopic.php', array(), true, false, 'viewtopic.php', 'no params using empty array'),
);
}
/**
* @dataProvider append_sid_data
*/
public function test_append_sid($url, $params, $is_amp, $session_id, $expected, $description)
{
global $phpbb_dispatcher;
$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
$this->assertEquals($expected, append_sid($url, $params, $is_amp, $session_id));
}
}
<?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__) . '/../../phpBB/includes/functions.php';
class phpbb_session_append_sid_test extends phpbb_test_case
{
public function append_sid_data()
{
return array(
array('viewtopic.php?t=1&amp;f=2', false, true, false, 'viewtopic.php?t=1&amp;f=2', 'parameters in url-argument'),
array('viewtopic.php', 't=1&amp;f=2', true, false, 'viewtopic.php?t=1&amp;f=2', 'parameters in params-argument using amp'),
array('viewtopic.php', 't=1&f=2', false, false, 'viewtopic.php?t=1&f=2', 'parameters in params-argument using &'),
array('viewtopic.php', array('t' => 1, 'f' => 2), true, false, 'viewtopic.php?t=1&amp;f=2', 'parameters in params-argument as array'),
// Custom sid parameter
array('viewtopic.php', 't=1&amp;f=2', true, 'custom-sid', 'viewtopic.php?t=1&amp;f=2&amp;sid=custom-sid', 'using session_id'),
// Testing anchors
array('viewtopic.php?t=1&amp;f=2#anchor', false, true, false, 'viewtopic.php?t=1&amp;f=2#anchor', 'anchor in url-argument'),
array('viewtopic.php', 't=1&amp;f=2#anchor', true, false, 'viewtopic.php?t=1&amp;f=2#anchor', 'anchor in params-argument'),
array('viewtopic.php', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'viewtopic.php?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
// Anchors and custom sid
array('viewtopic.php?t=1&amp;f=2#anchor', false, true, 'custom-sid', 'viewtopic.php?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in url-argument using session_id'),
array('viewtopic.php', 't=1&amp;f=2#anchor', true, 'custom-sid', 'viewtopic.php?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument using session_id'),
array('viewtopic.php', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'viewtopic.php?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
// Empty parameters should not append the ?
array('viewtopic.php', false, true, false, 'viewtopic.php', 'no params using bool false'),
array('viewtopic.php', '', true, false, 'viewtopic.php', 'no params using empty string'),
array('viewtopic.php', array(), true, false, 'viewtopic.php', 'no params using empty array'),
);
}
/**
* @dataProvider append_sid_data
*/
public function test_append_sid($url, $params, $is_amp, $session_id, $expected, $description)
{
global $phpbb_dispatcher;
$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
$this->assertEquals($expected, append_sid($url, $params, $is_amp, $session_id));
}
}

View File

@@ -196,7 +196,25 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array('loop' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'loop.inner' => array(array(), array())),
array('loop'),
'',
),/* no top level nested loops
),
/* Currently fail on develop:
http://tracker.phpbb.com/browse/PHPBB3-11323
array(
'include_define_variable.html',
array('VARIABLE' => 'variable.html'),
array(),
array(),
'variable.html',
),
array(
'include_loop_define.html',
array('VARIABLE' => 'value'),
array('loop' => array(array('NESTED_FILE' => 'variable.html'))),
array(),
'value',
),
*/
/* no top level nested loops
array(
'loop_vars.html',
array(),

View File

@@ -0,0 +1,2 @@
<!-- DEFINE $DEF = '{VARIABLE}' -->
<!-- INCLUDE {$DEF} -->

View File

@@ -0,0 +1,4 @@
<!-- BEGIN loop -->
<!-- DEFINE $DEF = '{loop.NESTED_FILE}' -->
<!-- INCLUDE {$DEF} -->
<!-- END loop -->

View File

@@ -227,7 +227,6 @@ class phpbb_database_test_connection_manager
switch ($this->config['dbms'])
{
case 'phpbb_db_driver_mysql':
case 'phpbb_db_driver_mysql4':
case 'phpbb_db_driver_mysqli':
$sql = 'SHOW TABLES';
break;

View File

@@ -262,7 +262,7 @@ class phpbb_functional_test_case extends phpbb_test_case
$config['rand_seed_last_update'] = time() + 600;
// Required by user_add
global $db, $cache, $phpbb_dispatcher;
global $db, $cache, $phpbb_dispatcher, $phpbb_container;
$db = $this->get_db();
if (!function_exists('phpbb_mock_null_cache'))
{
@@ -270,6 +270,14 @@ class phpbb_functional_test_case extends phpbb_test_case
}
$cache = new phpbb_mock_null_cache;
$cache_driver = new phpbb_cache_driver_null();
$phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
$phpbb_container
->expects($this->any())
->method('get')
->with('cache.driver')
->will($this->returnValue($cache_driver));
if (!function_exists('utf_clean_string'))
{
require_once(__DIR__ . '/../../phpBB/includes/utf/utf_tools.php');
@@ -323,7 +331,7 @@ class phpbb_functional_test_case extends phpbb_test_case
* Login to the ACP
* You must run login() before calling this.
*/
protected function admin_login()
protected function admin_login($username = 'admin')
{
$this->add_lang('acp/common');
@@ -343,7 +351,9 @@ class phpbb_functional_test_case extends phpbb_test_case
{
if (strpos($field, 'password_') === 0)
{
$login = $this->client->submit($form, array('username' => 'admin', $field => 'admin'));
$crawler = $this->client->submit($form, array('username' => $username, $field => $username));
$this->assert_response_success();
$this->assertContains($this->lang('LOGIN_ADMIN_SUCCESS'), $crawler->filter('html')->text());
$cookies = $this->cookieJar->all();
@@ -424,4 +434,20 @@ class phpbb_functional_test_case extends phpbb_test_case
$content = $this->client->getResponse()->getContent();
$this->assertNotContains('Fatal error:', $content);
}
public function assert_filter($crawler, $expr, $msg = null)
{
$nodes = $crawler->filter($expr);
if ($msg)
{
$msg .= "\n";
}
else
{
$msg = '';
}
$msg .= "`$expr` not found in DOM.";
$this->assertGreaterThan(0, count($nodes), $msg);
return $nodes;
}
}

View File

@@ -77,6 +77,11 @@ class phpbb_test_case_helpers
{
include($test_config);
if (!function_exists('phpbb_convert_30_dbms_to_31'))
{
require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
}
$config = array_merge($config, array(
'dbms' => phpbb_convert_30_dbms_to_31($dbms),
'dbhost' => $dbhost,

View File

@@ -205,8 +205,7 @@ class phpbb_filespec_test extends phpbb_test_case
*/
public function test_get_extension($filename, $expected)
{
$filespec = $this->get_filespec();
$this->assertEquals($expected, $filespec->get_extension($filename));
$this->assertEquals($expected, filespec::get_extension($filename));
}
public function is_image_variables()