diff options
Diffstat (limited to 'tests')
76 files changed, 690 insertions, 187 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/console/config/config_test.php b/tests/console/config/config_test.php new file mode 100644 index 0000000000..7c098af004 --- /dev/null +++ b/tests/console/config/config_test.php @@ -0,0 +1,251 @@ +<?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 Symfony\Component\Console\Application; +use Symfony\Component\Console\Tester\CommandTester; + +class phpbb_console_command_config_test extends phpbb_test_case +{ + protected $config; + protected $command_name; + protected $user; + + public function setUp() + { + $this->config = new \phpbb\config\config(array()); + + $this->user = $this->getMock('\phpbb\user', array(), array('\phpbb\datetime')); + $this->user->method('lang')->will($this->returnArgument(0)); + } + + public function test_set_dynamic() + { + $this->assertEmpty($this->config); + + $command_tester = $this->get_command_tester('set'); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'test_key', + 'value' => 'test_value', + '--dynamic' => true, + )); + + $this->assertSame($this->config['test_key'], 'test_value'); + } + + public function test_set_no_dynamic() + { + $this->assertEmpty($this->config); + + $command_tester = $this->get_command_tester('set'); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'test_key', + 'value' => 'test_value', + '--dynamic' => false, + )); + + $this->assertSame($this->config['test_key'], 'test_value'); + } + + public function test_set_atomic_dynamic() + { + $this->assertEmpty($this->config); + + $this->config->set('test_key', 'old_value', true); + $this->assertSame($this->config['test_key'], 'old_value'); + + $command_tester = $this->get_command_tester('set_atomic'); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'test_key', + 'old' => 'old_value', + 'new' => 'new_value', + '--dynamic' => true, + )); + + $this->assertSame($this->config['test_key'], 'new_value'); + } + + public function test_set_atomic_no_dynamic() + { + $this->assertEmpty($this->config); + + $this->config->set('test_key', 'old_value', false); + $this->assertSame($this->config['test_key'], 'old_value'); + + $command_tester = $this->get_command_tester('set_atomic'); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'test_key', + 'old' => 'old_value', + 'new' => 'new_value', + '--dynamic' => false, + )); + + $this->assertSame($this->config['test_key'], 'new_value'); + } + + public function test_set_atomic_error_dynamic() + { + $this->assertEmpty($this->config); + + $this->config->set('test_key', 'wrong_value', true); + $this->assertSame($this->config['test_key'], 'wrong_value'); + + $command_tester = $this->get_command_tester('set_atomic'); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'test_key', + 'old' => 'old_value', + 'new' => 'new_value', + '--dynamic' => true, + )); + + $this->assertSame($this->config['test_key'], 'wrong_value'); + } + + public function test_get_no_new_line() + { + $this->config->set('test_key', 'test_value', false); + $this->assertSame($this->config['test_key'], 'test_value'); + + $command_tester = $this->get_command_tester('get'); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'test_key', + '--no-newline' => true, + )); + + $this->assertSame($this->config['test_key'], $command_tester->getDisplay()); + } + + public function test_get_new_line() + { + $this->config->set('test_key', 'test_value', false); + $this->assertSame($this->config['test_key'], 'test_value'); + + $command_tester = $this->get_command_tester('get'); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'test_key', + '--no-newline' => false, + )); + + $this->assertSame($this->config['test_key'] . PHP_EOL, $command_tester->getDisplay()); + } + + public function test_get_error() + { + $this->config->set('test_key', 'test_value', false); + $this->assertSame($this->config['test_key'], 'test_value'); + + $command_tester = $this->get_command_tester('get'); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'wrong_key', + '--no-newline' => false, + )); + + $this->assertContains('CLI_CONFIG_NOT_EXISTS', $command_tester->getDisplay()); + } + + public function test_increment_dynamic() + { + $this->config->set('test_key', 0, false); + $this->assertSame($this->config['test_key'], 0); + + $command_tester = $this->get_command_tester('increment'); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'test_key', + 'increment' => 2, + '--dynamic' => true, + )); + + $this->assertContains('CLI_CONFIG_INCREMENT_SUCCESS', $command_tester->getDisplay()); + $this->assertSame(2, $this->config['test_key']); + } + + public function test_increment_no_dynamic() + { + $this->config->set('test_key', 0, false); + $this->assertSame($this->config['test_key'], 0); + + $command_tester = $this->get_command_tester('increment'); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'test_key', + 'increment' => 2, + '--dynamic' => false, + )); + + $this->assertContains('CLI_CONFIG_INCREMENT_SUCCESS', $command_tester->getDisplay()); + $this->assertSame(2, $this->config['test_key']); + } + + public function test_increment_no_set() + { + $this->assertEmpty($this->config); + + $command_tester = $this->get_command_tester('increment'); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'test_key', + 'increment' => 2, + '--dynamic' => true, + )); + + $this->assertContains('CLI_CONFIG_INCREMENT_SUCCESS', $command_tester->getDisplay()); + $this->assertSame(2, $this->config['test_key']); + } + + public function test_delete_ok() + { + $this->config->set('test_key', 'test_value', false); + $this->assertSame($this->config['test_key'], 'test_value'); + + $command_tester = $this->get_command_tester('delete'); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'test_key', + )); + + $this->assertContains('CLI_CONFIG_DELETE_SUCCESS', $command_tester->getDisplay()); + $this->assertEmpty($this->config); + } + + public function test_delete_error() + { + $this->assertEmpty($this->config); + + $command_tester = $this->get_command_tester('delete'); + $command_tester->execute(array( + 'command' => $this->command_name, + 'key' => 'wrong_key', + )); + + $this->assertContains('CLI_CONFIG_NOT_EXISTS', $command_tester->getDisplay()); + $this->assertEmpty($this->config); + } + + public function get_command_tester($class_name) + { + $command_complete_name = '\phpbb\console\command\config' . '\\' . $class_name; + $application = new Application(); + $application->add(new $command_complete_name($this->user, $this->config)); + $command = $application->find('config:' . $this->command_name); + $this->command_name = $command->getName(); + return new CommandTester($command); + } +} 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 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/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/ext/vendor4/bar/composer.json b/tests/extension/ext/vendor4/bar/composer.json new file mode 100644 index 0000000000..1a2fddc3f4 --- /dev/null +++ b/tests/extension/ext/vendor4/bar/composer.json @@ -0,0 +1,23 @@ +{ + "name": "vendor4/bar", + "type": "phpbb-extension", + "description": "An example/sample extension to be used for testing purposes in phpBB Development.", + "version": "1.0.0", + "time": "2012-02-15 01:01:01", + "license": "GPL-2.0", + "authors": [{ + "name": "John Smith", + "email": "email@phpbb.com", + "homepage": "http://phpbb.com", + "role": "N/A" + }], + "require": { + "php": ">=5.3" + }, + "extra": { + "display-name": "phpBB Bar Extension", + "soft-require": { + "phpbb/phpbb": "3.1.*@dev" + } + } +} diff --git a/tests/extension/ext/vendor4/bar/styles/all/template/foobar_body.html b/tests/extension/ext/vendor4/bar/styles/all/template/foobar_body.html new file mode 100644 index 0000000000..c8f8cf957e --- /dev/null +++ b/tests/extension/ext/vendor4/bar/styles/all/template/foobar_body.html @@ -0,0 +1 @@ +All folder diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php index 1e43c2a0a3..5c7cad89f6 100644 --- a/tests/extension/manager_test.php +++ b/tests/extension/manager_test.php @@ -36,7 +36,7 @@ class phpbb_extension_manager_test extends phpbb_database_test_case public function test_all_available() { // barfoo and vendor3/bar should not listed due to missing composer.json. barfoo also has incorrect dir structure. - $this->assertEquals(array('vendor/moo', 'vendor2/bar', 'vendor2/foo', 'vendor3/foo'), array_keys($this->extension_manager->all_available())); + $this->assertEquals(array('vendor/moo', 'vendor2/bar', 'vendor2/foo', 'vendor3/foo', 'vendor4/bar'), array_keys($this->extension_manager->all_available())); } public function test_all_enabled() @@ -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/extension_acp_test.php b/tests/functional/extension_acp_test.php index 6490c1ead3..7be8957ec7 100644 --- a/tests/functional/extension_acp_test.php +++ b/tests/functional/extension_acp_test.php @@ -84,7 +84,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid); $this->assertCount(1, $crawler->filter('.ext_enabled')); - $this->assertCount(5, $crawler->filter('.ext_disabled')); + $this->assertCount(6, $crawler->filter('.ext_disabled')); $this->assertContains('phpBB Foo Extension', $crawler->filter('.ext_enabled')->eq(0)->text()); $this->assertContainsLang('EXTENSION_DISABLE', $crawler->filter('.ext_enabled')->eq(0)->text()); diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php index 532a160a47..18eb9ad4c6 100644 --- a/tests/functional/extension_controller_test.php +++ b/tests/functional/extension_controller_test.php @@ -26,6 +26,8 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c 'foo/bar/event/', 'foo/bar/language/en/', 'foo/bar/styles/prosilver/template/', + 'foo/foo/config/', + 'foo/foo/controller/', ); static public function setUpBeforeClass() @@ -65,6 +67,18 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c } /** + * Check a controller for extension foo/bar. + */ + public function test_routing_resources() + { + $this->phpbb_extension_manager->enable('foo/foo'); + $crawler = self::request('GET', 'app.php/foo/foo', array(), false); + self::assert_response_status_code(); + $this->assertContains("foo/foo controller handle() method", $crawler->filter('body')->text()); + $this->phpbb_extension_manager->purge('foo/foo'); + } + + /** * Check the output of a controller using the template system */ public function test_controller_with_template() diff --git a/tests/functional/fixtures/ext/foo/foo/composer.json b/tests/functional/fixtures/ext/foo/foo/composer.json new file mode 100644 index 0000000000..d85c76a6a2 --- /dev/null +++ b/tests/functional/fixtures/ext/foo/foo/composer.json @@ -0,0 +1,24 @@ +{ + "name": "foo/foo", + "type": "phpbb-extension", + "description": "Testing extensions", + "homepage": "", + "version": "1.0.0", + "time": "2013-03-21 01:01:01", + "license": "GPL-2.0", + "authors": [{ + "name": "Tristan Darricau", + "email": "nicofuma@phpbb.com", + "homepage": "http://www.phpbb.com", + "role": "Developer" + }], + "require": { + "php": ">=5.3" + }, + "extra": { + "display-name": "phpBB 3.1 Extension Testing", + "soft-require": { + "phpbb/phpbb": "3.1.*@dev" + } + } +} diff --git a/tests/functional/fixtures/ext/foo/foo/config/resource.yml b/tests/functional/fixtures/ext/foo/foo/config/resource.yml new file mode 100644 index 0000000000..ed1d018016 --- /dev/null +++ b/tests/functional/fixtures/ext/foo/foo/config/resource.yml @@ -0,0 +1,3 @@ +foo_foo_controller: + pattern: /foo + defaults: { _controller: foo_foo.controller:handle } diff --git a/tests/functional/fixtures/ext/foo/foo/config/routing.yml b/tests/functional/fixtures/ext/foo/foo/config/routing.yml new file mode 100644 index 0000000000..c2c401687d --- /dev/null +++ b/tests/functional/fixtures/ext/foo/foo/config/routing.yml @@ -0,0 +1,3 @@ +foo_foo.general: + resource: "resource.yml" + prefix: /foo diff --git a/tests/functional/fixtures/ext/foo/foo/config/services.yml b/tests/functional/fixtures/ext/foo/foo/config/services.yml new file mode 100644 index 0000000000..b3c7719715 --- /dev/null +++ b/tests/functional/fixtures/ext/foo/foo/config/services.yml @@ -0,0 +1,3 @@ +services: + foo_foo.controller: + class: foo\foo\controller\controller diff --git a/tests/functional/fixtures/ext/foo/foo/controller/controller.php b/tests/functional/fixtures/ext/foo/foo/controller/controller.php new file mode 100644 index 0000000000..771eaeacfc --- /dev/null +++ b/tests/functional/fixtures/ext/foo/foo/controller/controller.php @@ -0,0 +1,13 @@ +<?php + +namespace foo\foo\controller; + +use Symfony\Component\HttpFoundation\Response; + +class controller +{ + public function handle() + { + return new Response('foo/foo controller handle() method', 200); + } +} diff --git a/tests/functional/fixtures/ext/foo/foo/ext.php b/tests/functional/fixtures/ext/foo/foo/ext.php new file mode 100644 index 0000000000..80acda74fe --- /dev/null +++ b/tests/functional/fixtures/ext/foo/foo/ext.php @@ -0,0 +1,8 @@ +<?php + +namespace foo\foo; + +class ext extends \phpbb\extension\base +{ + +} diff --git a/tests/functional/notification_test.php b/tests/functional/notification_test.php index e4a960f862..667d268b1e 100644 --- a/tests/functional/notification_test.php +++ b/tests/functional/notification_test.php @@ -21,20 +21,20 @@ class phpbb_functional_notification_test extends phpbb_functional_test_case return array( // Rows inserted by phpBB/install/schemas/schema_data.sql // Also see PHPBB3-11460 - array('post_notification', true), - array('topic_notification', true), - array('post_email', true), - array('topic_email', true), + array('notification.type.post_notification', true), + array('notification.type.topic_notification', true), + array('notification.type.post_notification.method.email', true), + array('notification.type.topic_notification.method.email', true), // Default behaviour for in-board notifications: // If user did not opt-out, in-board notifications are on. - array('bookmark_notification', true), - array('quote_notification', true), + array('notification.type.bookmark_notification', true), + array('notification.type.quote_notification', true), // Default behaviour for email notifications: // If user did not opt-in, email notifications are off. - array('bookmark_email', false), - array('quote_email', false), + array('notification.type.bookmark_notification.method.email', false), + array('notification.type.quote_notification.method.email', false), ); } 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/lock/flock_test.php b/tests/lock/flock_test.php index 0ff38b6cc8..554b7e57f4 100644 --- a/tests/lock/flock_test.php +++ b/tests/lock/flock_test.php @@ -83,9 +83,9 @@ class phpbb_lock_flock_test extends phpbb_test_case sleep(1); $lock = new \phpbb\lock\flock($path); - $start = time(); + $start = microtime(true); $ok = $lock->acquire(); - $delta = time() - $start; + $delta = microtime(true) - $start; $this->assertTrue($ok); $this->assertTrue($lock->owns_lock()); $this->assertGreaterThan(0.5, $delta, 'First lock acquired too soon'); @@ -94,9 +94,9 @@ class phpbb_lock_flock_test extends phpbb_test_case $this->assertFalse($lock->owns_lock()); // acquire again, this should be instantaneous - $start = time(); + $start = microtime(true); $ok = $lock->acquire(); - $delta = time() - $start; + $delta = microtime(true) - $start; $this->assertTrue($ok); $this->assertTrue($lock->owns_lock()); $this->assertLessThan(0.1, $delta, 'Second lock not acquired instantaneously'); 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..c97b7c24e2 100644 --- a/tests/notification/base.php +++ b/tests/notification/base.php @@ -21,21 +21,21 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case { return array( 'test', - 'approve_post', - 'approve_topic', - 'bookmark', - 'disapprove_post', - 'disapprove_topic', - 'pm', - 'post', - 'post_in_queue', - 'quote', - 'report_pm', - 'report_pm_closed', - 'report_post', - 'report_post_closed', - 'topic', - 'topic_in_queue', + 'notification.type.approve_post', + 'notification.type.approve_topic', + 'notification.type.bookmark', + 'notification.type.disapprove_post', + 'notification.type.disapprove_topic', + 'notification.type.pm', + 'notification.type.post', + 'notification.type.post_in_queue', + 'notification.type.quote', + 'notification.type.report_pm', + 'notification.type.report_pm_closed', + 'notification.type.report_post', + 'notification.type.report_post_closed', + 'notification.type.topic', + 'notification.type.topic_in_queue', ); } @@ -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( @@ -92,10 +92,11 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case $types = array(); foreach ($this->get_notification_types() as $type) { - $class = $this->build_type('phpbb\notification\type\\' . $type); + $type_parts = explode('.', $type); + $class = $this->build_type('phpbb\notification\type\\' . array_pop($type_parts)); $types[$type] = $class; - $this->container->set('notification.type.' . $type, $class); + $this->container->set($type, $class); } $this->notifications->set_var('notification_types', $types); diff --git a/tests/notification/fixtures/submit_post_bookmark.xml b/tests/notification/fixtures/submit_post_notification.type.bookmark.xml index 525d0484e0..a1413e2cf8 100644 --- a/tests/notification/fixtures/submit_post_bookmark.xml +++ b/tests/notification/fixtures/submit_post_notification.type.bookmark.xml @@ -50,7 +50,7 @@ <column>notification_type_enabled</column> <row> <value>1</value> - <value>bookmark</value> + <value>notification.type.bookmark</value> <value>1</value> </row> </table> @@ -123,35 +123,35 @@ <column>method</column> <column>notify</column> <row> - <value>bookmark</value> + <value>notification.type.bookmark</value> <value>0</value> <value>2</value> <value></value> <value>1</value> </row> <row> - <value>bookmark</value> + <value>notification.type.bookmark</value> <value>0</value> <value>3</value> <value></value> <value>1</value> </row> <row> - <value>bookmark</value> + <value>notification.type.bookmark</value> <value>0</value> <value>4</value> <value></value> <value>1</value> </row> <row> - <value>bookmark</value> + <value>notification.type.bookmark</value> <value>0</value> <value>5</value> <value></value> <value>1</value> </row> <row> - <value>bookmark</value> + <value>notification.type.bookmark</value> <value>0</value> <value>6</value> <value></value> diff --git a/tests/notification/fixtures/submit_post_post.xml b/tests/notification/fixtures/submit_post_notification.type.post.xml index a38ca77ea0..ed75787c70 100644 --- a/tests/notification/fixtures/submit_post_post.xml +++ b/tests/notification/fixtures/submit_post_notification.type.post.xml @@ -50,7 +50,7 @@ <column>notification_type_enabled</column> <row> <value>1</value> - <value>post</value> + <value>notification.type.post</value> <value>1</value> </row> </table> @@ -153,49 +153,49 @@ <column>method</column> <column>notify</column> <row> - <value>post</value> + <value>notification.type.post</value> <value>0</value> <value>2</value> <value></value> <value>1</value> </row> <row> - <value>post</value> + <value>notification.type.post</value> <value>0</value> <value>3</value> <value></value> <value>1</value> </row> <row> - <value>post</value> + <value>notification.type.post</value> <value>0</value> <value>4</value> <value></value> <value>1</value> </row> <row> - <value>post</value> + <value>notification.type.post</value> <value>0</value> <value>5</value> <value></value> <value>1</value> </row> <row> - <value>post</value> + <value>notification.type.post</value> <value>0</value> <value>6</value> <value></value> <value>1</value> </row> <row> - <value>post</value> + <value>notification.type.post</value> <value>0</value> <value>7</value> <value></value> <value>1</value> </row> <row> - <value>post</value> + <value>notification.type.post</value> <value>0</value> <value>8</value> <value></value> diff --git a/tests/notification/fixtures/submit_post_post_in_queue.xml b/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml index 28cb69be36..2dea8e34dd 100644 --- a/tests/notification/fixtures/submit_post_post_in_queue.xml +++ b/tests/notification/fixtures/submit_post_notification.type.post_in_queue.xml @@ -22,7 +22,7 @@ <column>notification_type_enabled</column> <row> <value>1</value> - <value>post_in_queue</value> + <value>notification.type.post_in_queue</value> <value>1</value> </row> </table> @@ -107,49 +107,49 @@ <column>method</column> <column>notify</column> <row> - <value>needs_approval</value> + <value>notification.type.needs_approval</value> <value>0</value> <value>2</value> <value></value> <value>1</value> </row> <row> - <value>needs_approval</value> + <value>notification.type.needs_approval</value> <value>0</value> <value>3</value> <value></value> <value>1</value> </row> <row> - <value>needs_approval</value> + <value>notification.type.needs_approval</value> <value>0</value> <value>4</value> <value></value> <value>1</value> </row> <row> - <value>needs_approval</value> + <value>notification.type.needs_approval</value> <value>0</value> <value>5</value> <value></value> <value>1</value> </row> <row> - <value>needs_approval</value> + <value>notification.type.needs_approval</value> <value>0</value> <value>6</value> <value></value> <value>1</value> </row> <row> - <value>needs_approval</value> + <value>notification.type.needs_approval</value> <value>0</value> <value>7</value> <value></value> <value>0</value> </row> <row> - <value>needs_approval</value> + <value>notification.type.needs_approval</value> <value>0</value> <value>9</value> <value></value> diff --git a/tests/notification/fixtures/submit_post_quote.xml b/tests/notification/fixtures/submit_post_notification.type.quote.xml index 2b11992e54..dd5bc620cd 100644 --- a/tests/notification/fixtures/submit_post_quote.xml +++ b/tests/notification/fixtures/submit_post_notification.type.quote.xml @@ -22,7 +22,7 @@ <column>notification_type_enabled</column> <row> <value>1</value> - <value>quote</value> + <value>notification.type.quote</value> <value>1</value> </row> </table> @@ -95,35 +95,35 @@ <column>method</column> <column>notify</column> <row> - <value>quote</value> + <value>notification.type.quote</value> <value>0</value> <value>2</value> <value></value> <value>1</value> </row> <row> - <value>quote</value> + <value>notification.type.quote</value> <value>0</value> <value>3</value> <value></value> <value>1</value> </row> <row> - <value>quote</value> + <value>notification.type.quote</value> <value>0</value> <value>4</value> <value></value> <value>1</value> </row> <row> - <value>quote</value> + <value>notification.type.quote</value> <value>0</value> <value>5</value> <value></value> <value>1</value> </row> <row> - <value>quote</value> + <value>notification.type.quote</value> <value>0</value> <value>6</value> <value></value> diff --git a/tests/notification/fixtures/submit_post_topic.xml b/tests/notification/fixtures/submit_post_notification.type.topic.xml index 5e179d9b99..1ba8d05699 100644 --- a/tests/notification/fixtures/submit_post_topic.xml +++ b/tests/notification/fixtures/submit_post_notification.type.topic.xml @@ -42,7 +42,7 @@ <column>notification_type_enabled</column> <row> <value>1</value> - <value>topic</value> + <value>notification.type.topic</value> <value>1</value> </row> </table> @@ -103,28 +103,28 @@ <column>method</column> <column>notify</column> <row> - <value>topic</value> + <value>notification.type.topic</value> <value>0</value> <value>2</value> <value></value> <value>1</value> </row> <row> - <value>topic</value> + <value>notification.type.topic</value> <value>0</value> <value>6</value> <value></value> <value>1</value> </row> <row> - <value>topic</value> + <value>notification.type.topic</value> <value>0</value> <value>7</value> <value></value> <value>1</value> </row> <row> - <value>topic</value> + <value>notification.type.topic</value> <value>0</value> <value>8</value> <value></value> diff --git a/tests/notification/group_request_test.php b/tests/notification/group_request_test.php index 14ed4ff62c..afbc586601 100644 --- a/tests/notification/group_request_test.php +++ b/tests/notification/group_request_test.php @@ -25,8 +25,8 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas return array_merge( parent::get_notification_types(), array( - 'group_request', - 'group_request_approved', + 'notification.type.group_request', + 'notification.type.group_request_approved', ) ); } diff --git a/tests/notification/manager_helper.php b/tests/notification/manager_helper.php index 24030f5775..75b7275d3a 100644 --- a/tests/notification/manager_helper.php +++ b/tests/notification/manager_helper.php @@ -43,7 +43,8 @@ class phpbb_notification_manager_helper extends \phpbb\notification\manager */ public function get_item_type_class($item_type, $data = array()) { - $item_type = 'phpbb\notification\type\\' . $item_type; + $item_parts = explode('.', $item_type); + $item_type = 'phpbb\notification\type\\' . array_pop($item_parts); $item = new $item_type($this->user_loader, $this->db, $this->cache->get_driver(), $this->user, $this->auth, $this->config, $this->phpbb_root_path, $this->php_ext, $this->notification_types_table, $this->notifications_table, $this->user_notifications_table); diff --git a/tests/notification/notification_test.php b/tests/notification/notification_test.php index 27ea8ddb44..79fa5338c4 100644 --- a/tests/notification/notification_test.php +++ b/tests/notification/notification_test.php @@ -25,22 +25,22 @@ class phpbb_notification_test extends phpbb_tests_notification_base public function test_get_notification_type_id() { // They should be inserted the first time - $post_type_id = $this->notifications->get_notification_type_id('post'); - $quote_type_id = $this->notifications->get_notification_type_id('quote'); + $post_type_id = $this->notifications->get_notification_type_id('notification.type.post'); + $quote_type_id = $this->notifications->get_notification_type_id('notification.type.quote'); $test_type_id = $this->notifications->get_notification_type_id('test'); $this->assertEquals(array( 'test' => $test_type_id, - 'quote' => $quote_type_id, - 'post' => $post_type_id, + 'notification.type.quote' => $quote_type_id, + 'notification.type.post' => $post_type_id, ), $this->notifications->get_notification_type_ids(array( 'test', - 'quote', - 'post', + 'notification.type.quote', + 'notification.type.post', ) )); - $this->assertEquals($quote_type_id, $this->notifications->get_notification_type_id('quote')); + $this->assertEquals($quote_type_id, $this->notifications->get_notification_type_id('notification.type.quote')); try { @@ -58,12 +58,12 @@ class phpbb_notification_test extends phpbb_tests_notification_base $this->assertArrayHasKey('NOTIFICATION_GROUP_MISCELLANEOUS', $subscription_types); $this->assertArrayHasKey('NOTIFICATION_GROUP_POSTING', $subscription_types); - $this->assertArrayHasKey('bookmark', $subscription_types['NOTIFICATION_GROUP_POSTING']); - $this->assertArrayHasKey('post', $subscription_types['NOTIFICATION_GROUP_POSTING']); - $this->assertArrayHasKey('quote', $subscription_types['NOTIFICATION_GROUP_POSTING']); - $this->assertArrayHasKey('topic', $subscription_types['NOTIFICATION_GROUP_POSTING']); + $this->assertArrayHasKey('notification.type.bookmark', $subscription_types['NOTIFICATION_GROUP_POSTING']); + $this->assertArrayHasKey('notification.type.post', $subscription_types['NOTIFICATION_GROUP_POSTING']); + $this->assertArrayHasKey('notification.type.quote', $subscription_types['NOTIFICATION_GROUP_POSTING']); + $this->assertArrayHasKey('notification.type.topic', $subscription_types['NOTIFICATION_GROUP_POSTING']); - $this->assertArrayHasKey('pm', $subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS']); + $this->assertArrayHasKey('notification.type.pm', $subscription_types['NOTIFICATION_GROUP_MISCELLANEOUS']); //get_subscription_types //get_subscription_methods @@ -72,12 +72,12 @@ class phpbb_notification_test extends phpbb_tests_notification_base public function test_subscriptions() { $expected_subscriptions = array( - 'post' => array(''), - 'topic' => array(''), - 'quote' => array(''), - 'bookmark' => array(''), + 'notification.type.post' => array(''), + 'notification.type.topic' => array(''), + 'notification.type.quote' => array(''), + 'notification.type.bookmark' => array(''), 'test' => array(''), - 'pm' => array(''), + 'notification.type.pm' => array(''), ); $subscriptions = $this->notifications->get_global_subscriptions(2); @@ -92,20 +92,20 @@ class phpbb_notification_test extends phpbb_tests_notification_base $this->assert_array_content_equals($methods, $expected_subscriptions[$item_type]); } - $this->notifications->delete_subscription('post', 0, '', 2); + $this->notifications->delete_subscription('notification.type.post', 0, '', 2); - $this->assertArrayNotHasKey('post', $this->notifications->get_global_subscriptions(2)); + $this->assertArrayNotHasKey('notification.type.post', $this->notifications->get_global_subscriptions(2)); - $this->notifications->add_subscription('post', 0, '', 2); + $this->notifications->add_subscription('notification.type.post', 0, '', 2); - $this->assertArrayHasKey('post', $this->notifications->get_global_subscriptions(2)); + $this->assertArrayHasKey('notification.type.post', $this->notifications->get_global_subscriptions(2)); } public function test_notifications() { $this->db->sql_query('DELETE FROM phpbb_notification_types'); - $types = array('quote', 'bookmark', 'post', 'test'); + $types = array('notification.type.quote', 'notification.type.bookmark', 'notification.type.post', 'test'); foreach ($types as $id => $type) { $this->db->sql_query('INSERT INTO phpbb_notification_types ' . @@ -150,7 +150,7 @@ class phpbb_notification_test extends phpbb_tests_notification_base 'post_time' => 1349413323, )); - $this->notifications->add_notifications(array('quote', 'bookmark', 'post', 'test'), array( + $this->notifications->add_notifications(array('notification.type.quote', 'notification.type.bookmark', 'notification.type.post', 'test'), array( 'post_id' => '4', 'topic_id' => '2', 'post_time' => 1349413324, @@ -166,7 +166,7 @@ class phpbb_notification_test extends phpbb_tests_notification_base 'user_id' => 0, ))); - $this->notifications->add_notifications(array('quote', 'bookmark', 'post', 'test'), array( + $this->notifications->add_notifications(array('notification.type.quote', 'notification.type.bookmark', 'notification.type.post', 'test'), array( 'post_id' => '5', 'topic_id' => '2', 'post_time' => 1349413325, @@ -258,7 +258,7 @@ class phpbb_notification_test extends phpbb_tests_notification_base 'post_time' => 1234, // change time )); - $this->notifications->update_notifications(array('quote', 'bookmark', 'post', 'test'), array( + $this->notifications->update_notifications(array('notification.type.quote', 'notification.type.bookmark', 'notification.type.post', 'test'), array( 'post_id' => '5', 'topic_id' => '2', 'poster_id' => 2, 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/submit_post_type_bookmark_test.php b/tests/notification/submit_post_type_bookmark_test.php index 6d7747c2ba..7c3b9f938f 100644 --- a/tests/notification/submit_post_type_bookmark_test.php +++ b/tests/notification/submit_post_type_bookmark_test.php @@ -15,7 +15,7 @@ require_once dirname(__FILE__) . '/submit_post_base.php'; class phpbb_notification_submit_post_type_bookmark_test extends phpbb_notification_submit_post_base { - protected $item_type = 'bookmark'; + protected $item_type = 'notification.type.bookmark'; public function setUp() { diff --git a/tests/notification/submit_post_type_post_in_queue_test.php b/tests/notification/submit_post_type_post_in_queue_test.php index 6bd9c8c93f..1390e92d96 100644 --- a/tests/notification/submit_post_type_post_in_queue_test.php +++ b/tests/notification/submit_post_type_post_in_queue_test.php @@ -15,7 +15,7 @@ require_once dirname(__FILE__) . '/submit_post_base.php'; class phpbb_notification_submit_post_type_post_in_queue_test extends phpbb_notification_submit_post_base { - protected $item_type = 'post_in_queue'; + protected $item_type = 'notification.type.post_in_queue'; public function setUp() { diff --git a/tests/notification/submit_post_type_post_test.php b/tests/notification/submit_post_type_post_test.php index 5007424690..037c326bc0 100644 --- a/tests/notification/submit_post_type_post_test.php +++ b/tests/notification/submit_post_type_post_test.php @@ -15,7 +15,7 @@ require_once dirname(__FILE__) . '/submit_post_base.php'; class phpbb_notification_submit_post_type_post_test extends phpbb_notification_submit_post_base { - protected $item_type = 'post'; + protected $item_type = 'notification.type.post'; public function setUp() { diff --git a/tests/notification/submit_post_type_quote_test.php b/tests/notification/submit_post_type_quote_test.php index 94979fd154..61e3840773 100644 --- a/tests/notification/submit_post_type_quote_test.php +++ b/tests/notification/submit_post_type_quote_test.php @@ -15,7 +15,7 @@ require_once dirname(__FILE__) . '/submit_post_base.php'; class phpbb_notification_submit_post_type_quote_test extends phpbb_notification_submit_post_base { - protected $item_type = 'quote'; + protected $item_type = 'notification.type.quote'; public function setUp() { diff --git a/tests/notification/submit_post_type_topic_test.php b/tests/notification/submit_post_type_topic_test.php index 52e9353c7c..c095fbc4ba 100644 --- a/tests/notification/submit_post_type_topic_test.php +++ b/tests/notification/submit_post_type_topic_test.php @@ -15,7 +15,7 @@ require_once dirname(__FILE__) . '/submit_post_base.php'; class phpbb_notification_submit_post_type_topic_test extends phpbb_notification_submit_post_base { - protected $item_type = 'topic'; + protected $item_type = 'notification.type.topic'; public function setUp() { 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/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_allfolder_test.php b/tests/template/template_allfolder_test.php new file mode 100644 index 0000000000..b4ad84e9c3 --- /dev/null +++ b/tests/template/template_allfolder_test.php @@ -0,0 +1,59 @@ +<?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. +* +*/ + +require_once dirname(__FILE__) . '/template_test_case.php'; + +class phpbb_template_allfolder_test extends phpbb_template_template_test_case +{ + public function test_allfolder() + { + $this->setup_engine_for_allfolder(); + + $this->run_template('foobar_body.html', array(), array(), array(), "All folder"); + } + + protected function setup_engine_for_allfolder(array $new_config = array()) + { + global $phpbb_root_path, $phpEx; + + $defaults = $this->config_defaults(); + $config = new \phpbb\config\config(array_merge($defaults, $new_config)); + $this->user = new \phpbb\user('\phpbb\datetime'); + + $path_helper = new \phpbb\path_helper( + new \phpbb\symfony_request( + new phpbb_mock_request() + ), + new \phpbb\filesystem(), + $this->getMock('\phpbb\request\request'), + $phpbb_root_path, + $phpEx + ); + + $this->extension_manager = new phpbb_mock_extension_manager( + dirname(__FILE__) . '/', + array( + 'vendor4/bar' => array( + 'ext_name' => 'vendor4/bar', + 'ext_active' => '1', + 'ext_path' => 'ext/vendor4/bar/', + ), + ) + ); + + $this->template_path = $this->test_path . '/templates'; + $this->ext_template_path = 'tests/extension/ext/vendor4/bar/styles/all/template'; + $this->template = new \phpbb\template\twig\twig($path_helper, $config, $this->user, new \phpbb\template\context(), $this->extension_manager); + $this->template->set_custom_style('all', array($this->template_path, $this->ext_template_path)); + } +} 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 c131754d23..49cc72363e 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() ; |