diff options
author | Joas Schilling <nickvergessen@gmx.de> | 2014-08-10 15:24:43 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@gmx.de> | 2014-08-10 15:24:43 +0200 |
commit | d998efcf54f3a7ec202a98555c70094aede7ec42 (patch) | |
tree | a69aa6fd09f7d8a8f386bb7f3520c6a3dbde213b | |
parent | 58a863dbadbb316076647cfa235c69951d66df77 (diff) | |
parent | 54b0ebc4106b985053e0c1827283e77fcfb596af (diff) | |
download | forums-d998efcf54f3a7ec202a98555c70094aede7ec42.tar forums-d998efcf54f3a7ec202a98555c70094aede7ec42.tar.gz forums-d998efcf54f3a7ec202a98555c70094aede7ec42.tar.bz2 forums-d998efcf54f3a7ec202a98555c70094aede7ec42.tar.xz forums-d998efcf54f3a7ec202a98555c70094aede7ec42.zip |
Merge branch 'develop-ascraeus' into develop
* develop-ascraeus:
[ticket/12932] Remove set_datetime_class method from user class
[ticket/12932] Fix tests and calls to create_datetime
[ticket/12932] Add method for getting the datetime class and allow overriding
Conflicts:
phpBB/config/services.yml
48 files changed, 80 insertions, 68 deletions
diff --git a/phpBB/config/parameters.yml b/phpBB/config/parameters.yml new file mode 100644 index 0000000000..5bf2c678ee --- /dev/null +++ b/phpBB/config/parameters.yml @@ -0,0 +1,2 @@ +parameters: + datetime.class: \phpbb\datetime diff --git a/phpBB/config/services.yml b/phpBB/config/services.yml index 8caf1af683..bbe0d2ca87 100644 --- a/phpBB/config/services.yml +++ b/phpBB/config/services.yml @@ -11,6 +11,7 @@ imports: - { resource: passwords.yml } - { resource: profilefields.yml } - { resource: twig.yml } + - { resource: parameters.yml } services: acl.permissions: @@ -350,6 +351,8 @@ services: user: class: phpbb\user + arguments: + - %datetime.class% user_loader: class: phpbb\user_loader diff --git a/phpBB/includes/functions.php b/phpBB/includes/functions.php index 53ccf2df2c..6a2edb0d58 100644 --- a/phpBB/includes/functions.php +++ b/phpBB/includes/functions.php @@ -1061,7 +1061,7 @@ function phpbb_timezone_select($user, $default = '', $truncate = false) foreach ($unsorted_timezones as $timezone) { $tz = new DateTimeZone($timezone); - $dt = new \phpbb\datetime($user, 'now', $tz); + $dt = $user->create_datetime('now', $tz); $offset = $dt->getOffset(); $current_time = $dt->format($user->lang['DATETIME_FORMAT'], true); $offset_string = phpbb_format_timezone_offset($offset); @@ -4881,7 +4881,7 @@ function page_header($page_title = '', $display_online_list = false, $item_id = } } - $dt = new \phpbb\datetime($user, 'now', $user->timezone); + $dt = $user->create_datetime(); $timezone_offset = 'GMT' . phpbb_format_timezone_offset($dt->getOffset()); $timezone_name = $user->timezone->getName(); if (isset($user->lang['timezones'][$timezone_name])) diff --git a/phpBB/install/index.php b/phpBB/install/index.php index 3d5e546ffb..ccfa64796c 100644 --- a/phpBB/install/index.php +++ b/phpBB/install/index.php @@ -241,7 +241,7 @@ $sub = $request->variable('sub', ''); // Set PHP error handler to ours set_error_handler(defined('PHPBB_MSG_HANDLER') ? PHPBB_MSG_HANDLER : 'msg_handler'); -$user = new \phpbb\user(); +$user = new \phpbb\user('\phpbb\datetime'); $auth = new \phpbb\auth\auth(); // Add own hook handler, if present. :o diff --git a/phpBB/phpbb/db/migration/data/v310/soft_delete_mod_convert.php b/phpBB/phpbb/db/migration/data/v310/soft_delete_mod_convert.php index 6335c75398..58845b88ec 100644 --- a/phpBB/phpbb/db/migration/data/v310/soft_delete_mod_convert.php +++ b/phpBB/phpbb/db/migration/data/v310/soft_delete_mod_convert.php @@ -121,7 +121,7 @@ class soft_delete_mod_convert extends \phpbb\db\migration\migration new \phpbb\auth\auth(), $this->config, $this->db, - new \phpbb\user(), + new \phpbb\user('\phpbb\datetime'), $this->phpbb_root_path, $this->php_ext, $this->table_prefix . 'forums', diff --git a/phpBB/phpbb/user.php b/phpBB/phpbb/user.php index 4e90044395..ea98034434 100644 --- a/phpBB/phpbb/user.php +++ b/phpBB/phpbb/user.php @@ -31,6 +31,11 @@ class user extends \phpbb\session */ public $timezone; + /** + * @var string Class name of datetime object + */ + protected $datetime; + var $lang_name = false; var $lang_id = false; var $lang_path; @@ -42,12 +47,14 @@ class user extends \phpbb\session /** * Constructor to set the lang path + * @param string $datetime_class Class name of datetime class */ - function __construct() + function __construct($datetime_class) { global $phpbb_root_path; $this->lang_path = $phpbb_root_path . 'language/'; + $this->datetime = $datetime_class; } /** @@ -727,7 +734,7 @@ class user extends \phpbb\session public function create_datetime($time = 'now', \DateTimeZone $timezone = null) { $timezone = $timezone ?: $this->timezone; - return new \phpbb\datetime($this, $time, $timezone); + return new $this->datetime($this, $time, $timezone); } /** 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..744f955531 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), 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/manager_test.php b/tests/avatar/manager_test.php index d8099b40d4..8463cdb6c2 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -266,7 +266,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'), 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 7f31dd9b28..65dda3ce48 100644 --- a/tests/content_visibility/delete_post_test.php +++ b/tests/content_visibility/delete_post_test.php @@ -306,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(); 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 8113bd0018..cff31d6358 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/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/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 fdb9deda53..ead0076d90 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_'; $container = new phpbb_mock_container_builder(); 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/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 3e0af36a73..f3db6ef01f 100644 --- a/tests/profilefields/type_googleplus_test.php +++ b/tests/profilefields/type_googleplus_test.php @@ -21,7 +21,7 @@ class phpbb_profilefield_type_googleplus_test extends phpbb_test_case { parent::setUp(); - $user = new \phpbb\user(); + $user = new \phpbb\user('\phpbb\datetime'); $user->add_lang('ucp'); $request = $this->getMock('\phpbb\request\request'); $template = $this->getMock('\phpbb\template\template'); 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/template/template_test_case.php b/tests/template/template_test_case.php index 1f46d6ff71..f9ea8cfaba 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 38d93f9b2f..8927c4dbf9 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -239,7 +239,7 @@ class phpbb_functional_test_case extends phpbb_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, @@ -598,7 +598,7 @@ class phpbb_functional_test_case extends phpbb_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); @@ -637,7 +637,7 @@ class phpbb_functional_test_case extends phpbb_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/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() ; |