1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-25 11:01:48 +02:00

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

# By Oleg Pudeyev (37) and others
# Via Oleg Pudeyev (24) and others
* 'develop' of github.com:phpbb/phpbb3: (179 commits)
  [ticket/11323] Add tests for inclusion of defined variables
  [ticket/11324] Add PHP 5.5 environment to travis and allow it to fail.
  [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
  [ticket/11305] Mock container for cache driver in functional create_user()
  [ticket/11305] Check for $cache being null before using it in db drivers.
  [ticket/10805] Compare phpbbAlertTimer against null
  [ticket/11305] Define hook finder as a service on the container.
  [ticket/11305] Adjust comment.
  [ticket/11305] Use phpbb_create_default_container.
  [ticket/11305] Create a normal container during final installation step.
  [ticket/11305] Retrieve cache driver from container rather than cache service.
  ...

Conflicts:
	phpBB/install/schemas/firebird_schema.sql
	phpBB/install/schemas/mssql_schema.sql
	phpBB/install/schemas/mysql_40_schema.sql
	phpBB/install/schemas/mysql_41_schema.sql
	phpBB/install/schemas/oracle_schema.sql
	phpBB/install/schemas/postgres_schema.sql
	phpBB/install/schemas/sqlite_schema.sql
	phpBB/styles/subsilver2/template/overall_footer.html
This commit is contained in:
Nathan Guse
2013-01-15 11:31:39 -06:00
125 changed files with 3514 additions and 2562 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

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

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