aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auth/provider_apache_test.php2
-rw-r--r--tests/auth/provider_db_test.php6
-rw-r--r--tests/auth/provider_oauth_token_storage_test.php2
-rw-r--r--tests/avatar/fixtures/users.xml33
-rw-r--r--tests/avatar/manager_test.php70
-rw-r--r--tests/bootstrap.php1
-rw-r--r--tests/config_php_file_test.php10
-rw-r--r--tests/console/cron/cron_list_test.php2
-rw-r--r--tests/console/cron/run_test.php2
-rw-r--r--tests/content_visibility/delete_post_test.php36
-rw-r--r--tests/content_visibility/get_forums_visibility_sql_test.php2
-rw-r--r--tests/content_visibility/get_global_visibility_sql_test.php2
-rw-r--r--tests/content_visibility/get_visibility_sql_test.php2
-rw-r--r--tests/content_visibility/set_post_visibility_test.php4
-rw-r--r--tests/content_visibility/set_topic_visibility_test.php2
-rw-r--r--tests/controller/controller_test.php2
-rw-r--r--tests/controller/helper_route_test.php2
-rw-r--r--tests/datetime/from_format_test.php2
-rw-r--r--tests/dbal/db_tools_test.php12
-rw-r--r--tests/dbal/migrator_test.php2
-rw-r--r--tests/dbal/migrator_tool_module_test.php2
-rw-r--r--tests/dbal/select_test.php60
-rw-r--r--tests/di/create_container_test.php4
-rw-r--r--tests/extension/manager_test.php2
-rw-r--r--tests/extension/metadata_manager_test.php2
-rw-r--r--tests/functional/avatar_acp_groups_test.php2
-rw-r--r--tests/functional/avatar_acp_users_test.php2
-rw-r--r--tests/functional/avatar_ucp_groups_test.php2
-rw-r--r--tests/functional/avatar_ucp_users_test.php13
-rw-r--r--tests/functional/common_avatar_test.php15
-rw-r--r--tests/functional/download_test.php64
-rw-r--r--tests/functional/fileupload_form_test.php2
-rw-r--r--tests/functional/fileupload_remote_test.php2
-rw-r--r--tests/functional/forgot_password_test.php2
-rw-r--r--tests/functional/plupload_test.php2
-rw-r--r--tests/functions/generate_string_list.php2
-rw-r--r--tests/functions/insert_config_array_test.php142
-rw-r--r--tests/groupposition/legend_test.php14
-rw-r--r--tests/groupposition/teampage_test.php16
-rw-r--r--tests/log/add_test.php4
-rw-r--r--tests/log/delete_test.php2
-rw-r--r--tests/log/function_add_log_test.php2
-rw-r--r--tests/notification/base.php2
-rw-r--r--tests/notification/submit_post_base.php2
-rw-r--r--tests/notification/user_list_trim_test.php2
-rw-r--r--tests/pagination/pagination_test.php2
-rw-r--r--tests/profilefields/type_bool_test.php2
-rw-r--r--tests/profilefields/type_date_test.php2
-rw-r--r--tests/profilefields/type_dropdown_test.php2
-rw-r--r--tests/profilefields/type_googleplus_test.php54
-rw-r--r--tests/profilefields/type_int_test.php2
-rw-r--r--tests/profilefields/type_string_test.php2
-rw-r--r--tests/profilefields/type_url_test.php2
-rw-r--r--tests/security/base.php2
-rw-r--r--tests/session/garbage_collection_test.php16
-rw-r--r--tests/template/template_test_case.php2
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php188
-rw-r--r--tests/test_framework/phpbb_mink_test_case.php183
-rw-r--r--tests/user/lang_test.php4
-rw-r--r--tests/version/version_fetch_test.php2
-rw-r--r--tests/version/version_test.php6
61 files changed, 644 insertions, 387 deletions
diff --git a/tests/auth/provider_apache_test.php b/tests/auth/provider_apache_test.php
index 2decf0f18c..68ad7b2c19 100644
--- a/tests/auth/provider_apache_test.php
+++ b/tests/auth/provider_apache_test.php
@@ -29,7 +29,7 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case
$db = $this->new_dbal();
$config = new \phpbb\config\config(array());
$this->request = $this->getMock('\phpbb\request\request');
- $this->user = $this->getMock('\phpbb\user');
+ $this->user = new \phpbb\user('\phpbb\datetime');
$driver_helper = new \phpbb\passwords\driver\helper($config);
$passwords_drivers = array(
'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($config, $driver_helper),
diff --git a/tests/auth/provider_db_test.php b/tests/auth/provider_db_test.php
index 23324f87f2..e33eae6b54 100644
--- a/tests/auth/provider_db_test.php
+++ b/tests/auth/provider_db_test.php
@@ -39,7 +39,7 @@ class phpbb_auth_provider_db_test extends phpbb_database_test_case
'max_login_attempts' => 0,
));
$request = $this->getMock('\phpbb\request\request');
- $user = $this->getMock('\phpbb\user');
+ $user = new \phpbb\user('\phpbb\datetime');
$driver_helper = new \phpbb\passwords\driver\helper($config);
$passwords_drivers = array(
'passwords.driver.bcrypt_2y' => new \phpbb\passwords\driver\bcrypt_2y($config, $driver_helper),
@@ -52,7 +52,9 @@ class phpbb_auth_provider_db_test extends phpbb_database_test_case
// Set up passwords manager
$passwords_manager = new \phpbb\passwords\manager($config, $passwords_drivers, $passwords_helper, array_keys($passwords_drivers));
- $provider = new \phpbb\auth\provider\db($db, $config, $passwords_manager, $request, $user, $phpbb_root_path, $phpEx);
+ $phpbb_container = new phpbb_mock_container_builder();
+
+ $provider = new \phpbb\auth\provider\db($db, $config, $passwords_manager, $request, $user, $phpbb_container, $phpbb_root_path, $phpEx);
if (version_compare(PHP_VERSION, '5.3.7', '<'))
{
$password_hash = '$2a$10$e01Syh9PbJjUkio66eFuUu4FhCE2nRgG7QPc1JACalsPXcIuG2bbi';
diff --git a/tests/auth/provider_oauth_token_storage_test.php b/tests/auth/provider_oauth_token_storage_test.php
index 45daa9816b..71b49ff439 100644
--- a/tests/auth/provider_oauth_token_storage_test.php
+++ b/tests/auth/provider_oauth_token_storage_test.php
@@ -31,7 +31,7 @@ class phpbb_auth_provider_oauth_token_storage_test extends phpbb_database_test_c
global $phpbb_root_path, $phpEx;
$this->db = $this->new_dbal();
- $this->user = $this->getMock('\phpbb\user');
+ $this->user = new \phpbb\user('\phpbb\datetime');
$this->service_name = 'auth.provider.oauth.service.testing';
$this->token_storage_table = 'phpbb_oauth_tokens';
diff --git a/tests/avatar/fixtures/users.xml b/tests/avatar/fixtures/users.xml
new file mode 100644
index 0000000000..3e6586e909
--- /dev/null
+++ b/tests/avatar/fixtures/users.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<dataset>
+ <table name="phpbb_users">
+ <column>user_id</column>
+ <column>username_clean</column>
+ <column>user_permissions</column>
+ <column>user_sig</column>
+ <column>user_avatar</column>
+ <column>user_avatar_type</column>
+ <column>user_avatar_width</column>
+ <column>user_avatar_height</column>
+ <row>
+ <value>1</value>
+ <value>barfoo</value>
+ <value></value>
+ <value></value>
+ <value>foobar@example.com</value>
+ <value>avatar.driver.gravatar</value>
+ <value>80</value>
+ <value>80</value>
+ </row>
+ <row>
+ <value>2</value>
+ <value>foobar</value>
+ <value></value>
+ <value></value>
+ <value></value>
+ <value></value>
+ <value></value>
+ <value></value>
+ </row>
+ </table>
+</dataset>
diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php
index d8099b40d4..81c153aed4 100644
--- a/tests/avatar/manager_test.php
+++ b/tests/avatar/manager_test.php
@@ -13,13 +13,18 @@
require_once dirname(__FILE__) . '/driver/foobar.php';
-class phpbb_avatar_manager_test extends \phpbb_test_case
+class phpbb_avatar_manager_test extends \phpbb_database_test_case
{
/** @var \phpbb\avatar\manager */
protected $manager;
protected $avatar_foobar;
protected $avatar_barfoo;
+ public function getDataSet()
+ {
+ return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/users.xml');
+ }
+
public function setUp()
{
global $phpbb_root_path, $phpEx;
@@ -31,7 +36,7 @@ class phpbb_avatar_manager_test extends \phpbb_test_case
->will($this->returnArgument(0));
// Prepare dependencies for avatar manager and driver
- $config = new \phpbb\config\config(array());
+ $this->config = new \phpbb\config\config(array());
$cache = $this->getMock('\phpbb\cache\driver\driver_interface');
$path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
@@ -52,7 +57,7 @@ class phpbb_avatar_manager_test extends \phpbb_test_case
$guesser = new \phpbb\mimetype\guesser($guessers);
// $this->avatar_foobar will be needed later on
- $this->avatar_foobar = $this->getMock('\phpbb\avatar\driver\foobar', array('get_name'), array($config, $phpbb_root_path, $phpEx, $path_helper, $cache));
+ $this->avatar_foobar = $this->getMock('\phpbb\avatar\driver\foobar', array('get_name'), array($this->config, $phpbb_root_path, $phpEx, $path_helper, $cache));
$this->avatar_foobar->expects($this->any())
->method('get_name')
->will($this->returnValue('avatar.driver.foobar'));
@@ -67,24 +72,26 @@ class phpbb_avatar_manager_test extends \phpbb_test_case
{
if ($driver !== 'upload')
{
- $cur_avatar = $this->getMock('\phpbb\avatar\driver\\' . $driver, array('get_name'), array($config, $phpbb_root_path, $phpEx, $path_helper, $cache));
+ $cur_avatar = $this->getMock('\phpbb\avatar\driver\\' . $driver, array('get_name'), array($this->config, $phpbb_root_path, $phpEx, $path_helper, $cache));
}
else
{
- $cur_avatar = $this->getMock('\phpbb\avatar\driver\\' . $driver, array('get_name'), array($config, $phpbb_root_path, $phpEx, $path_helper, $guesser, $cache));
+ $cur_avatar = $this->getMock('\phpbb\avatar\driver\\' . $driver, array('get_name'), array($this->config, $phpbb_root_path, $phpEx, $path_helper, $guesser, $cache));
}
$cur_avatar->expects($this->any())
->method('get_name')
->will($this->returnValue('avatar.driver.' . $driver));
- $config['allow_avatar_' . get_class($cur_avatar)] = false;
+ $this->config['allow_avatar_' . get_class($cur_avatar)] = $driver == 'gravatar';
$avatar_drivers[] = $cur_avatar;
}
- $config['allow_avatar_' . get_class($this->avatar_foobar)] = true;
- $config['allow_avatar_' . get_class($this->avatar_barfoo)] = false;
+ $this->config['allow_avatar_' . get_class($this->avatar_foobar)] = true;
+ $this->config['allow_avatar_' . get_class($this->avatar_barfoo)] = false;
// Set up avatar manager
- $this->manager = new \phpbb\avatar\manager($config, $avatar_drivers, $phpbb_container);
+ $this->manager = new \phpbb\avatar\manager($this->config, $avatar_drivers, $phpbb_container);
+ $this->db = $this->new_dbal();
+ $this->user = new \phpbb\user('\phpbb\datetime');
}
protected function avatar_drivers()
@@ -122,6 +129,7 @@ class phpbb_avatar_manager_test extends \phpbb_test_case
{
return array(
array('avatar.driver.foobar', 'avatar.driver.foobar'),
+ array('avatar.driver.gravatar', 'avatar.driver.gravatar'),
array('avatar.driver.foo_wrong', null),
array('avatar.driver.local', null),
array(AVATAR_GALLERY, null),
@@ -196,8 +204,8 @@ class phpbb_avatar_manager_test extends \phpbb_test_case
array(
'avatar' => '',
'avatar_type' => '',
- 'avatar_width' => '',
- 'avatar_height' => '',
+ 'avatar_width' => 0,
+ 'avatar_height' => 0,
),
),
array(
@@ -266,7 +274,7 @@ class phpbb_avatar_manager_test extends \phpbb_test_case
public function test_localize_errors()
{
- $user = $this->getMock('\phpbb\user');
+ $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
$lang_array = array(
array('FOOBAR_OFF', 'foobar_off'),
array('FOOBAR_EXPLAIN', 'FOOBAR_EXPLAIN %s'),
@@ -287,4 +295,42 @@ class phpbb_avatar_manager_test extends \phpbb_test_case
array('FOOBAR_EXPLAIN', 'foo'),
)));
}
+
+ public function data_handle_avatar_delete()
+ {
+ return array(
+ array(array(
+ 'avatar' => '',
+ 'avatar_type' => '',
+ 'avatar_width' => 0,
+ 'avatar_height' => 0,
+ ), 1, array(
+ 'avatar' => 'foobar@example.com',
+ 'avatar_type' => 'avatar.driver.gravatar',
+ 'avatar_width' => '16',
+ 'avatar_height' => '16',
+ ), USERS_TABLE, 'user_'),
+ );
+ }
+
+ /**
+ * @dataProvider data_handle_avatar_delete
+ */
+ public function test_handle_avatar_delete($expected, $id, $avatar_data, $table, $prefix)
+ {
+ $this->config['allow_avatar_gravatar'] = true;
+ $this->assertNull($this->manager->handle_avatar_delete($this->db, $this->user, $avatar_data, $table, $prefix));
+
+ $sql = 'SELECT * FROM ' . $table . '
+ WHERE ' . $prefix . 'id = ' . $id;
+ $result = $this->db->sql_query_limit($sql, 1);
+
+ $row = $this->manager->clean_row($this->db->sql_fetchrow($result), substr($prefix, 0, -1));
+ $this->db->sql_freeresult($result);
+
+ foreach ($expected as $key => $value)
+ {
+ $this->assertEquals($value, $row[$key]);
+ }
+ }
}
diff --git a/tests/bootstrap.php b/tests/bootstrap.php
index 2856ba02bb..bb4a703cc3 100644
--- a/tests/bootstrap.php
+++ b/tests/bootstrap.php
@@ -31,5 +31,4 @@ require_once 'test_framework/phpbb_test_case_helpers.php';
require_once 'test_framework/phpbb_test_case.php';
require_once 'test_framework/phpbb_database_test_case.php';
require_once 'test_framework/phpbb_database_test_connection_manager.php';
-require_once 'test_framework/phpbb_mink_test_case.php';
require_once 'test_framework/phpbb_functional_test_case.php';
diff --git a/tests/config_php_file_test.php b/tests/config_php_file_test.php
index c2e4eb21c7..c319678108 100644
--- a/tests/config_php_file_test.php
+++ b/tests/config_php_file_test.php
@@ -17,6 +17,7 @@ class phpbb_config_php_file_test extends phpbb_test_case
{
$config_php = new \phpbb\config_php_file(dirname( __FILE__ ) . '/fixtures/', 'php');
$this->assertSame('bar', $config_php->get('foo'));
+ $this->assertNull($config_php->get('bar'));
$this->assertSame(array('foo' => 'bar', 'foo_foo' => 'bar bar'), $config_php->get_all());
}
@@ -25,6 +26,15 @@ class phpbb_config_php_file_test extends phpbb_test_case
$config_php = new \phpbb\config_php_file(dirname( __FILE__ ) . '/fixtures/', 'php');
$config_php->set_config_file(dirname( __FILE__ ) . '/fixtures/config_other.php');
$this->assertSame('foo', $config_php->get('bar'));
+ $this->assertNull($config_php->get('foo'));
$this->assertSame(array('bar' => 'foo', 'bar_bar' => 'foo foo'), $config_php->get_all());
}
+
+ public function test_non_existent_file()
+ {
+ $config_php = new \phpbb\config_php_file(dirname( __FILE__ ) . '/fixtures/non_existent/', 'php');
+ $this->assertNull($config_php->get('bar'));
+ $this->assertNull($config_php->get('foo'));
+ $this->assertSame(array(), $config_php->get_all());
+ }
}
diff --git a/tests/console/cron/cron_list_test.php b/tests/console/cron/cron_list_test.php
index 1059a3f221..22423304be 100644
--- a/tests/console/cron/cron_list_test.php
+++ b/tests/console/cron/cron_list_test.php
@@ -32,7 +32,7 @@ class phpbb_console_command_cron_list_test extends phpbb_test_case
protected function setUp()
{
- $this->user = $this->getMock('\phpbb\user');
+ $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
$this->user->method('lang')->will($this->returnArgument(0));
}
diff --git a/tests/console/cron/run_test.php b/tests/console/cron/run_test.php
index 60bd74e1f0..029dc5249b 100644
--- a/tests/console/cron/run_test.php
+++ b/tests/console/cron/run_test.php
@@ -41,7 +41,7 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
set_config(null, null, null, $this->config);
$this->lock = new \phpbb\lock\db('cron_lock', $this->config, $this->db);
- $this->user = $this->getMock('\phpbb\user');
+ $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
$this->user->method('lang')->will($this->returnArgument(0));
$this->task = new phpbb_cron_task_simple();
diff --git a/tests/content_visibility/delete_post_test.php b/tests/content_visibility/delete_post_test.php
index aa705c52a5..65dda3ce48 100644
--- a/tests/content_visibility/delete_post_test.php
+++ b/tests/content_visibility/delete_post_test.php
@@ -67,6 +67,9 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
array(
array('forum_posts_approved' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 0, 'forum_topics_approved' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 3),
),
+ array(
+ array('user_posts' => 3),
+ ),
),
array(
1, 1, 1,
@@ -93,6 +96,9 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
array(
array('forum_posts_approved' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 0, 'forum_topics_approved' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 3),
),
+ array(
+ array('user_posts' => 3),
+ ),
),
array(
1, 1, 3,
@@ -119,6 +125,9 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
array(
array('forum_posts_approved' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 0, 'forum_topics_approved' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 2),
),
+ array(
+ array('user_posts' => 3),
+ ),
),
array(
1, 1, 2,
@@ -145,6 +154,9 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
array(
array('forum_posts_approved' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 1, 'forum_topics_approved' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 3),
),
+ array(
+ array('user_posts' => 3),
+ ),
),
array(
1, 1, 1,
@@ -171,6 +183,9 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
array(
array('forum_posts_approved' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 1, 'forum_topics_approved' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 3),
),
+ array(
+ array('user_posts' => 3),
+ ),
),
array(
1, 1, 3,
@@ -197,6 +212,9 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
array(
array('forum_posts_approved' => 2, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 1, 'forum_topics_approved' => 1, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 2),
),
+ array(
+ array('user_posts' => 3),
+ ),
),
array(
@@ -222,6 +240,9 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
array(
array('forum_posts_approved' => 0, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 0, 'forum_topics_approved' => 0, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 0, 'forum_last_post_id' => 0),
),
+ array(
+ array('user_posts' => 3),
+ ),
),
array(
@@ -257,6 +278,9 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
array(
array('forum_posts_approved' => 0, 'forum_posts_unapproved' => 0, 'forum_posts_softdeleted' => 1, 'forum_topics_approved' => 0, 'forum_topics_unapproved' => 0, 'forum_topics_softdeleted' => 1, 'forum_last_post_id' => 0),
),
+ array(
+ array('user_posts' => 3),
+ ),
),
);
}
@@ -264,7 +288,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
/**
* @dataProvider delete_post_data
*/
- public function test_delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason, $expected_posts, $expected_topic, $expected_forum)
+ public function test_delete_post($forum_id, $topic_id, $post_id, $data, $is_soft, $reason, $expected_posts, $expected_topic, $expected_forum, $expected_user)
{
global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $phpbb_root_path, $phpEx;
@@ -282,7 +306,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
->will($this->returnValueMap(array(
array('m_approve', 1, true),
)));
- $user = $this->getMock('\phpbb\user');
+ $user = new \phpbb\user('\phpbb\datetime');
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
@@ -313,5 +337,13 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
$this->assertEquals($expected_forum, $db->sql_fetchrowset($result));
$db->sql_freeresult($result);
+
+ $sql = 'SELECT user_posts
+ FROM ' . USERS_TABLE . '
+ WHERE user_id = ' . (int) $data['poster_id'];
+ $result = $db->sql_query($sql);
+
+ $this->assertEquals($expected_user, $db->sql_fetchrowset($result));
+ $db->sql_freeresult($result);
}
}
diff --git a/tests/content_visibility/get_forums_visibility_sql_test.php b/tests/content_visibility/get_forums_visibility_sql_test.php
index 7e4ce6577d..fe7ab36436 100644
--- a/tests/content_visibility/get_forums_visibility_sql_test.php
+++ b/tests/content_visibility/get_forums_visibility_sql_test.php
@@ -134,7 +134,7 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data
->method('acl_getf')
->with($this->stringContains('_'), $this->anything())
->will($this->returnValueMap($permissions));
- $user = $this->getMock('\phpbb\user');
+ $user = new \phpbb\user('\phpbb\datetime');
$config = new phpbb\config\config(array());
$content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE);
diff --git a/tests/content_visibility/get_global_visibility_sql_test.php b/tests/content_visibility/get_global_visibility_sql_test.php
index 082e0d76ab..43a80c792b 100644
--- a/tests/content_visibility/get_global_visibility_sql_test.php
+++ b/tests/content_visibility/get_global_visibility_sql_test.php
@@ -134,7 +134,7 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data
->method('acl_getf')
->with($this->stringContains('_'), $this->anything())
->will($this->returnValueMap($permissions));
- $user = $this->getMock('\phpbb\user');
+ $user = new \phpbb\user('\phpbb\datetime');
$config = new phpbb\config\config(array());
$content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE);
diff --git a/tests/content_visibility/get_visibility_sql_test.php b/tests/content_visibility/get_visibility_sql_test.php
index 2d4f24f1c6..f718e6c29a 100644
--- a/tests/content_visibility/get_visibility_sql_test.php
+++ b/tests/content_visibility/get_visibility_sql_test.php
@@ -81,7 +81,7 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te
->method('acl_get')
->with($this->stringContains('_'), $this->anything())
->will($this->returnValueMap($permissions));
- $user = $this->getMock('\phpbb\user');
+ $user = new \phpbb\user('\phpbb\datetime');
$config = new phpbb\config\config(array());
$content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE);
diff --git a/tests/content_visibility/set_post_visibility_test.php b/tests/content_visibility/set_post_visibility_test.php
index a596b45714..ab79fbc2ee 100644
--- a/tests/content_visibility/set_post_visibility_test.php
+++ b/tests/content_visibility/set_post_visibility_test.php
@@ -124,7 +124,7 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
$auth = $this->getMock('\phpbb\auth\auth');
- $user = $this->getMock('\phpbb\user');
+ $user = new \phpbb\user('\phpbb\datetime');
$config = new phpbb\config\config(array());
$content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE);
@@ -174,7 +174,7 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
$auth = $this->getMock('\phpbb\auth\auth');
- $user = $this->getMock('\phpbb\user');
+ $user = new \phpbb\user('\phpbb\datetime');
$config = new phpbb\config\config(array());
$content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE);
diff --git a/tests/content_visibility/set_topic_visibility_test.php b/tests/content_visibility/set_topic_visibility_test.php
index 230474428c..4d02a55490 100644
--- a/tests/content_visibility/set_topic_visibility_test.php
+++ b/tests/content_visibility/set_topic_visibility_test.php
@@ -88,7 +88,7 @@ class phpbb_content_visibility_set_topic_visibility_test extends phpbb_database_
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
$auth = $this->getMock('\phpbb\auth\auth');
- $user = $this->getMock('\phpbb\user');
+ $user = new \phpbb\user('\phpbb\datetime');
$config = new phpbb\config\config(array());
$content_visibility = new \phpbb\content_visibility($auth, $config, $db, $user, $phpbb_root_path, $phpEx, FORUMS_TABLE, POSTS_TABLE, TOPICS_TABLE, USERS_TABLE);
diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php
index 67faf83e29..58bcf0ef81 100644
--- a/tests/controller/controller_test.php
+++ b/tests/controller/controller_test.php
@@ -72,7 +72,7 @@ class phpbb_controller_controller_test extends phpbb_test_case
include(__DIR__.'/phpbb/controller/foo.php');
}
- $resolver = new \phpbb\controller\resolver(new \phpbb\user, $container, dirname(__FILE__) . '/');
+ $resolver = new \phpbb\controller\resolver(new \phpbb\user('\phpbb\datetime'), $container, dirname(__FILE__) . '/');
$symfony_request = new Request();
$symfony_request->attributes->set('_controller', 'foo.controller:handle');
diff --git a/tests/controller/helper_route_test.php b/tests/controller/helper_route_test.php
index 206c3a4f0b..04bff81683 100644
--- a/tests/controller/helper_route_test.php
+++ b/tests/controller/helper_route_test.php
@@ -20,7 +20,7 @@ class phpbb_controller_helper_route_test extends phpbb_test_case
global $phpbb_dispatcher, $phpbb_root_path, $phpEx;
$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
- $this->user = $this->getMock('\phpbb\user');
+ $this->user = new \phpbb\user('\phpbb\datetime');
$phpbb_path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
new phpbb_mock_request()
diff --git a/tests/datetime/from_format_test.php b/tests/datetime/from_format_test.php
index 88eec525a3..5f155adbbd 100644
--- a/tests/datetime/from_format_test.php
+++ b/tests/datetime/from_format_test.php
@@ -39,7 +39,7 @@ class phpbb_datetime_from_format_test extends phpbb_test_case
{
global $user;
- $user = new \phpbb\user();
+ $user = new \phpbb\user('\phpbb\datetime');
$user->timezone = new DateTimeZone($timezone);
$user->lang['datetime'] = array(
'TODAY' => 'Today',
diff --git a/tests/dbal/db_tools_test.php b/tests/dbal/db_tools_test.php
index 6cc2f8ec0f..51f9daacfb 100644
--- a/tests/dbal/db_tools_test.php
+++ b/tests/dbal/db_tools_test.php
@@ -288,13 +288,13 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
$this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12012_2'));
// Create index over the column
- $this->assertFalse($this->tools->sql_index_exists('prefix_table_name', 'i_bug_12012_2'));
- $this->assertTrue($this->tools->sql_create_index('prefix_table_name', 'i_bug_12012_2', array('c_bug_12012_2', 'c_bool')));
- $this->assertTrue($this->tools->sql_index_exists('prefix_table_name', 'i_bug_12012_2'));
+ $this->assertFalse($this->tools->sql_index_exists('prefix_table_name', 'bug_12012_2'));
+ $this->assertTrue($this->tools->sql_create_index('prefix_table_name', 'bug_12012_2', array('c_bug_12012_2', 'c_bool')));
+ $this->assertTrue($this->tools->sql_index_exists('prefix_table_name', 'bug_12012_2'));
- $this->assertFalse($this->tools->sql_index_exists('prefix_table_name', 'i_bug_12012_3'));
- $this->assertTrue($this->tools->sql_create_index('prefix_table_name', 'i_bug_12012_3', array('c_bug_12012_2')));
- $this->assertTrue($this->tools->sql_index_exists('prefix_table_name', 'i_bug_12012_3'));
+ $this->assertFalse($this->tools->sql_index_exists('prefix_table_name', 'bug_12012_3'));
+ $this->assertTrue($this->tools->sql_create_index('prefix_table_name', 'bug_12012_3', array('c_bug_12012_2')));
+ $this->assertTrue($this->tools->sql_index_exists('prefix_table_name', 'bug_12012_3'));
// Remove the column
$this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_bug_12012_2'));
diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php
index 4a1d15aea4..10a9444d63 100644
--- a/tests/dbal/migrator_test.php
+++ b/tests/dbal/migrator_test.php
@@ -60,7 +60,7 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
$container = new phpbb_mock_container_builder();
$container->set('migrator', $migrator);
- $user = new \phpbb\user();
+ $user = new \phpbb\user('\phpbb\datetime');
$this->extension_manager = new \phpbb\extension\manager(
$container,
diff --git a/tests/dbal/migrator_tool_module_test.php b/tests/dbal/migrator_tool_module_test.php
index aeb69e27ac..08c3e979b8 100644
--- a/tests/dbal/migrator_tool_module_test.php
+++ b/tests/dbal/migrator_tool_module_test.php
@@ -32,7 +32,7 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
$db = $this->db = $this->new_dbal();
$this->cache = new \phpbb\cache\service(new \phpbb\cache\driver\null(), new \phpbb\config\config(array()), $this->db, $phpbb_root_path, $phpEx);
- $user = $this->user = new \phpbb\user();
+ $user = $this->user = new \phpbb\user('\phpbb\user');
$cache = new phpbb_mock_cache;
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
diff --git a/tests/dbal/select_test.php b/tests/dbal/select_test.php
index e480716a49..b7074552ba 100644
--- a/tests/dbal/select_test.php
+++ b/tests/dbal/select_test.php
@@ -233,6 +233,66 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
$db->sql_freeresult($result);
}
+ public function not_like_expression_data()
+ {
+ // * = any_char; # = one_char
+ return array(
+ array('barfoo', array(
+ array('username_clean' => 'foobar'),
+ array('username_clean' => 'bertie')
+ )),
+ array('bar', array(
+ array('username_clean' => 'barfoo'),
+ array('username_clean' => 'foobar'),
+ array('username_clean' => 'bertie'),
+ )),
+ array('bar*', array(
+ array('username_clean' => 'foobar'),
+ array('username_clean' => 'bertie'))
+ ),
+ array('*bar*', array(array('username_clean' => 'bertie'))),
+ array('b*r', array(
+ array('username_clean' => 'barfoo'),
+ array('username_clean' => 'foobar'),
+ array('username_clean' => 'bertie')
+ )),
+ array('b*e', array(
+ array('username_clean' => 'barfoo'),
+ array('username_clean' => 'foobar')
+ )),
+ array('#b*e', array(
+ array('username_clean' => 'barfoo'),
+ array('username_clean' => 'foobar'),
+ array('username_clean' => 'bertie')
+ )),
+ array('b####e', array(
+ array('username_clean' => 'barfoo'),
+ array('username_clean' => 'foobar')
+ )),
+ );
+ }
+
+ /**
+ * @dataProvider not_like_expression_data
+ */
+ public function test_not_like_expression($like_expression, $expected)
+ {
+ $db = $this->new_dbal();
+
+ $like_expression = str_replace('*', $db->get_any_char(), $like_expression);
+ $like_expression = str_replace('#', $db->get_one_char(), $like_expression);
+ $where = ($like_expression) ? 'username_clean ' . $db->sql_not_like_expression($like_expression) : '';
+
+ $result = $db->sql_query('SELECT username_clean
+ FROM phpbb_users
+ ' . (($where) ? ' WHERE ' . $where : '') . '
+ ORDER BY user_id ASC');
+
+ $this->assertEquals($expected, $db->sql_fetchrowset($result));
+
+ $db->sql_freeresult($result);
+ }
+
public function in_set_data()
{
return array(
diff --git a/tests/di/create_container_test.php b/tests/di/create_container_test.php
index 559c0b122c..4ae6017989 100644
--- a/tests/di/create_container_test.php
+++ b/tests/di/create_container_test.php
@@ -191,6 +191,10 @@ namespace phpbb\db\driver
{
}
+ function sql_not_like_expression($expression)
+ {
+ }
+
function sql_fetchrowset($query_id = false)
{
return array(
diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php
index 1e43c2a0a3..5ec8e60a68 100644
--- a/tests/extension/manager_test.php
+++ b/tests/extension/manager_test.php
@@ -154,7 +154,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
$phpbb_root_path = __DIR__ . './../../phpBB/';
$php_ext = 'php';
$table_prefix = 'phpbb_';
- $user = new \phpbb\user();
+ $user = new \phpbb\user('\phpbb\user');
$migrator = new \phpbb\db\migrator(
$config,
diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php
index 535e4fe0d5..8e27b39459 100644
--- a/tests/extension/metadata_manager_test.php
+++ b/tests/extension/metadata_manager_test.php
@@ -44,7 +44,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$this->db_tools = new \phpbb\db\tools($this->db);
$this->phpbb_root_path = dirname(__FILE__) . '/';
$this->phpEx = 'php';
- $this->user = new \phpbb\user();
+ $this->user = new \phpbb\user('\phpbb\datetime');
$this->table_prefix = 'phpbb_';
$this->template = new \phpbb\template\twig\twig(
diff --git a/tests/functional/avatar_acp_groups_test.php b/tests/functional/avatar_acp_groups_test.php
index 35f7956252..925335a2f7 100644
--- a/tests/functional/avatar_acp_groups_test.php
+++ b/tests/functional/avatar_acp_groups_test.php
@@ -48,7 +48,7 @@ class phpbb_functional_avatar_acp_groups_test extends phpbb_functional_common_av
),
// Delete avatar image to reset group settings
array(
- 'GROUP_UPDATED',
+ array('CONFIRM_AVATAR_DELETE', 'GROUP_UPDATED'),
'avatar_driver_gravatar',
array(
'avatar_delete' => array('tick', ''),
diff --git a/tests/functional/avatar_acp_users_test.php b/tests/functional/avatar_acp_users_test.php
index 38e001f516..5eca473157 100644
--- a/tests/functional/avatar_acp_users_test.php
+++ b/tests/functional/avatar_acp_users_test.php
@@ -46,7 +46,7 @@ class phpbb_functional_avatar_acp_users_test extends phpbb_functional_common_ava
),
// Reset avatar settings
array(
- 'USER_AVATAR_UPDATED',
+ array('CONFIRM_AVATAR_DELETE', 'USER_AVATAR_UPDATED'),
'avatar_driver_gravatar',
array(
'avatar_delete' => array('tick', ''),
diff --git a/tests/functional/avatar_ucp_groups_test.php b/tests/functional/avatar_ucp_groups_test.php
index fddf66933f..1e8ca911c6 100644
--- a/tests/functional/avatar_ucp_groups_test.php
+++ b/tests/functional/avatar_ucp_groups_test.php
@@ -55,7 +55,7 @@ class phpbb_functional_avatar_ucp_groups_test extends phpbb_functional_common_av
),
),
array(
- 'GROUP_UPDATED',
+ array('CONFIRM_AVATAR_DELETE', 'GROUP_UPDATED'),
'avatar_driver_gravatar',
array(
'avatar_delete' => array('tick', ''),
diff --git a/tests/functional/avatar_ucp_users_test.php b/tests/functional/avatar_ucp_users_test.php
index 62cd79c307..972bfa0fb2 100644
--- a/tests/functional/avatar_ucp_users_test.php
+++ b/tests/functional/avatar_ucp_users_test.php
@@ -36,18 +36,9 @@ class phpbb_functional_avatar_ucp_users_test extends phpbb_functional_common_ava
'avatar_gravatar_height' => 80,
),
),
- // Wrong driver selected
- array(
- 'NO_AVATAR_SELECTED',
- 'avatar_driver_upload',
- array(
- 'avatar_remote_url' => 'https://secure.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg',
- 'avatar_remote_width' => 80,
- 'avatar_remote_height' => 80,
- ),
- ),
+
array(
- 'PROFILE_UPDATED',
+ array('CONFIRM_AVATAR_DELETE', 'PROFILE_UPDATED'),
'avatar_driver_gravatar',
array(
'avatar_delete' => array('tick', ''),
diff --git a/tests/functional/common_avatar_test.php b/tests/functional/common_avatar_test.php
index 1bb9e5cd8e..82d7136c98 100644
--- a/tests/functional/common_avatar_test.php
+++ b/tests/functional/common_avatar_test.php
@@ -50,7 +50,7 @@ abstract class phpbb_functional_common_avatar_test extends phpbb_functional_test
$this->assertContainsLang('CONFIG_UPDATED', $crawler->text());
}
- public function assert_avatar_submit($expected, $type, $data, $button_text = 'SUBMIT')
+ public function assert_avatar_submit($expected, $type, $data, $delete = false, $button_text = 'SUBMIT')
{
$crawler = self::request('GET', $this->get_url() . '&sid=' . $this->sid);
@@ -72,6 +72,12 @@ abstract class phpbb_functional_common_avatar_test extends phpbb_functional_test
$crawler = self::submit($form);
+ if (is_array($expected))
+ {
+ $delete_expected = $expected[1];
+ $expected = $expected[0];
+ }
+
try
{
$this->assertContainsLang($expected, $crawler->text());
@@ -80,5 +86,12 @@ abstract class phpbb_functional_common_avatar_test extends phpbb_functional_test
{
$this->assertContains($expected, $crawler->text());
}
+
+ if ($delete)
+ {
+ $form = $crawler->selectButton('confirm')->form();
+ $crawler = self::submit($form);
+ $this->assertContainsLang($delete_expected, $crawler->text());
+ }
}
}
diff --git a/tests/functional/download_test.php b/tests/functional/download_test.php
index 6a6df14c81..4e4995c21e 100644
--- a/tests/functional/download_test.php
+++ b/tests/functional/download_test.php
@@ -80,20 +80,6 @@ class phpbb_functional_download_test extends phpbb_functional_test_case
'attachments' => true,
));
- // Download topic archive as guest
- $crawler = self::request('GET', "download/file.php?archive=.zip&topic_id={$this->data['topics']['Download Topic #1']}", array(), false);
- self::assert_response_status_code(200);
- $content = self::$client->getResponse()->getContent();
- $finfo = new finfo(FILEINFO_MIME_TYPE);
- self::assertEquals('application/zip', $finfo->buffer($content));
-
- // Download post archive as guest
- $crawler = self::request('GET', "download/file.php?archive=.zip&post_id={$this->data['posts']['Re: Download Topic #1-#2']}", array(), false);
- self::assert_response_status_code(200);
- $content = self::$client->getResponse()->getContent();
- $finfo = new finfo(FILEINFO_MIME_TYPE);
- self::assertEquals('application/zip', $finfo->buffer($content));
-
// Download attachment as guest
$crawler = self::request('GET', "download/file.php?id={$this->data['attachments'][$this->data['posts']['Re: Download Topic #1-#2']]}", array(), false);
self::assert_response_status_code(200);
@@ -147,18 +133,6 @@ class phpbb_functional_download_test extends phpbb_functional_test_case
));
$this->add_lang('viewtopic');
- // Download topic archive as guest: still works
- $crawler = self::request('GET', "download/file.php?archive=.zip&topic_id={$this->data['topics']['Download Topic #1']}", array(), false);
- self::assert_response_status_code(200);
- $content = self::$client->getResponse()->getContent();
- $finfo = new finfo(FILEINFO_MIME_TYPE);
- self::assertEquals('application/zip', $finfo->buffer($content));
-
- // No download post archive as guest
- $crawler = self::request('GET', "download/file.php?archive=.zip&post_id={$this->data['posts']['Re: Download Topic #1-#2']}", array(), false);
- self::assert_response_html(404);
- $this->assertContainsLang('ERROR_NO_ATTACHMENT', $crawler->filter('#message')->text());
-
// No download attachment as guest
$crawler = self::request('GET', "download/file.php?id={$this->data['attachments'][$this->data['posts']['Re: Download Topic #1-#2']]}", array(), false);
self::assert_response_html(404);
@@ -167,20 +141,6 @@ class phpbb_functional_download_test extends phpbb_functional_test_case
// Login as admin and try again, should work now.
$this->login();
- // Download topic archive as admin
- $crawler = self::request('GET', "download/file.php?archive=.zip&topic_id={$this->data['topics']['Download Topic #1']}", array(), false);
- self::assert_response_status_code(200);
- $content = self::$client->getResponse()->getContent();
- $finfo = new finfo(FILEINFO_MIME_TYPE);
- self::assertEquals('application/zip', $finfo->buffer($content));
-
- // Download post archive as admin
- $crawler = self::request('GET', "download/file.php?archive=.zip&post_id={$this->data['posts']['Re: Download Topic #1-#2']}", array(), false);
- self::assert_response_status_code(200);
- $content = self::$client->getResponse()->getContent();
- $finfo = new finfo(FILEINFO_MIME_TYPE);
- self::assertEquals('application/zip', $finfo->buffer($content));
-
// Download attachment as admin
$crawler = self::request('GET', "download/file.php?id={$this->data['attachments'][$this->data['posts']['Re: Download Topic #1-#2']]}", array(), false);
self::assert_response_status_code(200);
@@ -235,16 +195,6 @@ class phpbb_functional_download_test extends phpbb_functional_test_case
));
$this->add_lang('viewtopic');
- // Download topic archive as guest: still works
- $crawler = self::request('GET', "download/file.php?archive=.zip&topic_id={$this->data['topics']['Download Topic #1']}", array(), false);
- self::assert_response_html(404);
- $this->assertContainsLang('ERROR_NO_ATTACHMENT', $crawler->filter('#message')->text());
-
- // No download post archive as guest
- $crawler = self::request('GET', "download/file.php?archive=.zip&post_id={$this->data['posts']['Re: Download Topic #1-#2']}", array(), false);
- self::assert_response_html(404);
- $this->assertContainsLang('ERROR_NO_ATTACHMENT', $crawler->filter('#message')->text());
-
// No download attachment as guest
$crawler = self::request('GET', "download/file.php?id={$this->data['attachments'][$this->data['posts']['Re: Download Topic #1-#2']]}", array(), false);
self::assert_response_html(404);
@@ -253,20 +203,6 @@ class phpbb_functional_download_test extends phpbb_functional_test_case
// Login as admin and try again, should work now.
$this->login();
- // Download topic archive as admin
- $crawler = self::request('GET', "download/file.php?archive=.zip&topic_id={$this->data['topics']['Download Topic #1']}", array(), false);
- self::assert_response_status_code(200);
- $content = self::$client->getResponse()->getContent();
- $finfo = new finfo(FILEINFO_MIME_TYPE);
- self::assertEquals('application/zip', $finfo->buffer($content));
-
- // Download post archive as admin
- $crawler = self::request('GET', "download/file.php?archive=.zip&post_id={$this->data['posts']['Re: Download Topic #1-#2']}", array(), false);
- self::assert_response_status_code(200);
- $content = self::$client->getResponse()->getContent();
- $finfo = new finfo(FILEINFO_MIME_TYPE);
- self::assertEquals('application/zip', $finfo->buffer($content));
-
// Download attachment as admin
$crawler = self::request('GET', "download/file.php?id={$this->data['attachments'][$this->data['posts']['Re: Download Topic #1-#2']]}", array(), false);
self::assert_response_status_code(200);
diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php
index 29036c821e..e87953367f 100644
--- a/tests/functional/fileupload_form_test.php
+++ b/tests/functional/fileupload_form_test.php
@@ -42,8 +42,6 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case
unlink($fileinfo->getPathname());
}
-
- parent::tearDown();
}
private function upload_file($filename, $mimetype)
diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php
index ef39e1d71b..6ece150b23 100644
--- a/tests/functional/fileupload_remote_test.php
+++ b/tests/functional/fileupload_remote_test.php
@@ -45,8 +45,6 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case
global $config, $user;
$user = null;
$config = array();
-
- parent::tearDown();
}
public function test_invalid_extension()
diff --git a/tests/functional/forgot_password_test.php b/tests/functional/forgot_password_test.php
index c95efc5b2e..64fa19557f 100644
--- a/tests/functional/forgot_password_test.php
+++ b/tests/functional/forgot_password_test.php
@@ -57,7 +57,5 @@ class phpbb_functional_forgot_password_test extends phpbb_functional_test_case
'config[allow_password_reset]' => 1,
));
$crawler = self::submit($form);
-
- parent::tearDown();
}
}
diff --git a/tests/functional/plupload_test.php b/tests/functional/plupload_test.php
index d9faec035c..ee71597ffc 100644
--- a/tests/functional/plupload_test.php
+++ b/tests/functional/plupload_test.php
@@ -57,8 +57,6 @@ class phpbb_functional_plupload_test extends phpbb_functional_test_case
unlink($fileinfo->getPathname());
}
-
- parent::tearDown();
}
public function get_urls()
diff --git a/tests/functions/generate_string_list.php b/tests/functions/generate_string_list.php
index 32a04c1501..cd1e37618a 100644
--- a/tests/functions/generate_string_list.php
+++ b/tests/functions/generate_string_list.php
@@ -22,7 +22,7 @@ class phpbb_generate_string_list_test extends phpbb_test_case
{
parent::setUp();
- $this->user = new \phpbb\user();
+ $this->user = new \phpbb\user('\phpbb\datetime');
$this->user->data = array('user_lang' => 'en');
$this->user->add_lang('common');
}
diff --git a/tests/functions/insert_config_array_test.php b/tests/functions/insert_config_array_test.php
new file mode 100644
index 0000000000..bfcb05862e
--- /dev/null
+++ b/tests/functions/insert_config_array_test.php
@@ -0,0 +1,142 @@
+<?php
+/**
+*
+* This file is part of the phpBB Forum Software package.
+*
+* @copyright (c) phpBB Limited <https://www.phpbb.com>
+* @license GNU General Public License, version 2 (GPL-2.0)
+*
+* For full copyright and license information, please see
+* the docs/CREDITS.txt file.
+*
+*/
+
+class phpbb_functions_insert_config_array_test extends phpbb_test_case
+{
+ public function config_display_vars()
+ {
+ return array(
+ 'legend1' => '',
+ 'acp_config_1' => array(),
+ 'acp_config_2' => array(),
+ 'acp_config_3' => array(),
+ 'acp_config_4' => array(),
+ 'acp_config_5' => array(),
+ );
+ }
+
+ public function insert_config_array_data()
+ {
+ return array(
+ array( // Add a new config after 1st array item
+ array('new_config_1' => array()),
+ array('after' => 'legend1'),
+ array(
+ 'legend1' => '',
+ 'new_config_1' => array(),
+ 'acp_config_1' => array(),
+ 'acp_config_2' => array(),
+ 'acp_config_3' => array(),
+ 'acp_config_4' => array(),
+ 'acp_config_5' => array(),
+ ),
+ ),
+ array( // Add a new config after last array item
+ array('new_config_1' => array()),
+ array('after' => 'acp_config_5'),
+ array(
+ 'legend1' => '',
+ 'acp_config_1' => array(),
+ 'acp_config_2' => array(),
+ 'acp_config_3' => array(),
+ 'acp_config_4' => array(),
+ 'acp_config_5' => array(),
+ 'new_config_1' => array(),
+ ),
+ ),
+ array( // Add a new config before 2nd array item
+ array('new_config_1' => array()),
+ array('before' => 'acp_config_1'),
+ array(
+ 'legend1' => '',
+ 'new_config_1' => array(),
+ 'acp_config_1' => array(),
+ 'acp_config_2' => array(),
+ 'acp_config_3' => array(),
+ 'acp_config_4' => array(),
+ 'acp_config_5' => array(),
+ ),
+ ),
+ array( // Add a new config before last config item
+ array('new_config_1' => array()),
+ array('before' => 'acp_config_5'),
+ array(
+ 'legend1' => '',
+ 'acp_config_1' => array(),
+ 'acp_config_2' => array(),
+ 'acp_config_3' => array(),
+ 'acp_config_4' => array(),
+ 'new_config_1' => array(),
+ 'acp_config_5' => array(),
+ ),
+ ),
+ array( // When an array key does not exist
+ array('new_config_1' => array()),
+ array('after' => 'foobar'),
+ array(
+ 'legend1' => '',
+ 'acp_config_1' => array(),
+ 'acp_config_2' => array(),
+ 'acp_config_3' => array(),
+ 'acp_config_4' => array(),
+ 'acp_config_5' => array(),
+ ),
+ ),
+ array( // When after|before is not used correctly (defaults to after)
+ array('new_config_1' => array()),
+ array('foobar' => 'acp_config_1'),
+ array(
+ 'legend1' => '',
+ 'acp_config_1' => array(),
+ 'new_config_1' => array(),
+ 'acp_config_2' => array(),
+ 'acp_config_3' => array(),
+ 'acp_config_4' => array(),
+ 'acp_config_5' => array(),
+ ),
+ ),
+ array( // Add a new config set after the last array item
+ array(
+ 'legend2' => array(),
+ 'new_config_1' => array(),
+ 'new_config_2' => array(),
+ 'new_config_3' => array(),
+ ),
+ array('after' => 'acp_config_5'),
+ array(
+ 'legend1' => '',
+ 'acp_config_1' => array(),
+ 'acp_config_2' => array(),
+ 'acp_config_3' => array(),
+ 'acp_config_4' => array(),
+ 'acp_config_5' => array(),
+ 'legend2' => array(),
+ 'new_config_1' => array(),
+ 'new_config_2' => array(),
+ 'new_config_3' => array(),
+ ),
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider insert_config_array_data
+ */
+ public function test_insert_config_array($new_config, $position, $expected)
+ {
+ $config_array = $this->config_display_vars();
+ $new_config_array = phpbb_insert_config_array($config_array, $new_config, $position);
+
+ $this->assertSame($expected, $new_config_array);
+ }
+}
diff --git a/tests/groupposition/legend_test.php b/tests/groupposition/legend_test.php
index 4bad598a31..fe003e93a7 100644
--- a/tests/groupposition/legend_test.php
+++ b/tests/groupposition/legend_test.php
@@ -37,7 +37,7 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user;
+ $user = new \phpbb\user('\phpbb\datetime');
$user->lang = array();
if ($throws_exception)
@@ -55,7 +55,7 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user;
+ $user = new \phpbb\user('\phpbb\datetime');
$user->lang = array();
$test_class = new \phpbb\groupposition\legend($db, $user);
@@ -95,7 +95,7 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user;
+ $user = new \phpbb\user('\phpbb\datetime');
$user->lang = array();
$test_class = new \phpbb\groupposition\legend($db, $user);
@@ -183,7 +183,7 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user;
+ $user = new \phpbb\user('\phpbb\datetime');
$user->lang = array();
$test_class = new \phpbb\groupposition\legend($db, $user);
@@ -238,7 +238,7 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user;
+ $user = new \phpbb\user('\phpbb\datetime');
$user->lang = array();
$test_class = new \phpbb\groupposition\legend($db, $user);
@@ -293,7 +293,7 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user;
+ $user = new \phpbb\user('\phpbb\datetime');
$user->lang = array();
$test_class = new \phpbb\groupposition\legend($db, $user);
@@ -391,7 +391,7 @@ class phpbb_groupposition_legend_test extends phpbb_database_test_case
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user;
+ $user = new \phpbb\user('\phpbb\datetime');
$user->lang = array();
$test_class = new \phpbb\groupposition\legend($db, $user);
diff --git a/tests/groupposition/teampage_test.php b/tests/groupposition/teampage_test.php
index dbdeb35e9f..1e61e3ebfb 100644
--- a/tests/groupposition/teampage_test.php
+++ b/tests/groupposition/teampage_test.php
@@ -39,7 +39,7 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user;
+ $user = new \phpbb\user('\phpbb\datetime');
$user->lang = array();
if ($throws_exception)
@@ -57,7 +57,7 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user;
+ $user = new \phpbb\user('\phpbb\datetime');
$user->lang = array();
$test_class = new \phpbb\groupposition\teampage($db, $user, $cache);
@@ -141,7 +141,7 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user;
+ $user = new \phpbb\user('\phpbb\datetime');
$user->lang = array();
$test_class = new \phpbb\groupposition\teampage($db, $user, $cache);
@@ -184,7 +184,7 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user;
+ $user = new \phpbb\user('\phpbb\datetime');
$user->lang = array();
$test_class = new \phpbb\groupposition\teampage($db, $user, $cache);
@@ -251,7 +251,7 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user;
+ $user = new \phpbb\user('\phpbb\datetime');
$user->lang = array();
$test_class = new \phpbb\groupposition\teampage($db, $user, $cache);
@@ -303,7 +303,7 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user;
+ $user = new \phpbb\user('\phpbb\datetime');
$user->lang = array();
$test_class = new \phpbb\groupposition\teampage($db, $user, $cache);
@@ -466,7 +466,7 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user;
+ $user = new \phpbb\user('\phpbb\datetime');
$user->lang = array();
$test_class = new \phpbb\groupposition\teampage($db, $user, $cache);
@@ -629,7 +629,7 @@ class phpbb_groupposition_teampage_test extends phpbb_database_test_case
$cache = new phpbb_mock_cache;
$db = $this->new_dbal();
- $user = new \phpbb\user;
+ $user = new \phpbb\user('\phpbb\datetime');
$user->lang = array();
$test_class = new \phpbb\groupposition\teampage($db, $user, $cache);
diff --git a/tests/log/add_test.php b/tests/log/add_test.php
index d7e3760f0f..bacc0c76f7 100644
--- a/tests/log/add_test.php
+++ b/tests/log/add_test.php
@@ -27,7 +27,7 @@ class phpbb_log_add_test extends phpbb_database_test_case
$db = $this->new_dbal();
$cache = new phpbb_mock_cache;
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
- $user = $this->getMock('\phpbb\user');
+ $user = new \phpbb\user('\phpbb\datetime');
$auth = $this->getMock('\phpbb\auth\auth');
$log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
@@ -56,7 +56,7 @@ class phpbb_log_add_test extends phpbb_database_test_case
$db = $this->new_dbal();
$cache = new phpbb_mock_cache;
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
- $user = $this->getMock('\phpbb\user');
+ $user = new \phpbb\user('\phpbb\datetime');
$auth = $this->getMock('\phpbb\auth\auth');
$log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
diff --git a/tests/log/delete_test.php b/tests/log/delete_test.php
index b8be15efa5..ec43182a0c 100644
--- a/tests/log/delete_test.php
+++ b/tests/log/delete_test.php
@@ -30,7 +30,7 @@ class phpbb_log_delete_test extends phpbb_database_test_case
$db = $this->new_dbal();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
- $user = $this->getMock('\phpbb\user');
+ $user = new \phpbb\user('\phpbb\datetime');
$user->data['user_id'] = 1;
$auth = $this->getMock('\phpbb\auth\auth');
diff --git a/tests/log/function_add_log_test.php b/tests/log/function_add_log_test.php
index 99d412537c..63e468498e 100644
--- a/tests/log/function_add_log_test.php
+++ b/tests/log/function_add_log_test.php
@@ -161,7 +161,7 @@ class phpbb_log_function_add_log_test extends phpbb_database_test_case
$db = $this->new_dbal();
$cache = new phpbb_mock_cache;
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
- $user = $this->getMock('\phpbb\user');
+ $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
$auth = $this->getMock('\phpbb\auth\auth');
$phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
diff --git a/tests/notification/base.php b/tests/notification/base.php
index a66e5986fd..bfa9d2a1a4 100644
--- a/tests/notification/base.php
+++ b/tests/notification/base.php
@@ -56,7 +56,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
'allow_topic_notify' => true,
'allow_forum_notify' => true,
));
- $user = $this->user = new \phpbb\user();
+ $user = $this->user = new \phpbb\user('\phpbb\datetime');
$this->user_loader = new \phpbb\user_loader($this->db, $phpbb_root_path, $phpEx, 'phpbb_users');
$auth = $this->auth = new phpbb_mock_notifications_auth();
$cache = $this->cache = new \phpbb\cache\service(
diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php
index bd926e2a98..684dd99280 100644
--- a/tests/notification/submit_post_base.php
+++ b/tests/notification/submit_post_base.php
@@ -85,7 +85,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
// User
- $user = $this->getMock('\phpbb\user');
+ $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
$user->ip = '';
$user->data = array(
'user_id' => 2,
diff --git a/tests/notification/user_list_trim_test.php b/tests/notification/user_list_trim_test.php
index 851c9ec221..c43eff729c 100644
--- a/tests/notification/user_list_trim_test.php
+++ b/tests/notification/user_list_trim_test.php
@@ -53,7 +53,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case
array('u_viewprofile', 1, false),
)));
- $user = new \phpbb\user();
+ $user = new \phpbb\user('\phpbb\datetime');
$user->data = array('user_lang' => 'en');
$user->add_lang('common');
diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php
index ace8c1eed0..321d6c2caf 100644
--- a/tests/pagination/pagination_test.php
+++ b/tests/pagination/pagination_test.php
@@ -29,7 +29,7 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
global $phpbb_dispatcher;
$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
- $this->user = $this->getMock('\phpbb\user');
+ $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
$this->user->expects($this->any())
->method('lang')
->will($this->returnCallback(array($this, 'return_callback_implode')));
diff --git a/tests/profilefields/type_bool_test.php b/tests/profilefields/type_bool_test.php
index bdab179c8c..41c40ddb4b 100644
--- a/tests/profilefields/type_bool_test.php
+++ b/tests/profilefields/type_bool_test.php
@@ -25,7 +25,7 @@ class phpbb_profilefield_type_bool_test extends phpbb_test_case
*/
public function setUp()
{
- $user = $this->getMock('\phpbb\user');
+ $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
$user->expects($this->any())
->method('lang')
->will($this->returnCallback(array($this, 'return_callback_implode')));
diff --git a/tests/profilefields/type_date_test.php b/tests/profilefields/type_date_test.php
index 0ad2cde9fe..123955198e 100644
--- a/tests/profilefields/type_date_test.php
+++ b/tests/profilefields/type_date_test.php
@@ -25,7 +25,7 @@ class phpbb_profilefield_type_date_test extends phpbb_test_case
*/
public function setUp()
{
- $this->user = $this->getMock('\phpbb\user');
+ $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
$this->user->expects($this->any())
->method('lang')
->will($this->returnCallback(array($this, 'return_callback_implode')));
diff --git a/tests/profilefields/type_dropdown_test.php b/tests/profilefields/type_dropdown_test.php
index ebecbf97f0..3845a8e96b 100644
--- a/tests/profilefields/type_dropdown_test.php
+++ b/tests/profilefields/type_dropdown_test.php
@@ -25,7 +25,7 @@ class phpbb_profilefield_type_dropdown_test extends phpbb_test_case
*/
public function setUp()
{
- $user = $this->getMock('\phpbb\user');
+ $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
$user->expects($this->any())
->method('lang')
->will($this->returnCallback(array($this, 'return_callback_implode')));
diff --git a/tests/profilefields/type_googleplus_test.php b/tests/profilefields/type_googleplus_test.php
index fdbdd86553..f3db6ef01f 100644
--- a/tests/profilefields/type_googleplus_test.php
+++ b/tests/profilefields/type_googleplus_test.php
@@ -11,8 +11,27 @@
*
*/
+require_once __DIR__ . '/../../phpBB/includes/utf/utf_tools.php';
+
class phpbb_profilefield_type_googleplus_test extends phpbb_test_case
{
+ protected $field;
+
+ public function setUp()
+ {
+ parent::setUp();
+
+ $user = new \phpbb\user('\phpbb\datetime');
+ $user->add_lang('ucp');
+ $request = $this->getMock('\phpbb\request\request');
+ $template = $this->getMock('\phpbb\template\template');
+
+ $this->field = new \phpbb\profilefields\type\type_googleplus(
+ $request,
+ $template,
+ $user
+ );
+ }
public function get_profile_contact_value_data()
{
return array(
@@ -36,16 +55,6 @@ class phpbb_profilefield_type_googleplus_test extends phpbb_test_case
*/
public function test_get_profile_contact_value($value, $field_options, $expected, $description)
{
- $user = $this->getMock('\phpbb\user');
- $request = $this->getMock('\phpbb\request\request');
- $template = $this->getMock('\phpbb\template\template');
-
- $field = new \phpbb\profilefields\type\type_googleplus(
- $request,
- $template,
- $user
- );
-
$default_field_options = array(
'field_type' => '\phpbb\profilefields\type\type_googleplus',
'field_name' => 'field',
@@ -57,6 +66,29 @@ class phpbb_profilefield_type_googleplus_test extends phpbb_test_case
);
$field_options = array_merge($default_field_options, $field_options);
- $this->assertSame($expected, $field->get_profile_contact_value($value, $field_options), $description);
+ $this->assertSame($expected, $this->field->get_profile_contact_value($value, $field_options), $description);
+ }
+
+ public function data_validate_googleplus()
+ {
+ return array(
+ array('foobar', false),
+ array('2342340929304', false),
+ array('foo<bar', 'The field “googleplus” has invalid characters.'),
+ array('klkd.klkl', false),
+ array('kl+', 'The field “googleplus” has invalid characters.'),
+ array('foo=bar', 'The field “googleplus” has invalid characters.'),
+ array('..foo', 'The field “googleplus” has invalid characters.'),
+ array('foo..bar', 'The field “googleplus” has invalid characters.'),
+ );
+ }
+
+ /**
+ * @dataProvider data_validate_googleplus
+ */
+ public function test_validate_googleplus($input, $expected)
+ {
+ $field_data = array_merge(array('lang_name' => 'googleplus'), $this->field->get_default_option_values());
+ $this->assertSame($expected, $this->field->validate_string_profile_field('string', $input, $field_data));
}
}
diff --git a/tests/profilefields/type_int_test.php b/tests/profilefields/type_int_test.php
index ac48c10a84..07b22525e2 100644
--- a/tests/profilefields/type_int_test.php
+++ b/tests/profilefields/type_int_test.php
@@ -24,7 +24,7 @@ class phpbb_profilefield_type_int_test extends phpbb_test_case
*/
public function setUp()
{
- $user = $this->getMock('\phpbb\user');
+ $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
$user->expects($this->any())
->method('lang')
->will($this->returnCallback(array($this, 'return_callback_implode')));
diff --git a/tests/profilefields/type_string_test.php b/tests/profilefields/type_string_test.php
index 2277526758..d5384e0ae8 100644
--- a/tests/profilefields/type_string_test.php
+++ b/tests/profilefields/type_string_test.php
@@ -30,7 +30,7 @@ class phpbb_profilefield_type_string_test extends phpbb_test_case
{
global $request, $user, $cache;
- $user = $this->getMock('\phpbb\user');
+ $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
$cache = new phpbb_mock_cache;
$user->expects($this->any())
->method('lang')
diff --git a/tests/profilefields/type_url_test.php b/tests/profilefields/type_url_test.php
index a45a28e7c7..372c07418f 100644
--- a/tests/profilefields/type_url_test.php
+++ b/tests/profilefields/type_url_test.php
@@ -26,7 +26,7 @@ class phpbb_profilefield_type_url_test extends phpbb_test_case
*/
public function setUp()
{
- $user = $this->getMock('\phpbb\user');
+ $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
$user->expects($this->any())
->method('lang')
->will($this->returnCallback(array($this, 'return_callback_implode')));
diff --git a/tests/security/base.php b/tests/security/base.php
index 83d0649dfa..5519cac441 100644
--- a/tests/security/base.php
+++ b/tests/security/base.php
@@ -59,7 +59,7 @@ abstract class phpbb_security_test_base extends phpbb_test_case
$phpbb_filesystem = new \phpbb\filesystem($symfony_request, $phpbb_root_path, $phpEx);
// Set no user and trick a bit to circumvent errors
- $user = new \phpbb\user();
+ $user = new \phpbb\user('\phpbb\datetime');
$user->lang = true;
$user->browser = $server['HTTP_USER_AGENT'];
$user->referer = '';
diff --git a/tests/session/garbage_collection_test.php b/tests/session/garbage_collection_test.php
index 0fbc71dcd7..3fad81c68b 100644
--- a/tests/session/garbage_collection_test.php
+++ b/tests/session/garbage_collection_test.php
@@ -12,6 +12,7 @@
*/
require_once dirname(__FILE__) . '/../test_framework/phpbb_session_test_case.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
class phpbb_session_garbage_collection_test extends phpbb_session_test_case
{
@@ -26,6 +27,19 @@ class phpbb_session_garbage_collection_test extends phpbb_session_test_case
{
parent::setUp();
$this->session = $this->session_factory->get_session($this->db);
+
+ global $phpbb_container;
+
+ $plugins = new \phpbb\di\service_collection($phpbb_container);
+ $plugins->add('core.captcha.plugins.nogd');
+ $phpbb_container->set(
+ 'captcha.factory',
+ new \phpbb\captcha\factory($phpbb_container, $plugins)
+ );
+ $phpbb_container->set(
+ 'core.captcha.plugins.nogd',
+ new \phpbb\captcha\plugins\nogd()
+ );
}
public function test_cleanup_all()
@@ -47,7 +61,7 @@ class phpbb_session_garbage_collection_test extends phpbb_session_test_case
global $config;
$config['session_length'] = 0;
// There is an error unless the captcha plugin is set
- $config['captcha_plugin'] = 'phpbb_captcha_nogd';
+ $config['captcha_plugin'] = 'core.captcha.plugins.nogd';
$this->session->session_gc();
$this->check_sessions_equals(
array(),
diff --git a/tests/template/template_test_case.php b/tests/template/template_test_case.php
index 83446b5352..1250397401 100644
--- a/tests/template/template_test_case.php
+++ b/tests/template/template_test_case.php
@@ -65,7 +65,7 @@ class phpbb_template_template_test_case extends phpbb_test_case
$defaults = $this->config_defaults();
$config = new \phpbb\config\config(array_merge($defaults, $new_config));
- $this->user = new \phpbb\user;
+ $this->user = new \phpbb\user('\phpbb\datetime');
$path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index 9bb4d69bf4..49cc72363e 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -11,12 +11,14 @@
*
*/
use Symfony\Component\BrowserKit\CookieJar;
-use Behat\Mink\Driver\Goutte\Client;
-use Behat\Mink\Driver\GoutteDriver;
-class phpbb_functional_test_case extends phpbb_mink_test_case
+require_once __DIR__ . '/../../phpBB/includes/functions_install.php';
+
+class phpbb_functional_test_case extends phpbb_test_case
{
+ static protected $client;
static protected $cookieJar;
+ static protected $root_url;
protected $cache = null;
protected $db = null;
@@ -34,6 +36,7 @@ class phpbb_functional_test_case extends phpbb_mink_test_case
*/
protected $lang = array();
+ static protected $config = array();
static protected $already_installed = false;
static public function setUpBeforeClass()
@@ -43,24 +46,6 @@ class phpbb_functional_test_case extends phpbb_mink_test_case
self::$config = phpbb_test_case_helpers::get_test_config();
self::$root_url = self::$config['phpbb_functional_url'];
- self::$cookieJar = new CookieJar;
- self::$client = new Client(array(), null, self::$cookieJar);
-
- $client_options = array(
- Guzzle\Http\Client::DISABLE_REDIRECTS => true,
- 'curl.options' => array(
- CURLOPT_TIMEOUT => 120,
- ),
- );
-
- self::$client->setClient(new Guzzle\Http\Client('', $client_options));
-
- // Reset the curl handle because it is 0 at this point and not a valid
- // resource
- self::$client->getClient()->getCurlMulti()->reset(true);
-
- self::$driver = new GoutteDriver(self::$client);
-
// 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
@@ -93,6 +78,12 @@ class phpbb_functional_test_case extends phpbb_mink_test_case
$this->bootstrap();
+ self::$cookieJar = new CookieJar;
+ self::$client = new Goutte\Client(array(), null, self::$cookieJar);
+ // Reset the curl handle because it is 0 at this point and not a valid
+ // resource
+ self::$client->getClient()->getCurlMulti()->reset(true);
+
// Clear the language array so that things
// that were added in other tests are gone
$this->lang = array();
@@ -119,14 +110,13 @@ class phpbb_functional_test_case extends phpbb_mink_test_case
protected function tearDown()
{
+ parent::tearDown();
+
if ($this->db instanceof \phpbb\db\driver\driver_interface)
{
// Close the database connections again this test
$this->db->sql_close();
}
-
- self::$cookieJar->clear();
- parent::tearDown();
}
/**
@@ -249,7 +239,7 @@ class phpbb_functional_test_case extends phpbb_mink_test_case
);
$container = new phpbb_mock_container_builder();
$container->set('migrator', $migrator);
- $user = new \phpbb\user();
+ $user = new \phpbb\user('\phpbb\datetime');
$extension_manager = new \phpbb\extension\manager(
$container,
@@ -266,6 +256,144 @@ class phpbb_functional_test_case extends phpbb_mink_test_case
return $extension_manager;
}
+ static protected function install_board()
+ {
+ global $phpbb_root_path, $phpEx;
+
+ self::recreate_database(self::$config);
+
+ $config_file = $phpbb_root_path . "config.$phpEx";
+ $config_file_dev = $phpbb_root_path . "config_dev.$phpEx";
+ $config_file_test = $phpbb_root_path . "config_test.$phpEx";
+
+ if (file_exists($config_file))
+ {
+ if (!file_exists($config_file_dev))
+ {
+ rename($config_file, $config_file_dev);
+ }
+ else
+ {
+ unlink($config_file);
+ }
+ }
+
+ self::$cookieJar = new CookieJar;
+ self::$client = new Goutte\Client(array(), null, self::$cookieJar);
+ // Set client manually so we can increase the cURL timeout
+ self::$client->setClient(new Guzzle\Http\Client('', array(
+ Guzzle\Http\Client::DISABLE_REDIRECTS => true,
+ 'curl.options' => array(
+ CURLOPT_TIMEOUT => 120,
+ ),
+ )));
+
+ // Reset the curl handle because it is 0 at this point and not a valid
+ // resource
+ self::$client->getClient()->getCurlMulti()->reset(true);
+
+ $parseURL = parse_url(self::$config['phpbb_functional_url']);
+
+ $crawler = self::request('GET', 'install/index.php?mode=install&language=en');
+ self::assertContains('Welcome to Installation', $crawler->filter('#main')->text());
+ $form = $crawler->selectButton('submit')->form();
+
+ // install/index.php?mode=install&sub=requirements
+ $crawler = self::submit($form);
+ self::assertContains('Installation compatibility', $crawler->filter('#main')->text());
+ $form = $crawler->selectButton('submit')->form();
+
+ // install/index.php?mode=install&sub=database
+ $crawler = self::submit($form);
+ self::assertContains('Database configuration', $crawler->filter('#main')->text());
+ $form = $crawler->selectButton('submit')->form(array(
+ // Installer uses 3.0-style dbms name
+ 'dbms' => str_replace('phpbb\db\driver\\', '', self::$config['dbms']),
+ 'dbhost' => self::$config['dbhost'],
+ 'dbport' => self::$config['dbport'],
+ 'dbname' => self::$config['dbname'],
+ 'dbuser' => self::$config['dbuser'],
+ 'dbpasswd' => self::$config['dbpasswd'],
+ 'table_prefix' => self::$config['table_prefix'],
+ ));
+
+ // install/index.php?mode=install&sub=database
+ $crawler = self::submit($form);
+ self::assertContains('Successful connection', $crawler->filter('#main')->text());
+ $form = $crawler->selectButton('submit')->form();
+
+ // install/index.php?mode=install&sub=administrator
+ $crawler = self::submit($form);
+ self::assertContains('Administrator configuration', $crawler->filter('#main')->text());
+ $form = $crawler->selectButton('submit')->form(array(
+ 'default_lang' => 'en',
+ 'admin_name' => 'admin',
+ 'admin_pass1' => 'adminadmin',
+ 'admin_pass2' => 'adminadmin',
+ 'board_email' => 'nobody@example.com',
+ ));
+
+ // install/index.php?mode=install&sub=administrator
+ $crawler = self::submit($form);
+ self::assertContains('Tests passed', $crawler->filter('#main')->text());
+ $form = $crawler->selectButton('submit')->form();
+
+ // We have to skip install/index.php?mode=install&sub=config_file
+ // because that step will create a config.php file if phpBB has the
+ // permission to do so. We have to create the config file on our own
+ // in order to get the DEBUG constants defined.
+ $config_php_data = phpbb_create_config_file_data(self::$config, self::$config['dbms'], true, false, true);
+ $config_created = file_put_contents($config_file, $config_php_data) !== false;
+ if (!$config_created)
+ {
+ self::markTestSkipped("Could not write $config_file file.");
+ }
+
+ // We also have to create a install lock that is normally created by
+ // the installer. The file will be removed by the final step of the
+ // installer.
+ $install_lock_file = $phpbb_root_path . 'cache/install_lock';
+ $lock_created = file_put_contents($install_lock_file, '') !== false;
+ if (!$lock_created)
+ {
+ self::markTestSkipped("Could not create $lock_created file.");
+ }
+ @chmod($install_lock_file, 0666);
+
+ // install/index.php?mode=install&sub=advanced
+ $form_data = $form->getValues();
+ unset($form_data['submit']);
+
+ $crawler = self::request('POST', 'install/index.php?mode=install&sub=advanced', $form_data);
+ self::assertContains('The settings on this page are only necessary to set if you know that you require something different from the default.', $crawler->filter('#main')->text());
+ $form = $crawler->selectButton('submit')->form(array(
+ 'email_enable' => true,
+ 'smtp_delivery' => true,
+ 'smtp_host' => 'nxdomain.phpbb.com',
+ 'smtp_auth' => 'PLAIN',
+ 'smtp_user' => 'nxuser',
+ 'smtp_pass' => 'nxpass',
+ 'cookie_secure' => false,
+ 'force_server_vars' => false,
+ 'server_protocol' => $parseURL['scheme'] . '://',
+ 'server_name' => 'localhost',
+ 'server_port' => isset($parseURL['port']) ? (int) $parseURL['port'] : 80,
+ 'script_path' => $parseURL['path'],
+ ));
+
+ // install/index.php?mode=install&sub=create_table
+ $crawler = self::submit($form);
+ self::assertContains('The database tables used by phpBB', $crawler->filter('#main')->text());
+ self::assertContains('have been created and populated with some initial data.', $crawler->filter('#main')->text());
+ $form = $crawler->selectButton('submit')->form();
+
+ // install/index.php?mode=install&sub=final
+ $crawler = self::submit($form);
+ self::assertContains('You have successfully installed', $crawler->text());
+
+ copy($config_file, $config_file_test);
+ }
+
public function install_ext($extension)
{
$this->login();
@@ -284,6 +412,12 @@ class phpbb_functional_test_case extends phpbb_mink_test_case
$this->logout();
}
+ static private function recreate_database($config)
+ {
+ $db_conn_mgr = new phpbb_database_test_connection_manager($config);
+ $db_conn_mgr->recreate_db();
+ }
+
/**
* Creates a new style
*
@@ -464,7 +598,7 @@ class phpbb_functional_test_case extends phpbb_mink_test_case
$db = $this->get_db();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
- $user = $this->getMock('\phpbb\user');
+ $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
$auth = $this->getMock('\phpbb\auth\auth');
$phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
@@ -503,7 +637,7 @@ class phpbb_functional_test_case extends phpbb_mink_test_case
$db = $this->get_db();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
- $user = $this->getMock('\phpbb\user');
+ $user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime'));
$auth = $this->getMock('\phpbb\auth\auth');
$phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
diff --git a/tests/test_framework/phpbb_mink_test_case.php b/tests/test_framework/phpbb_mink_test_case.php
deleted file mode 100644
index ba480e35fb..0000000000
--- a/tests/test_framework/phpbb_mink_test_case.php
+++ /dev/null
@@ -1,183 +0,0 @@
-<?php
-/**
-*
-* This file is part of the phpBB Forum Software package.
-*
-* @copyright (c) phpBB Limited <https://www.phpbb.com>
-* @license GNU General Public License, version 2 (GPL-2.0)
-*
-* For full copyright and license information, please see
-* the docs/CREDITS.txt file.
-*
-*/
-use \Behat\Mink\Session;
-
-require_once __DIR__ . '/../../phpBB/includes/functions_install.php';
-
-abstract class phpbb_mink_test_case extends phpbb_test_case
-{
- static protected $driver;
- static protected $client;
- static protected $session;
- static protected $config = array();
- static protected $root_url;
-
- public function __construct($name = null, array $data = array(), $dataName = '')
- {
- parent::__construct($name, $data, $dataName);
-
- $this->backupStaticAttributesBlacklist += array(
- 'phpbb_mink_test_case' => array('config', 'already_installed'),
- );
- }
-
- static public function setUpBeforeClass()
- {
- parent::setUpBeforeClass();
- }
-
- public function setUp()
- {
- parent::setUp();
-
- if (!self::$driver)
- {
- self::markTestSkipped('Mink driver not initialized.');
- }
-
- if (!self::$session)
- {
- self::$session = new Session(self::$driver);
- }
- }
-
- static protected function recreate_database($config)
- {
- $db_conn_mgr = new phpbb_database_test_connection_manager($config);
- $db_conn_mgr->recreate_db();
- }
-
- protected function tearDown()
- {
- self::$session->reset();
- parent::tearDown();
- }
-
- static protected function visit($path)
- {
- self::$session->visit(self::$root_url . $path);
- return self::$session->getPage();
- }
-
- static protected function click_submit($submit_button_id = 'submit')
- {
- self::$session->getPage()->findById($submit_button_id)->click();
- return self::$session->getPage();
- }
-
- static protected function install_board()
- {
- global $phpbb_root_path, $phpEx;
-
- self::recreate_database(self::$config);
- self::$session = new Session(self::$driver);
-
- $config_file = $phpbb_root_path . "config.$phpEx";
- $config_file_dev = $phpbb_root_path . "config_dev.$phpEx";
- $config_file_test = $phpbb_root_path . "config_test.$phpEx";
-
- if (file_exists($config_file))
- {
- if (!file_exists($config_file_dev))
- {
- rename($config_file, $config_file_dev);
- }
- else
- {
- unlink($config_file);
- }
- }
-
- $parseURL = parse_url(self::$config['phpbb_functional_url']);
-
- $page = self::visit('install/index.php?mode=install');
- self::assertContains('Welcome to Installation', $page->findById('main')->getText());
-
- // install/index.php?mode=install&sub=requirements
- $page = self::click_submit();
- self::assertContains('Installation compatibility', $page->findById('main')->getText());
-
- // install/index.php?mode=install&sub=database
- $page = self::click_submit();
- self::assertContains('Database configuration', $page->findById('main')->getText());
-
- $page->findById('dbms')->setValue(str_replace('phpbb\db\driver\\', '', self::$config['dbms']));
- $page->findById('dbhost')->setValue(self::$config['dbhost']);
- $page->findById('dbport')->setValue(self::$config['dbport']);
- $page->findById('dbname')->setValue(self::$config['dbname']);
- $page->findById('dbuser')->setValue(self::$config['dbuser']);
- $page->findById('dbpasswd')->setValue(self::$config['dbpasswd']);
- $page->findById('table_prefix')->setValue(self::$config['table_prefix']);
-
- // install/index.php?mode=install&sub=database
- $page = self::click_submit();
- self::assertContains('Successful connection', $page->findById('main')->getText());
-
- // install/index.php?mode=install&sub=administrator
- $page = self::click_submit();
- self::assertContains('Administrator configuration', $page->findById('main')->getText());
-
- $page->findById('admin_name')->setValue('admin');
- $page->findById('admin_pass1')->setValue('adminadmin');
- $page->findById('admin_pass2')->setValue('adminadmin');
- $page->findById('board_email')->setValue('nobody@example.com');
-
- // install/index.php?mode=install&sub=administrator
- $page = self::click_submit();
- self::assertContains('Tests passed', $page->findById('main')->getText());
-
- // install/index.php?mode=install&sub=config_file
- $page = self::click_submit();
-
- // Installer has created a config.php file, we will overwrite it with a
- // config file of our own in order to get the DEBUG constants defined
- $config_php_data = phpbb_create_config_file_data(self::$config, self::$config['dbms'], true, false, true);
- $config_created = file_put_contents($config_file, $config_php_data) !== false;
- if (!$config_created)
- {
- self::markTestSkipped("Could not write $config_file file.");
- }
-
- if (strpos($page->findById('main')->getText(), 'The configuration file has been written') === false)
- {
- $page = self::click_submit('dldone');
- }
- self::assertContains('The configuration file has been written', $page->findById('main')->getText());
-
- // install/index.php?mode=install&sub=advanced
- $page = self::click_submit();
- self::assertContains('The settings on this page are only necessary to set if you know that you require something different from the default.', $page->findById('main')->getText());
-
- $page->findById('smtp_delivery')->setValue('1');
- $page->findById('smtp_host')->setValue('nxdomain.phpbb.com');
- $page->findById('smtp_user')->setValue('nxuser');
- $page->findById('smtp_pass')->setValue('nxpass');
- $page->findById('server_protocol')->setValue($parseURL['scheme'] . '://');
- $page->findById('server_name')->setValue('localhost');
- $page->findById('server_port')->setValue(isset($parseURL['port']) ? $parseURL['port'] : 80);
- $page->findById('script_path')->setValue($parseURL['path']);
-
- // install/index.php?mode=install&sub=create_table
- $page = self::click_submit();
- self::assertContains('The database tables used by phpBB', $page->findById('main')->getText());
- self::assertContains('have been created and populated with some initial data.', $page->findById('main')->getText());
-
- // install/index.php?mode=install&sub=final
- $page = self::click_submit();
- self::assertContains('You have successfully installed', $page->getText());
-
- copy($config_file, $config_file_test);
-
- self::$session->stop();
- }
-}
diff --git a/tests/user/lang_test.php b/tests/user/lang_test.php
index 45c6b04c65..bb11bb63cb 100644
--- a/tests/user/lang_test.php
+++ b/tests/user/lang_test.php
@@ -17,7 +17,7 @@ class phpbb_user_lang_test extends phpbb_test_case
{
public function test_user_lang_sprintf()
{
- $user = new \phpbb\user;
+ $user = new \phpbb\user('\phpbb\datetime');
$user->lang = array(
'FOO' => 'BAR',
'BARZ' => 'PENG',
@@ -99,7 +99,7 @@ class phpbb_user_lang_test extends phpbb_test_case
$this->assertEquals($user->lang('ARRY', 1, 's', 2), '1 post');
// ticket PHPBB3-10345 - different plural rules, not just 0/1/2+
- $user = new \phpbb\user;
+ $user = new \phpbb\user('\phpbb\datetime');
$user->lang = array(
'PLURAL_RULE' => 13,
'ARRY' => array(
diff --git a/tests/version/version_fetch_test.php b/tests/version/version_fetch_test.php
index aa0ebaaa26..05eac58a52 100644
--- a/tests/version/version_fetch_test.php
+++ b/tests/version/version_fetch_test.php
@@ -33,7 +33,7 @@ class phpbb_version_helper_fetch_test extends phpbb_test_case
new \phpbb\config\config(array(
'version' => '3.1.0',
)),
- new \phpbb\user()
+ new \phpbb\user('\phpbb\datetime')
);
}
diff --git a/tests/version/version_test.php b/tests/version/version_test.php
index bc4f2c0294..ba31c79a79 100644
--- a/tests/version/version_test.php
+++ b/tests/version/version_test.php
@@ -30,7 +30,7 @@ class phpbb_version_helper_test extends phpbb_test_case
new \phpbb\config\config(array(
'version' => '3.1.0',
)),
- new \phpbb\user()
+ new \phpbb\user('\phpbb\datetime')
);
}
@@ -208,7 +208,7 @@ class phpbb_version_helper_test extends phpbb_test_case
new \phpbb\config\config(array(
'version' => $current_version,
)),
- new \phpbb\user(),
+ new \phpbb\user('\phpbb\datetime'),
))
->getMock()
;
@@ -318,7 +318,7 @@ class phpbb_version_helper_test extends phpbb_test_case
new \phpbb\config\config(array(
'version' => $current_version,
)),
- new \phpbb\user(),
+ new \phpbb\user('\phpbb\datetime'),
))
->getMock()
;