1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-13 20:24:08 +02:00

Merge pull request #6838 from rxu/ticket/17535

[ticket/17535] Upgrade PHPUnit to version 10
This commit is contained in:
Marc Alexander
2025-07-30 13:48:49 +02:00
committed by GitHub
248 changed files with 1637 additions and 1555 deletions

View File

@@ -53,7 +53,7 @@ class phpbb_attachment_delete_test extends \phpbb_database_test_case
$this->attachment_delete = new \phpbb\attachment\delete($this->config, $this->db, $this->dispatcher, $this->resync, $this->storage);
}
public function data_attachment_delete()
public static function data_attachment_delete()
{
return array(
array('attach', '', false, false),
@@ -83,7 +83,7 @@ class phpbb_attachment_delete_test extends \phpbb_database_test_case
$this->assertSame($expected, $this->attachment_delete->delete($mode, $ids, $resync));
}
public function data_attachment_unlink()
public static function data_attachment_unlink()
{
return array(
array(true, true),

View File

@@ -21,15 +21,15 @@ class phpbb_attachment_manager_test extends \phpbb_test_case
{
$this->delete = $this->getMockBuilder('\phpbb\attachment\delete')
->disableOriginalConstructor()
->setMethods(['delete', 'unlink_attachment'])
->onlyMethods(['delete', 'unlink_attachment'])
->getMock();
$this->resync = $this->getMockBuilder('\phpbb\attachment\resync')
->disableOriginalConstructor()
->setMethods(['resync'])
->onlyMethods(['resync'])
->getMock();
$this->upload = $this->getMockBuilder('\phpbb\attachment\upload')
->disableOriginalConstructor()
->setMethods(['upload'])
->onlyMethods(['upload'])
->getMock();
}
@@ -38,7 +38,7 @@ class phpbb_attachment_manager_test extends \phpbb_test_case
return new \phpbb\attachment\manager($this->delete, $this->resync, $this->upload);
}
public function data_manager()
public static function data_manager()
{
return array(
array(

View File

@@ -32,7 +32,7 @@ class phpbb_attachment_resync_test extends \phpbb_database_test_case
$this->resync = new \phpbb\attachment\resync($this->db);
}
public function data_resync()
public static function data_resync()
{
return array(
array('', array(1), 'post_id', POSTS_TABLE, array('post_attachment' => '1'), array('post_attachment' => '1')),

View File

@@ -165,7 +165,7 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
);
}
public function data_upload()
public static function data_upload()
{
return array(
array('foobar', 1, false,
@@ -280,7 +280,7 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
), $filedata);
}
public function data_image_upload()
public static function data_image_upload()
{
return array(
array(false, false, array(),
@@ -365,7 +365,7 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
public function test_image_upload($is_image, $plupload_active, $config_data, $expected)
{
$filespec = $this->getMockBuilder('\phpbb\files\filespec_storage')
->setMethods(array(
->onlyMethods(array(
'init_error',
'is_image',
'move_file',

View File

@@ -74,8 +74,10 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case
->will($this->returnValue(true));
$this->request->expects($this->exactly(2))
->method('server')
->withConsecutive(['PHP_AUTH_USER'], ['PHP_AUTH_PW'])
->will($this->onConsecutiveCalls($this->returnValue('foobar'), $this->returnValue('example')));
->willReturnMap([
['PHP_AUTH_USER', 'foobar'],
['PHP_AUTH_PW', 'example']
]);
$expected = array(
'status' => LOGIN_SUCCESS,
@@ -102,8 +104,10 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case
->will($this->returnValue(true));
$this->request->expects($this->exactly(2))
->method('server')
->withConsecutive(['PHP_AUTH_USER'], ['PHP_AUTH_PW'])
->will($this->onConsecutiveCalls($this->returnValue('foobar'), $this->returnValue('example')));
->willReturnCallback(fn(string $arg) => match(true) {
$arg === 'PHP_AUTH_USER' => 'foobar',
$arg === 'PHP_AUTH_PW' => 'example',
});
$expected = array(
'user_id' => 1,

View File

@@ -89,7 +89,7 @@ class phpbb_avatar_driver_gravatar_test extends \phpbb_database_test_case
$this->template_data = array_merge($this->template_data, $data);
}
public function data_prepare_form(): array
public static function data_prepare_form(): array
{
return [
[

View File

@@ -12,6 +12,7 @@
*/
require_once __DIR__ . '/driver/foobar.php';
require_once __DIR__ . '/driver/barfoo.php';
class phpbb_avatar_manager_test extends \phpbb_database_test_case
{
@@ -62,15 +63,15 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
// $this->avatar_foobar will be needed later on
$this->avatar_foobar = $this->getMockBuilder('\phpbb\avatar\driver\foobar')
->setMethods(array('get_name'))
->onlyMethods(array('get_name'))
->setConstructorArgs(array($this->config, $imagesize, $phpbb_root_path, $phpEx, $path_helper, $cache))
->getMock();
$this->avatar_foobar->expects($this->any())
->method('get_name')
->will($this->returnValue('avatar.driver.foobar'));
// barfoo driver can't be mocked with constructor arguments
$this->avatar_barfoo = $this->getMockBuilder('\phpbb\avatar\driver\barfoo')
->setMethods(array('get_name', 'get_config_name'))
->onlyMethods(array('get_name', 'get_config_name'))
->setConstructorArgs(array($this->config, $imagesize, $phpbb_root_path, $phpEx, $path_helper, $cache))
->getMock();
$this->avatar_barfoo->expects($this->any())
->method('get_name')
@@ -89,14 +90,14 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
if ($driver !== 'upload')
{
$cur_avatar = $this->getMockBuilder('\phpbb\avatar\driver\\' . $driver)
->setMethods(array('get_name'))
->onlyMethods(array('get_name'))
->setConstructorArgs(array($this->config, $imagesize, $phpbb_root_path, $phpEx, $path_helper, $cache))
->getMock();
}
else
{
$cur_avatar = $this->getMockBuilder('\phpbb\avatar\driver\\' . $driver)
->setMethods(array('get_name'))
->onlyMethods(array('get_name'))
->setConstructorArgs(array($this->config, $phpbb_root_path, $phpEx, $storage, $path_helper, $routing_helper, $dispatcher, $files_factory, $php_ini))
->getMock();
}
@@ -147,7 +148,7 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
$this->assertEquals('avatar.driver.foobar', $drivers['avatar.driver.foobar']);
}
public function get_driver_data_enabled()
public static function get_driver_data_enabled()
{
return array(
array('avatar.driver.foobar', 'avatar.driver.foobar'),
@@ -168,7 +169,7 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
$this->assertEquals($expected, ($driver === null) ? null : $driver->get_name());
}
public function get_driver_data_all()
public static function get_driver_data_all()
{
return array(
array('avatar.driver.foobar', 'avatar.driver.foobar'),
@@ -204,7 +205,7 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
$this->assertEquals($expected_settings, $avatar_settings);
}
public function database_row_data()
public static function database_row_data()
{
return array(
array(
@@ -302,7 +303,7 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
global $phpbb_root_path, $phpEx;
$user = $this->getMockBuilder('\phpbb\user')
->setMethods(array())
->onlyMethods(['lang'])
->setConstructorArgs(array(new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)), '\phpbb\datetime'))
->getMock();
$lang_array = array(
@@ -326,7 +327,7 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
)));
}
public function data_handle_avatar_delete()
public static function data_handle_avatar_delete()
{
return array(
array(

View File

@@ -55,7 +55,7 @@ class ban_manager_test extends \phpbb_session_test_case
$this->phpbb_container = $phpbb_container;
}
public function data_check_ban(): array
public static function data_check_ban(): array
{
return [
[
@@ -170,7 +170,7 @@ class ban_manager_test extends \phpbb_session_test_case
$this->assertEquals($expected, $this->ban_manager->check($user_data));
}
public function data_get_bans(): array
public static function data_get_bans(): array
{
return [
[
@@ -298,7 +298,7 @@ class ban_manager_test extends \phpbb_session_test_case
$this->assertEquals($expected, $actual);
}
public function data_get_ban_end(): array
public static function data_get_ban_end(): array
{
return [
[
@@ -457,7 +457,7 @@ class ban_manager_test extends \phpbb_session_test_case
));
}
public function data_test_ban(): array
public static function data_test_ban(): array
{
return [
[
@@ -629,7 +629,7 @@ class ban_manager_test extends \phpbb_session_test_case
);
}
public function data_test_unban(): array
public static function data_test_unban(): array
{
return [
[
@@ -700,7 +700,7 @@ class ban_manager_test extends \phpbb_session_test_case
$this->assertFalse($check->invoke($ban_type_ip, [], []));
}
public function data_get_ban_message(): array
public static function data_get_ban_message(): array
{
return [
[

View File

@@ -16,7 +16,7 @@ require_once __DIR__ . '/../../phpBB/includes/message_parser.php';
class phpbb_bbcode_parser_test extends \phpbb_test_case
{
public function bbcode_firstpass_data()
public static function bbcode_firstpass_data()
{
return array(
// Default bbcodes from in their simplest way
@@ -249,10 +249,18 @@ class phpbb_bbcode_parser_test extends \phpbb_test_case
$this->markTestIncomplete($incomplete);
}
global $user, $request, $symfony_request;
global $user, $request, $symfony_request, $phpbb_dispatcher, $config, $phpEx;
$phpEx = 'php';
$config = new \phpbb\config\config([
'max_post_font_size' => 0,
'force_server_vars' => 0,
'server_name' => 'testhost',
]);
$user = new phpbb_mock_user;
$user->lang['UNAUTHORISED_BBCODE'] = 'UNAUTHORISED_BBCODE';
$request = new phpbb_mock_request;
$symfony_request = new \phpbb\symfony_request($request);
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$bbcode = new bbcode_firstpass();
$bbcode->mode = 'post';

View File

@@ -16,7 +16,7 @@ require_once __DIR__ . '/../../phpBB/includes/message_parser.php';
class phpbb_url_bbcode_test extends phpbb_test_case
{
public function url_bbcode_test_data()
public static function url_bbcode_test_data()
{
return array(
array(
@@ -52,10 +52,18 @@ class phpbb_url_bbcode_test extends phpbb_test_case
*/
public function test_url($description, $message, $expected)
{
global $user, $request, $symfony_request;
global $user, $request, $symfony_request, $phpbb_dispatcher, $config, $phpEx;
$phpEx = 'php';
$config = new \phpbb\config\config([
'max_post_font_size' => 0,
'force_server_vars' => 0,
'server_name' => 'testhost',
]);
$user = new phpbb_mock_user;
$user->lang['UNAUTHORISED_BBCODE'] = 'UNAUTHORISED_BBCODE';
$request = new phpbb_mock_request;
$symfony_request = new \phpbb\symfony_request($request);
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$bbcode = new bbcode_firstpass();
$bbcode->message = $message;

View File

@@ -14,13 +14,14 @@
define('IN_PHPBB', true);
define('PHPBB_ENVIRONMENT', 'test');
global $phpbb_class_loader, $phpbb_class_loader_mock, $phpbb_class_loader_ext, $phpbb_class_loader_tests;
global $phpbb_root_path, $phpEx, $table_prefix;
$phpbb_root_path = 'phpBB/';
$phpEx = 'php';
global $table_prefix;
require_once $phpbb_root_path . 'includes/startup.php';
$table_prefix = 'phpbb_';
require_once $phpbb_root_path . 'includes/startup.php';
require_once $phpbb_root_path . 'includes/constants.php';
require_once $phpbb_root_path . 'phpbb/class_loader.' . $phpEx;
require_once $phpbb_root_path . 'includes/utf/utf_tools.' . $phpEx;

View File

@@ -32,7 +32,7 @@ class phpbb_cache_redis_driver_test extends \phpbb_cache_common_test_case
$config = phpbb_test_case_helpers::get_test_config();
if (isset($config['redis_host']) || isset($config['redis_port']))
{
$host = isset($config['redis_host']) ? $config['redis_host'] : 'localhost';
$host = isset($config['redis_host']) ? $config['redis_host'] : '0.0.0.0';
$port = isset($config['redis_port']) ? $config['redis_port'] : 6379;
self::$config = array('host' => $host, 'port' => $port);
}
@@ -46,12 +46,14 @@ class phpbb_cache_redis_driver_test extends \phpbb_cache_common_test_case
protected function setUp(): void
{
global $phpbb_root_path, $phpbb_container;
global $phpbb_root_path, $phpbb_container, $dbname, $table_prefix;
parent::setUp();
$phpbb_container = new phpbb_mock_container_builder();
$phpbb_container->setParameter('core.cache_dir', $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/');
$config = phpbb_test_case_helpers::get_test_config();
$dbname = $config['dbname'];
$this->driver = new \phpbb\cache\driver\redis(self::$config['host'], self::$config['port']);
$this->driver->purge();
}

View File

@@ -51,7 +51,7 @@ class phpbb_captcha_qa_test extends \phpbb_database_test_case
$this->assertSame('foobar', $this->qa->get_service_name());
}
public function data_acp_get_question_input()
public static function data_acp_get_question_input()
{
return array(
array("foobar\ntest\nyes", array(

View File

@@ -454,7 +454,7 @@ class phpbb_captcha_turnstile_test extends \phpbb_database_test_case
->expects($matcher)
->method('assign_vars')
->willReturnCallback(function ($template_data) use ($matcher, $expected) {
$callNr = $matcher->getInvocationCount();
$callNr = $matcher->numberOfInvocations();
$this->assertEquals($expected[$callNr], $template_data);
});

View File

@@ -120,7 +120,7 @@ class phpbb_compress_test extends phpbb_test_case
}
}
public function tar_archive_list()
public static function tar_archive_list()
{
return array(
array('archive.tar', '.tar', array()),

View File

@@ -21,9 +21,10 @@ class phpbb_console_command_cache_purge_test extends phpbb_test_case
{
protected $cache_dir;
protected $cache;
protected $config;
protected $db;
protected $db_tools;
protected $config;
protected $language;
protected $user;
protected function setUp(): void

View File

@@ -76,7 +76,7 @@ class phpbb_console_command_cron_list_test extends phpbb_test_case
));
$mock_router = $this->getMockBuilder('\phpbb\routing\router')
->setMethods(array('setContext', 'generate'))
->onlyMethods(array('setContext', 'generate'))
->disableOriginalConstructor()
->getMock();
$mock_router->method('setContext')

View File

@@ -53,7 +53,7 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
));
$mock_router = $this->getMockBuilder('\phpbb\routing\router')
->setMethods(array('setContext', 'generate'))
->onlyMethods(array('setContext', 'generate'))
->disableOriginalConstructor()
->getMock();
$mock_router->method('setContext')
@@ -132,7 +132,7 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
));
$mock_router = $this->getMockBuilder('\phpbb\routing\router')
->setMethods(array('setContext', 'generate'))
->onlyMethods(array('setContext', 'generate'))
->disableOriginalConstructor()
->getMock();
$mock_router->method('setContext')
@@ -180,7 +180,7 @@ class phpbb_console_command_cron_run_test extends phpbb_database_test_case
));
$mock_router = $this->getMockBuilder('\phpbb\routing\router')
->setMethods(array('setContext', 'generate'))
->onlyMethods(array('setContext', 'generate'))
->disableOriginalConstructor()
->getMock();
$mock_router->method('setContext')

View File

@@ -23,6 +23,7 @@ class phpbb_console_command_thumbnail_test extends phpbb_database_test_case
protected $db;
protected $config;
protected $cache;
protected $language;
protected $user;
protected $storage;
protected $temp;

View File

@@ -50,7 +50,7 @@ class phpbb_console_user_activate_test extends phpbb_console_user_base
return new CommandTester($command);
}
public function activate_test_data()
public static function activate_test_data()
{
return array(
// Test an inactive user

View File

@@ -62,7 +62,7 @@ class phpbb_console_user_add_test extends phpbb_console_user_base
return $response;
};
$helper = $this->getMockBuilder('\Symfony\Component\Console\Helper\QuestionHelper')
->setMethods(['ask'])
->onlyMethods(['ask'])
->disableOriginalConstructor()
->getMock();
$helper->expects($this->any())

View File

@@ -15,12 +15,14 @@ abstract class phpbb_console_user_base extends phpbb_database_test_case
{
protected $db;
protected $config;
protected $email;
protected $user;
protected $language;
protected $log;
protected $passwords_manager;
/** @var Symfony\Component\Console\Helper\QuestionHelper */
protected $question;
protected $command_name;
protected $user_loader;
protected $phpbb_root_path;
protected $php_ext;

View File

@@ -21,7 +21,7 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
return $this->createXMLDataSet(__DIR__ . '/fixtures/delete_post.xml');
}
public function delete_post_data()
public static function delete_post_data()
{
$info_data = array(
'topic_first_post_id' => 1,

View File

@@ -18,7 +18,7 @@ class phpbb_content_visibility_get_forums_visibility_sql_test extends phpbb_data
return $this->createXMLDataSet(__DIR__ . '/fixtures/get_forums_visibility_sql.xml');
}
public function get_forums_visibility_sql_data()
public static function get_forums_visibility_sql_data()
{
return array(
array(

View File

@@ -18,7 +18,7 @@ class phpbb_content_visibility_get_global_visibility_sql_test extends phpbb_data
return $this->createXMLDataSet(__DIR__ . '/fixtures/get_forums_visibility_sql.xml');
}
public function get_global_visibility_sql_data()
public static function get_global_visibility_sql_data()
{
return array(
array(

View File

@@ -18,7 +18,7 @@ class phpbb_content_visibility_get_visibility_sql_test extends phpbb_database_te
return $this->createXMLDataSet(__DIR__ . '/fixtures/get_visibility_sql.xml');
}
public function get_visibility_sql_data()
public static function get_visibility_sql_data()
{
return array(
// data set 0: display_unapproved_posts=false, moderator, can see all posts

View File

@@ -21,7 +21,7 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t
return $this->createXMLDataSet(__DIR__ . '/fixtures/set_post_visibility.xml');
}
public function set_post_visibility_data()
public static function set_post_visibility_data()
{
return array(
array(
@@ -155,7 +155,7 @@ class phpbb_content_visibility_set_post_visibility_test extends phpbb_database_t
}
}
public function set_post_soft_deleted_data()
public static function set_post_soft_deleted_data()
{
return array(
array(

View File

@@ -21,7 +21,7 @@ class phpbb_content_visibility_set_topic_visibility_test extends phpbb_database_
return $this->createXMLDataSet(__DIR__ . '/fixtures/set_topic_visibility.xml');
}
public function set_topic_visibility_data()
public static function set_topic_visibility_data()
{
return array(
array(

View File

@@ -79,7 +79,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_database_test_
return 'app.php';
}
protected function path_to_app()
protected static function path_to_app()
{
return '';
}
@@ -166,36 +166,36 @@ abstract class phpbb_controller_common_helper_route extends phpbb_database_test_
$this->root_path = $this->get_phpbb_root_path();
}
public function helper_url_data_no_rewrite()
public static function helper_url_data_no_rewrite()
{
return array(
array('controller2', array('t' => 1, 'f' => 2), true, false, '/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
array('controller2', array('t' => 1, 'f' => 2), false, false, '/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, '/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, '/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
array('controller2', array('t' => 1, 'f' => 2), true, false, '/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
array('controller2', array('t' => 1, 'f' => 2), false, false, '/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, '/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, '/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
// Custom sid parameter
array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', '/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', '/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', '/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', '/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', '/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', '/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
// Testing anchors
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, '/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, '/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, '/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, '/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, '/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, '/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2#anchor', 'anchor in params-argument (array)'),
// Anchors and custom sid
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', '/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', '/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
// Empty parameters should not append the & or ?
array('controller2', array(), true, false, '/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'),
array('controller2', array(), false, false, '/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'),
array('controller3', array('p' => 3), true, false, '/' . $this->path_to_app() . 'app.php/foo/bar/p-3', 'no params using empty array'),
array('controller2', array(), true, false, '/' . static::path_to_app() . 'app.php/foo/bar', 'no params using empty array'),
array('controller2', array(), false, false, '/' . static::path_to_app() . 'app.php/foo/bar', 'no params using empty array'),
array('controller3', array('p' => 3), true, false, '/' . static::path_to_app() . 'app.php/foo/bar/p-3', 'no params using empty array'),
// Resolves DI parameters
array('controller4', array(), true, false, '/' . $this->path_to_app() . 'app.php/foo/' . PHPBB_ENVIRONMENT, 'di parameter'),
array('controller4', array(), true, false, '/' . static::path_to_app() . 'app.php/foo/' . PHPBB_ENVIRONMENT, 'di parameter'),
);
}
@@ -229,36 +229,36 @@ abstract class phpbb_controller_common_helper_route extends phpbb_database_test_
static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id), $description);
}
public function helper_url_data_with_rewrite()
public static function helper_url_data_with_rewrite()
{
return array(
array('controller2', array('t' => 1, 'f' => 2), true, false, '/' . $this->path_to_app() . 'foo/bar?t=1&f=2', 'parameters in params-argument as array'),
array('controller2', array('t' => 1, 'f' => 2), false, false, '/' . $this->path_to_app() . 'foo/bar?t=1&f=2', 'parameters in params-argument as array'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, '/' . $this->path_to_app() . 'foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, '/' . $this->path_to_app() . 'foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
array('controller2', array('t' => 1, 'f' => 2), true, false, '/' . static::path_to_app() . 'foo/bar?t=1&f=2', 'parameters in params-argument as array'),
array('controller2', array('t' => 1, 'f' => 2), false, false, '/' . static::path_to_app() . 'foo/bar?t=1&f=2', 'parameters in params-argument as array'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, '/' . static::path_to_app() . 'foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, '/' . static::path_to_app() . 'foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
// Custom sid parameter
array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', '/' . $this->path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', '/' . $this->path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', '/' . $this->path_to_app() . 'foo/bar/p-3?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', '/' . static::path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', '/' . static::path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', '/' . static::path_to_app() . 'foo/bar/p-3?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
// Testing anchors
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, '/' . $this->path_to_app() . 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, '/' . $this->path_to_app() . 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, '/' . $this->path_to_app() . 'foo/bar/p-3?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, '/' . static::path_to_app() . 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, '/' . static::path_to_app() . 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, '/' . static::path_to_app() . 'foo/bar/p-3?t=1&f=2#anchor', 'anchor in params-argument (array)'),
// Anchors and custom sid
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '/' . $this->path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', '/' . $this->path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '/' . $this->path_to_app() . 'foo/bar/p-3?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '/' . static::path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', '/' . static::path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '/' . static::path_to_app() . 'foo/bar/p-3?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
// Empty parameters should not append the & or ?
array('controller2', array(), true, false, '/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'),
array('controller2', array(), false, false, '/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'),
array('controller3', array('p' => 3), true, false, '/' . $this->path_to_app() . 'foo/bar/p-3', 'no params using empty array'),
array('controller2', array(), true, false, '/' . static::path_to_app() . 'foo/bar', 'no params using empty array'),
array('controller2', array(), false, false, '/' . static::path_to_app() . 'foo/bar', 'no params using empty array'),
array('controller3', array('p' => 3), true, false, '/' . static::path_to_app() . 'foo/bar/p-3', 'no params using empty array'),
// Resolves DI parameters
array('controller4', array(), true, false, '/' . $this->path_to_app() . 'foo/' . PHPBB_ENVIRONMENT, 'di parameter'),
array('controller4', array(), true, false, '/' . static::path_to_app() . 'foo/' . PHPBB_ENVIRONMENT, 'di parameter'),
);
}
@@ -292,36 +292,36 @@ abstract class phpbb_controller_common_helper_route extends phpbb_database_test_
static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id), $description);
}
public function helper_url_data_absolute()
public static function helper_url_data_absolute()
{
return array(
array('controller2', array('t' => 1, 'f' => 2), true, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
array('controller2', array('t' => 1, 'f' => 2), false, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
array('controller2', array('t' => 1, 'f' => 2), true, false, 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
array('controller2', array('t' => 1, 'f' => 2), false, false, 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
// Custom sid parameter
array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
// Testing anchors
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2#anchor', 'anchor in params-argument (array)'),
// Anchors and custom sid
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
// Empty parameters should not append the & or ?
array('controller2', array(), true, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'),
array('controller2', array(), false, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'),
array('controller3', array('p' => 3), true, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3', 'no params using empty array'),
array('controller2', array(), true, false, 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar', 'no params using empty array'),
array('controller2', array(), false, false, 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar', 'no params using empty array'),
array('controller3', array('p' => 3), true, false, 'http://localhost/' . static::path_to_app() . 'app.php/foo/bar/p-3', 'no params using empty array'),
// Resolves DI parameters
array('controller4', array(), true, false, 'http://localhost/' . $this->path_to_app() . 'app.php/foo/' . PHPBB_ENVIRONMENT, 'di parameter'),
array('controller4', array(), true, false, 'http://localhost/' . static::path_to_app() . 'app.php/foo/' . PHPBB_ENVIRONMENT, 'di parameter'),
);
}
@@ -355,7 +355,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_database_test_
static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL), $description);
}
public function helper_url_data_relative_path()
public static function helper_url_data_relative_path()
{
return array(
array('controller2', array('t' => 1, 'f' => 2), true, false, 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
@@ -418,36 +418,36 @@ abstract class phpbb_controller_common_helper_route extends phpbb_database_test_
static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH), $description);
}
public function helper_url_data_network()
public static function helper_url_data_network()
{
return array(
array('controller2', array('t' => 1, 'f' => 2), true, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
array('controller2', array('t' => 1, 'f' => 2), false, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
array('controller2', array('t' => 1, 'f' => 2), true, false, '//localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
array('controller2', array('t' => 1, 'f' => 2), false, false, '//localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, '//localhost/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, '//localhost/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
// Custom sid parameter
array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', '//localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', '//localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', '//localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', '//localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', '//localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', '//localhost/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
// Testing anchors
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, '//localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, '//localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, '//localhost/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2#anchor', 'anchor in params-argument (array)'),
// Anchors and custom sid
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '//localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', '//localhost/' . $this->path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '//localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '//localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', '//localhost/' . static::path_to_app() . 'app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '//localhost/' . static::path_to_app() . 'app.php/foo/bar/p-3?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
// Empty parameters should not append the & or ?
array('controller2', array(), true, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'),
array('controller2', array(), false, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar', 'no params using empty array'),
array('controller3', array('p' => 3), true, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/bar/p-3', 'no params using empty array'),
array('controller2', array(), true, false, '//localhost/' . static::path_to_app() . 'app.php/foo/bar', 'no params using empty array'),
array('controller2', array(), false, false, '//localhost/' . static::path_to_app() . 'app.php/foo/bar', 'no params using empty array'),
array('controller3', array('p' => 3), true, false, '//localhost/' . static::path_to_app() . 'app.php/foo/bar/p-3', 'no params using empty array'),
// Resolves DI parameters
array('controller4', array(), true, false, '//localhost/' . $this->path_to_app() . 'app.php/foo/' . PHPBB_ENVIRONMENT, 'di parameter'),
array('controller4', array(), true, false, '//localhost/' . static::path_to_app() . 'app.php/foo/' . PHPBB_ENVIRONMENT, 'di parameter'),
);
}
@@ -481,36 +481,36 @@ abstract class phpbb_controller_common_helper_route extends phpbb_database_test_
static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description);
}
public function helper_url_data_absolute_with_rewrite()
public static function helper_url_data_absolute_with_rewrite()
{
return array(
array('controller2', array('t' => 1, 'f' => 2), true, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2', 'parameters in params-argument as array'),
array('controller2', array('t' => 1, 'f' => 2), false, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2', 'parameters in params-argument as array'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
array('controller2', array('t' => 1, 'f' => 2), true, false, 'http://localhost/' . static::path_to_app() . 'foo/bar?t=1&f=2', 'parameters in params-argument as array'),
array('controller2', array('t' => 1, 'f' => 2), false, false, 'http://localhost/' . static::path_to_app() . 'foo/bar?t=1&f=2', 'parameters in params-argument as array'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, 'http://localhost/' . static::path_to_app() . 'foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, 'http://localhost/' . static::path_to_app() . 'foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
// Custom sid parameter
array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', 'http://localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', 'http://localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', 'http://localhost/' . $this->path_to_app() . 'foo/bar/p-3?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', 'http://localhost/' . static::path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', 'http://localhost/' . static::path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', 'http://localhost/' . static::path_to_app() . 'foo/bar/p-3?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
// Testing anchors
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar/p-3?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'http://localhost/' . static::path_to_app() . 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, 'http://localhost/' . static::path_to_app() . 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'http://localhost/' . static::path_to_app() . 'foo/bar/p-3?t=1&f=2#anchor', 'anchor in params-argument (array)'),
// Anchors and custom sid
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'http://localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', 'http://localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'http://localhost/' . $this->path_to_app() . 'foo/bar/p-3?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'http://localhost/' . static::path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', 'http://localhost/' . static::path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'http://localhost/' . static::path_to_app() . 'foo/bar/p-3?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
// Empty parameters should not append the & or ?
array('controller2', array(), true, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'),
array('controller2', array(), false, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'),
array('controller3', array('p' => 3), true, false, 'http://localhost/' . $this->path_to_app() . 'foo/bar/p-3', 'no params using empty array'),
array('controller2', array(), true, false, 'http://localhost/' . static::path_to_app() . 'foo/bar', 'no params using empty array'),
array('controller2', array(), false, false, 'http://localhost/' . static::path_to_app() . 'foo/bar', 'no params using empty array'),
array('controller3', array('p' => 3), true, false, 'http://localhost/' . static::path_to_app() . 'foo/bar/p-3', 'no params using empty array'),
// Resolves DI parameters
array('controller4', array(), true, false, 'http://localhost/' . $this->path_to_app() . 'foo/' . PHPBB_ENVIRONMENT, 'di parameter'),
array('controller4', array(), true, false, 'http://localhost/' . static::path_to_app() . 'foo/' . PHPBB_ENVIRONMENT, 'di parameter'),
);
}
@@ -544,7 +544,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_database_test_
static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::ABSOLUTE_URL), $description);
}
public function helper_url_data_relative_path_with_rewrite()
public static function helper_url_data_relative_path_with_rewrite()
{
return array(
array('controller2', array('t' => 1, 'f' => 2), true, false, 'foo/bar?t=1&f=2', 'parameters in params-argument as array'),
@@ -604,36 +604,36 @@ abstract class phpbb_controller_common_helper_route extends phpbb_database_test_
static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::RELATIVE_PATH), $description);
}
public function helper_url_data_network_with_rewrite()
public static function helper_url_data_network_with_rewrite()
{
return array(
array('controller2', array('t' => 1, 'f' => 2), true, false, '//localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2', 'parameters in params-argument as array'),
array('controller2', array('t' => 1, 'f' => 2), false, false, '//localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2', 'parameters in params-argument as array'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, '//localhost/' . $this->path_to_app() . 'foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, '//localhost/' . $this->path_to_app() . 'foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
array('controller2', array('t' => 1, 'f' => 2), true, false, '//localhost/' . static::path_to_app() . 'foo/bar?t=1&f=2', 'parameters in params-argument as array'),
array('controller2', array('t' => 1, 'f' => 2), false, false, '//localhost/' . static::path_to_app() . 'foo/bar?t=1&f=2', 'parameters in params-argument as array'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, '//localhost/' . static::path_to_app() . 'foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, '//localhost/' . static::path_to_app() . 'foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
// Custom sid parameter
array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', '//localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', '//localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', '//localhost/' . $this->path_to_app() . 'foo/bar/p-3?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', '//localhost/' . static::path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', '//localhost/' . static::path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', '//localhost/' . static::path_to_app() . 'foo/bar/p-3?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
// Testing anchors
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, '//localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, '//localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, '//localhost/' . $this->path_to_app() . 'foo/bar/p-3?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, '//localhost/' . static::path_to_app() . 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, '//localhost/' . static::path_to_app() . 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, '//localhost/' . static::path_to_app() . 'foo/bar/p-3?t=1&f=2#anchor', 'anchor in params-argument (array)'),
// Anchors and custom sid
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '//localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', '//localhost/' . $this->path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '//localhost/' . $this->path_to_app() . 'foo/bar/p-3?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '//localhost/' . static::path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', '//localhost/' . static::path_to_app() . 'foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', '//localhost/' . static::path_to_app() . 'foo/bar/p-3?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
// Empty parameters should not append the & or ?
array('controller2', array(), true, false, '//localhost/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'),
array('controller2', array(), false, false, '//localhost/' . $this->path_to_app() . 'foo/bar', 'no params using empty array'),
array('controller3', array('p' => 3), true, false, '//localhost/' . $this->path_to_app() . 'foo/bar/p-3', 'no params using empty array'),
array('controller2', array(), true, false, '//localhost/' . static::path_to_app() . 'foo/bar', 'no params using empty array'),
array('controller2', array(), false, false, '//localhost/' . static::path_to_app() . 'foo/bar', 'no params using empty array'),
array('controller3', array('p' => 3), true, false, '//localhost/' . static::path_to_app() . 'foo/bar/p-3', 'no params using empty array'),
// Resolves DI parameters
array('controller4', array(), true, false, '//localhost/' . $this->path_to_app() . 'foo/' . PHPBB_ENVIRONMENT, 'di parameter'),
array('controller4', array(), true, false, '//localhost/' . static::path_to_app() . 'foo/' . PHPBB_ENVIRONMENT, 'di parameter'),
);
}
@@ -667,7 +667,7 @@ abstract class phpbb_controller_common_helper_route extends phpbb_database_test_
static::assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id, UrlGeneratorInterface::NETWORK_PATH), $description);
}
public function helper_url_data_force_server_vars()
public static function helper_url_data_force_server_vars()
{
return array(
array(false, true, 'my_server', 443, '/my/board', 'http://', UrlGeneratorInterface::ABSOLUTE_URL, 'http://my_server:443/my/board/app.php/foo'),

View File

@@ -102,7 +102,7 @@ class phpbb_controller_controller_test extends phpbb_test_case
$this->assertEquals(array(), $resolver->getArguments($symfony_request, $resolver->getController($symfony_request)));
}
public function data_get_arguments()
public static function data_get_arguments()
{
return array(
array(array(new foo\controller(), 'handle2'), array('foo', 0)),

View File

@@ -30,7 +30,7 @@ class phpbb_controller_helper_route_other_app_test extends phpbb_controller_comm
return 'app.php';
}
protected function path_to_app()
protected static function path_to_app()
{
return 'foo/';
}

View File

@@ -13,7 +13,7 @@
require_once __DIR__ . '/common_helper_route.php';
class phpbb_controller_helper_route_test extends phpbb_controller_common_helper_route
class phpbb_controller_helper_route_root_test extends phpbb_controller_common_helper_route
{
protected function get_phpbb_root_path()
{

View File

@@ -35,7 +35,7 @@ class phpbb_controller_helper_route_slash_test extends phpbb_controller_common_h
return 'app.php';
}
protected function path_to_app()
protected static function path_to_app()
{
return 'phpBB/';
}

View File

@@ -84,7 +84,7 @@ class phpbb_cron_manager_test extends \phpbb_test_case
));
$mock_router = $this->getMockBuilder('\phpbb\routing\router')
->setMethods(array('setContext', 'generate'))
->onlyMethods(array('setContext', 'generate'))
->disableOriginalConstructor()
->getMock();
$mock_router->method('setContext')

View File

@@ -111,7 +111,8 @@ class phpbb_cron_wrapper_test extends phpbb_template_template_test_case
{
$this->task = $this->getMockBuilder(\phpbb\cron\task\task::class)
->disableOriginalConstructor()
->setMethods(['get_name', 'run', 'is_runnable', 'should_run', 'some_method'])
->onlyMethods(['get_name', 'run', 'is_runnable', 'should_run'])
->addMethods(['some_method'])
->getMock();
$this->routing_helper = $this->createMock(\phpbb\routing\helper::class);

View File

@@ -15,21 +15,59 @@ require_once __DIR__ . '/../mock/lang.php';
class phpbb_datetime_from_format_test extends phpbb_test_case
{
public function from_format_data()
/** @var \phpbb\language\language */
protected $lang;
/** @var \phpbb\user */
protected $user;
protected function setUp(): void
{
return array(
array(
global $phpbb_root_path, $phpEx;
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$this->lang = new \phpbb\language\language($lang_loader);
// Set up language data for testing
$reflection_class = new ReflectionClass('\phpbb\language\language');
// Set default language files loaded flag to true
$common_language_files_loaded_flag = $reflection_class->getProperty('common_language_files_loaded');
$common_language_files_loaded_flag->setAccessible(true);
$common_language_files_loaded_flag->setValue($this->lang, true);
// Set up test language data
$lang_array = $reflection_class->getProperty('lang');
$lang_array->setAccessible(true);
$lang_array->setValue($this->lang, [
'datetime' => [
'TODAY' => 'Today',
'TOMORROW' => 'Tomorrow',
'YESTERDAY' => 'Yesterday',
'AGO' => [
0 => 'less than a minute ago',
1 => '%d minute ago',
2 => '%d minutes ago',
],
],
]);
$this->user = new \phpbb\user($this->lang, '\phpbb\datetime');
}
public static function from_format_data()
{
return [
[
'UTC',
'Y-m-d',
'2012-06-08',
),
],
array(
[
'Europe/Berlin',
'Y-m-d H:i:s',
'2012-06-08 14:01:02',
),
);
],
];
}
/**
@@ -37,86 +75,66 @@ class phpbb_datetime_from_format_test extends phpbb_test_case
*/
public function test_from_format($timezone, $format, $expected)
{
global $phpbb_root_path, $phpEx;
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$lang = new \phpbb\language\language($lang_loader);
$user = new \phpbb\user($lang, '\phpbb\datetime');
$user->timezone = new DateTimeZone($timezone);
$user->lang['datetime'] = array(
'TODAY' => 'Today',
'TOMORROW' => 'Tomorrow',
'YESTERDAY' => 'Yesterday',
'AGO' => array(
0 => 'less than a minute ago',
1 => '%d minute ago',
2 => '%d minutes ago',
),
);
$timestamp = $user->get_timestamp_from_format($format, $expected, new DateTimeZone($timezone));
$this->assertEquals($expected, $user->format_date($timestamp, $format, true));
$this->user->timezone = new DateTimeZone($timezone);
$timestamp = $this->user->get_timestamp_from_format($format, $expected, new DateTimeZone($timezone));
$this->assertEquals($expected, $this->user->format_date($timestamp, $format, true));
}
public function relative_format_date_data()
public static function relative_format_date_data()
{
// If the current time is too close to the testing time,
// the relative time will use "x minutes ago" instead of "today ..."
// So we use 18:01 in the morning and 06:01 in the afternoon.
$testing_time = gmdate('H') <= 12 ? '18:01' : '06:01';
return array(
array(
return [
[
gmdate('Y-m-d', time() + 2 * 86400) . ' ' . $testing_time, false,
gmdate('Y-m-d', time() + 2 * 86400) . ' ' . $testing_time,
),
array(
],
[
gmdate('Y-m-d', time() + 86400) . ' ' . $testing_time, false,
'Tomorrow ' . $testing_time,
),
array(
],
[
gmdate('Y-m-d', time() + 86400) . ' ' . $testing_time, true,
gmdate('Y-m-d', time() + 86400) . ' ' . $testing_time,
),
array(
],
[
gmdate('Y-m-d') . ' ' . $testing_time, false,
'Today ' . $testing_time,
),
array(
],
[
gmdate('Y-m-d') . ' ' . $testing_time, true,
gmdate('Y-m-d') . ' ' . $testing_time,
),
array(
],
[
gmdate('Y-m-d', time() - 86400) . ' ' . $testing_time, false,
'Yesterday ' . $testing_time,
),
array(
],
[
gmdate('Y-m-d', time() - 86400) . ' ' . $testing_time, true,
gmdate('Y-m-d', time() - 86400) . ' ' . $testing_time,
),
array(
],
[
gmdate('Y-m-d', time() - 2 * 86400) . ' ' . $testing_time, false,
gmdate('Y-m-d', time() - 2 * 86400) . ' ' . $testing_time,
),
],
// Test edge cases: Yesterday 00:00, Today 00:00, Tomorrow 00:00
array(
[
gmdate('Y-m-d', strtotime('yesterday')) . ' 00:00', false,
'Yesterday 00:00',
),
array(
],
[
gmdate('Y-m-d', strtotime('today')) . ' 00:00', false,
'Today 00:00',
),
array(
],
[
gmdate('Y-m-d', strtotime('tomorrow')) . ' 00:00', false,
'Tomorrow 00:00',
),
);
],
];
}
/**
@@ -124,24 +142,8 @@ class phpbb_datetime_from_format_test extends phpbb_test_case
*/
public function test_relative_format_date($timestamp, $forcedate, $expected)
{
global $phpbb_root_path, $phpEx;
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$lang = new \phpbb\language\language($lang_loader);
$user = new \phpbb\user($lang, '\phpbb\datetime');
$user->timezone = new DateTimeZone('UTC');
$user->lang['datetime'] = array(
'TODAY' => 'Today',
'TOMORROW' => 'Tomorrow',
'YESTERDAY' => 'Yesterday',
'AGO' => array(
0 => 'less than a minute ago',
1 => '%d minute ago',
2 => '%d minutes ago',
),
);
$timestamp = $user->get_timestamp_from_format('Y-m-d H:i', $timestamp, new DateTimeZone('UTC'));
$this->user->timezone = new DateTimeZone('UTC');
$timestamp = $this->user->get_timestamp_from_format('Y-m-d H:i', $timestamp, new DateTimeZone('UTC'));
/* This code is equal to the one from \phpbb\datetime function format()
* If the delta is less than or equal to 1 hour
@@ -156,9 +158,9 @@ class phpbb_datetime_from_format_test extends phpbb_test_case
($delta >= -5 || (($now_ts/ 60) % 60) == (($timestamp / 60) % 60))
)
{
$expected = $user->lang(['datetime', 'AGO'], max(0, (int) floor($delta / 60)));
$expected = $this->lang->lang(['datetime', 'AGO'], max(0, (int) floor($delta / 60)));
}
$this->assertEquals($expected, $user->format_date($timestamp, '|Y-m-d| H:i', $forcedate));
$this->assertEquals($expected, $this->user->format_date($timestamp, '|Y-m-d| H:i', $forcedate));
}
}

View File

@@ -31,15 +31,21 @@ class phpbb_dbal_connect_test extends phpbb_database_test_case
// Failure to connect results in a trigger_error call in dbal.
// phpunit converts triggered errors to exceptions.
// In particular there should be no fatals here.
try
if ($db->get_sql_layer() === 'mysqli')
{
$db->sql_connect($config['dbhost'], 'phpbbogus', 'phpbbogus', 'phpbbogus', $config['dbport']);
$this->assertFalse(true);
$this->setExpectedTriggerError(E_WARNING);
}
catch (Exception $e)
else if ($db->get_sql_layer() !== 'sqlite3')
{
// should have a legitimate message
$this->assertNotEmpty($e->getMessage());
$this->setExpectedTriggerError(E_USER_ERROR);
}
// For SQLite3, connection will be successful anyway as phpBB driver uses SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE flags
$result = $db->sql_connect($config['dbhost'], 'phpbbogus', 'phpbbogus', 'phpbbogus', $config['dbport']);
if ($db->get_sql_layer() === 'sqlite3')
{
$this->assertTrue($result);
}
}
}

View File

@@ -404,11 +404,19 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
->will($this->returnValue(true));
// drop tables
$db_tools->expects($this->exactly(2))->method('schema_drop_table')
->withConsecutive(
[$this->isInstanceOf(Schema::class), 'dropped_table_1', true],
[$this->isInstanceOf(Schema::class), 'dropped_table_2', true]
);
$matcher = $this->exactly(2);
$db_tools->expects($matcher)->method('schema_drop_table')
->willReturnCallback(function() use ($matcher) {
$args = func_get_args();
$schema = array_shift($args);
$this->assertInstanceOf(\Doctrine\DBAL\Schema\Schema::class, $schema);
match($matcher->numberOfInvocations())
{
1 => $this->assertEquals($args, ['dropped_table_1', true]),
2 => $this->assertEquals($args, ['dropped_table_2', true]),
};
}
);
$db_tools->perform_schema_changes(array(
'drop_tables' => array(
@@ -432,11 +440,18 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
->will($this->returnValue(true));
// drop columns
$db_tools->expects($this->exactly(2))->method('schema_column_remove')
->withConsecutive(
[$this->isInstanceOf(Schema::class), 'existing_table', 'dropped_column_1', true],
[$this->isInstanceOf(Schema::class), 'existing_table', 'dropped_column_2', true]
);
$matcher = $this->exactly(2);
$db_tools->expects($matcher)->method('schema_column_remove')
->willReturnCallback(function() use ($matcher) {
$args = func_get_args();
$schema = array_shift($args);
$this->assertInstanceOf(\Doctrine\DBAL\Schema\Schema::class, $schema);
match($matcher->numberOfInvocations()) {
1 => $this->assertEquals($args, ['existing_table', 'dropped_column_1', true]),
2 => $this->assertEquals($args, ['existing_table', 'dropped_column_2', true]),
};
}
);
$db_tools->perform_schema_changes(array(
'drop_columns' => array(

View File

@@ -13,6 +13,10 @@
class phpbb_dbal_migrator_tool_config_text_test extends phpbb_database_test_case
{
protected $db;
protected $config_text;
protected $tool;
public function getDataSet()
{
return $this->createXMLDataSet(__DIR__.'/fixtures/migrator_config_text.xml');

View File

@@ -16,6 +16,11 @@ require_once __DIR__ . '/ext/foo/bar/ucp/ucp_test_info.php';
class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
{
protected $db;
protected $cache;
protected $user;
protected $tool;
public function getDataSet()
{
return $this->createXMLDataSet(__DIR__.'/fixtures/migrator_module.xml');
@@ -51,7 +56,7 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
$this->tool = new \phpbb\db\migration\tool\module($this->db, $this->user, $module_manager, 'phpbb_modules');
}
public function exists_data_acp()
public static function exists_data_acp()
{
return array(
// Test the existing category
@@ -184,7 +189,7 @@ class phpbb_dbal_migrator_tool_module_test extends phpbb_database_test_case
$this->assertEquals($expected, $this->tool->exists('acp', $parent, $module, $lazy));
}
public function exists_data_ucp()
public static function exists_data_ucp()
{
return array(
// Test the existing category

View File

@@ -22,6 +22,12 @@ class phpbb_dbal_migrator_tool_permission_role_test extends phpbb_database_test_
/** @var \phpbb\db\migration\tool\permission */
protected $tool;
/** @var \phpbb\db\driver\driver_interface */
protected $db;
/** @var \phpbb\cache\service */
protected $cache;
public $group_ids = [
'REGISTERED' => 2,
'GLOBAL_MODERATORS' => 4,
@@ -102,7 +108,7 @@ class phpbb_dbal_migrator_tool_permission_role_test extends phpbb_database_test_
$this->auth_admin = new \auth_admin();
}
public function data_test_new_role_exists()
public static function data_test_new_role_exists()
{
return [
['ROLE_ADMIN_NEW', true],
@@ -119,7 +125,7 @@ class phpbb_dbal_migrator_tool_permission_role_test extends phpbb_database_test_
$this->assertEquals($expected, (bool) $this->tool->role_exists($role_name));
}
public function data_test_permission_assign_new_roles()
public static function data_test_permission_assign_new_roles()
{
return [
[

View File

@@ -16,6 +16,12 @@ class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case
/** @var \phpbb\auth\auth */
protected $auth;
/** @var \phpbb\db\driver\driver_interface */
protected $db;
/** @var \phpbb\cache\service */
protected $cache;
/** @var \phpbb\db\migration\tool\permission */
protected $tool;
@@ -45,7 +51,7 @@ class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case
$this->tool = new \phpbb\db\migration\tool\permission($this->db, $this->cache, $this->auth, $phpbb_root_path, $phpEx);
}
public function exists_data()
public static function exists_data()
{
return array(
array(
@@ -170,7 +176,7 @@ class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case
$this->assertFalse($this->tool->exists('global_test', true));
}
public function data_test_permission_set()
public static function data_test_permission_set()
{
return array(
array(
@@ -226,7 +232,7 @@ class phpbb_dbal_migrator_tool_permission_test extends phpbb_database_test_case
}
}
public function data_test_permission_role_exists()
public static function data_test_permission_role_exists()
{
return array(
array('ROLE_MOD_FULL', true),

View File

@@ -18,7 +18,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
return $this->createXMLDataSet(__DIR__.'/fixtures/three_users.xml');
}
public function return_on_error_select_data()
public static function return_on_error_select_data()
{
return array(
array('phpbb_users', "username_clean = 'bertie'", array(array('username_clean' => 'bertie'))),
@@ -45,7 +45,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
$this->assertEquals($expected, $db->sql_fetchrowset($result));
}
public function fetchrow_data()
public static function fetchrow_data()
{
return array(
array('', array(array('username_clean' => 'barfoo'),
@@ -96,7 +96,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
$db->sql_freeresult($result);
}
public function fetchfield_data()
public static function fetchfield_data()
{
return array(
array('', array('barfoo', 'foobar', 'bertie')),
@@ -126,7 +126,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
$this->assertEquals($expected, $ary);
}
static public function fetchfield_seek_data()
public static function fetchfield_seek_data()
{
return array(
array(1, 'foobar'),
@@ -152,7 +152,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
$this->assertEquals($expected, $field);
}
static public function query_limit_data()
public static function query_limit_data()
{
return array(
array(0, 0, array(array('username_clean' => 'barfoo'),
@@ -193,7 +193,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
$this->assertEquals($expected, $ary);
}
public function like_expression_data()
public static function like_expression_data()
{
// * = any_char; # = one_char
return array(
@@ -230,7 +230,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
$db->sql_freeresult($result);
}
public function not_like_expression_data()
public static function not_like_expression_data()
{
// * = any_char; # = one_char
return array(
@@ -290,7 +290,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
$db->sql_freeresult($result);
}
public function in_set_data()
public static function in_set_data()
{
return array(
array('user_id', 3, false, false, array(array('username_clean' => 'bertie'))),
@@ -364,7 +364,7 @@ class phpbb_dbal_select_test extends phpbb_database_test_case
$db->sql_freeresult($result);
}
public function build_array_data()
public static function build_array_data()
{
return array(
array(array('username_clean' => 'barfoo'), array(array('username_clean' => 'barfoo'))),

View File

@@ -18,7 +18,7 @@ class phpbb_dbal_write_test extends phpbb_database_test_case
return $this->createXMLDataSet(__DIR__.'/fixtures/config.xml');
}
public function build_array_insert_data()
public static function build_array_insert_data()
{
return array(
array(array(
@@ -167,7 +167,7 @@ class phpbb_dbal_write_test extends phpbb_database_test_case
$db->sql_freeresult($result);
}
public function update_data()
public static function update_data()
{
return array(
array(

View File

@@ -15,7 +15,7 @@ namespace
{
require_once __DIR__ . '/fixtures/ext/vendor/enabled_4/di/extension.php';
class phpbb_di_container_test extends \phpbb_test_case
class phpbb_di_create_container_test extends \phpbb_test_case
{
protected $config_php;
@@ -73,7 +73,8 @@ namespace
// Checks the construction of a dumped container
$container = $this->builder->get_container();
$this->assertInstanceOf('phpbb_cache_container', $container);
$this->assertEquals('phpbb_cache_container', $container::class);
$this->assertInstanceOf('Symfony\Component\DependencyInjection\Container', $container);
$this->assertTrue($container->isCompiled());
}
@@ -100,7 +101,8 @@ namespace
// Checks the construction of a dumped container
$container = $this->builder->get_container();
$this->assertNotInstanceOf('phpbb_cache_container', $container);
$this->assertNotEquals('phpbb_cache_container', $container::class);
$this->assertEquals('Symfony\Component\DependencyInjection\ContainerBuilder', $container::class);
$this->assertInstanceOf('Symfony\Component\DependencyInjection\ContainerBuilder', $container);
$this->assertTrue($container->isCompiled());
}

View File

@@ -1,7 +1,7 @@
<?php
// phpBB 3.1.x auto-generated configuration file
// Do not change anything in this file!
$dbms = 'mysql';
$dbms = ''; // Set this to empty value to avoid failed connection attempt as this will produce unwanted error/exception
$dbhost = '127.0.0.1';
$dbport = '';
$dbname = 'phpbb';

View File

@@ -19,6 +19,9 @@ class phpbb_email_parsing_test extends phpbb_test_case
/** @var \ReflectionProperty */
protected $reflection_template_property;
/** @var \phpbb\messenger\method\email */
protected $email;
protected function setUp(): void
{
global $phpbb_container, $config, $phpbb_root_path, $phpEx, $request, $user;
@@ -146,7 +149,7 @@ class phpbb_email_parsing_test extends phpbb_test_case
$this->reflection_template_property->setAccessible(true);
}
public function email_parsing_data()
public static function email_parsing_data()
{
return array(
array('Author username', 'Any forum', 'The topic title', 'Dear user'),

View File

@@ -24,7 +24,7 @@ class phpbb_error_collector_test extends phpbb_test_case
public function test_collection()
{
$collector = new \phpbb\error_collector(E_ALL | E_STRICT); // php set_error_handler() default
$collector = new \phpbb\error_collector(E_ALL | E_NOTICE); // php set_error_handler() default
$collector->install();
// Cause a warning

View File

@@ -11,9 +11,9 @@
*
*/
class exception_listener extends phpbb_test_case
class exception_listener_test extends phpbb_test_case
{
public function phpbb_exception_data()
public static function phpbb_exception_data()
{
return array(
array(

View File

@@ -58,7 +58,7 @@ class phpbb_extension_extension_base_test extends phpbb_test_case
$container);
}
public function data_test_suffix_get_classes()
public static function data_test_suffix_get_classes()
{
return array(
array(

View File

@@ -57,7 +57,7 @@ class phpbb_extension_finder_test extends phpbb_test_case
);
}
public function set_extensions_data()
public static function set_extensions_data()
{
return array(
array(

View File

@@ -163,7 +163,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$this->assertEquals($metadata, $json);
}
public function validator_non_existing_data()
public static function validator_non_existing_data()
{
return array(
array('name'),
@@ -223,7 +223,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
}
}
public function validator_invalid_data()
public static function validator_invalid_data()
{
return array(
array('name', 'asdf'),
@@ -281,7 +281,7 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
}
}
public function validator_requirements_data()
public static function validator_requirements_data()
{
return array(
array(

View File

@@ -174,7 +174,7 @@ class phpbb_extension_modules_test extends phpbb_test_case
), $acp_modules);
}
public function module_auth_test_data()
public static function module_auth_test_data()
{
return array(
// module_auth, expected result

View File

@@ -76,7 +76,7 @@ class phpbb_feed_attachments_base_test extends phpbb_database_test_case
);
}
public function data_fetch_attachments()
public static function data_fetch_attachments()
{
return array(
array(array(0), array(0)),

View File

@@ -54,7 +54,7 @@ class phpbb_files_types_base_test extends phpbb_test_case
$this->factory = new \phpbb\files\factory($this->container);
}
public function data_check_upload_size()
public static function data_check_upload_size()
{
return array(
array('foo', '500KB', array()),

View File

@@ -71,7 +71,7 @@ class phpbb_files_types_form_test extends phpbb_test_case
$this->phpbb_root_path = $phpbb_root_path;
}
public function data_upload_form()
public static function data_upload_form()
{
return array(
array(

View File

@@ -96,7 +96,7 @@ class phpbb_files_types_local_test extends phpbb_test_case
$this->assertInstanceOf('\phpbb\files\filespec', $file);
}
public function data_upload_form()
public static function data_upload_form()
{
return array(
array(

View File

@@ -96,7 +96,7 @@ class phpbb_files_upload_test extends phpbb_test_case
$this->assertFalse($upload->is_valid('foobar'));
}
public function data_internal_error()
public static function data_internal_error()
{
return array(
array(UPLOAD_ERR_INI_SIZE, 'PHP_SIZE_OVERRUN'),

View File

@@ -21,7 +21,7 @@ class phpbb_filesystem_clean_path_test extends phpbb_test_case
$this->filesystem = new \phpbb\filesystem\filesystem();
}
public function clean_path_data()
public static function clean_path_data()
{
return array(
array('foo', 'foo'),

View File

@@ -21,7 +21,7 @@ class phpbb_filesystem_helper_clean_path_test extends phpbb_test_case
parent::setUp();
}
public function clean_path_data()
public static function clean_path_data()
{
yield ['foo', 'foo'];
yield ['foo/bar', 'foo/bar'];

View File

@@ -21,7 +21,7 @@ class phpbb_filesystem_helper_is_absolute_test extends phpbb_test_case
parent::setUp();
}
static public function is_absolute_data()
public static function is_absolute_data()
{
// Empty
yield ['', false];

View File

@@ -30,7 +30,7 @@ class phpbb_filesystem_helper_realpath_test extends phpbb_test_case
parent::setUp();
}
public function realpath_resolve_absolute_without_symlinks_data()
public static function realpath_resolve_absolute_without_symlinks_data()
{
// Constant data
yield [__DIR__, __DIR__];
@@ -42,7 +42,7 @@ class phpbb_filesystem_helper_realpath_test extends phpbb_test_case
yield [__FILE__ . '../', false];
}
public function realpath_resolve_relative_without_symlinks_data()
public static function realpath_resolve_relative_without_symlinks_data()
{
if (!function_exists('getcwd'))
{

View File

@@ -23,7 +23,7 @@ class phpbb_filesystem_is_absolute_test extends phpbb_test_case
$this->filesystem = new \phpbb\filesystem\filesystem();
}
static public function is_absolute_data()
public static function is_absolute_data()
{
return array(
// Empty

View File

@@ -34,7 +34,7 @@ class phpbb_filesystem_realpath_test extends phpbb_test_case
$this->filesystem = new \phpbb\filesystem\filesystem();
}
public function realpath_resolve_absolute_without_symlinks_data()
public static function realpath_resolve_absolute_without_symlinks_data()
{
return array(
// Constant data
@@ -49,7 +49,7 @@ class phpbb_filesystem_realpath_test extends phpbb_test_case
);
}
public function realpath_resolve_relative_without_symlinks_data()
public static function realpath_resolve_relative_without_symlinks_data()
{
if (!function_exists('getcwd'))
{

View File

@@ -65,7 +65,7 @@ class phpbb_functional_acp_bbcodes_test extends phpbb_functional_test_case
$this->assertStringContainsString($error, $text);
}
public function get_bbcode_error_tests()
public static function get_bbcode_error_tests()
{
return [
[

View File

@@ -25,7 +25,7 @@ class phpbb_functional_acp_groups_test extends phpbb_functional_common_groups_te
return 'adm/index.php?i=groups&mode=manage&action=edit';
}
public function acp_group_test_data()
public static function acp_group_test_data()
{
return array(
'both_yes' => array(

View File

@@ -48,7 +48,7 @@ class phpbb_functional_acp_permissions_test extends phpbb_functional_test_case
$this->assertStringContainsString($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text());
}
public function permissions_data()
public static function permissions_data()
{
return array(
// description

View File

@@ -25,7 +25,7 @@ class phpbb_functional_acp_profile_field_test extends phpbb_functional_test_case
$this->add_lang('acp/profile');
}
public function data_add_profile_field()
public static function data_add_profile_field()
{
return array(
array('profilefields.type.bool',

View File

@@ -23,7 +23,7 @@ class phpbb_functional_avatar_acp_groups_test extends phpbb_functional_common_av
return 'adm/index.php?i=acp_groups&mode=manage&action=edit&g=5';
}
public function avatar_acp_groups_data()
public static function avatar_acp_groups_data()
{
return array(
// Correct Gravatar

View File

@@ -23,7 +23,7 @@ class phpbb_functional_avatar_acp_users_test extends phpbb_functional_common_ava
return 'adm/index.php?i=acp_users&u=2&mode=avatar';
}
public function avatar_acp_users_data()
public static function avatar_acp_users_data()
{
return array(
// Gravatar with incorrect email

View File

@@ -22,7 +22,7 @@ class phpbb_functional_avatar_ucp_groups_test extends phpbb_functional_common_av
return 'ucp.php?i=ucp_groups&mode=manage&action=edit&g=5';
}
public function avatar_ucp_groups_data()
public static function avatar_ucp_groups_data()
{
return array(
// Gravatar with incorrect email

View File

@@ -23,7 +23,7 @@ class phpbb_functional_avatar_ucp_users_test extends phpbb_functional_common_ava
return 'ucp.php?i=ucp_profile&mode=avatar';
}
public function avatar_ucp_groups_data()
public static function avatar_ucp_groups_data()
{
return array(
// Gravatar with correct settings

View File

@@ -57,7 +57,7 @@ abstract class phpbb_functional_common_groups_test_case extends phpbb_functional
$this->assertStringContainsString($this->lang('CONFIG_UPDATED'), $crawler->text());
}
public function groups_manage_test_data()
public static function groups_manage_test_data()
{
return array(
array('', 'GROUP_UPDATED'),

View File

@@ -229,6 +229,11 @@ class phpbb_functional_download_test extends phpbb_functional_test_case
if (!empty($data['forums']))
{
array_walk($data['forums'], function(&$value, $key)
{
$value = $this->db->sql_escape($value);
}
);
$sql = 'SELECT *
FROM phpbb_forums
WHERE ' . $this->db->sql_in_set('forum_name', $data['forums']);
@@ -245,6 +250,11 @@ class phpbb_functional_download_test extends phpbb_functional_test_case
if (!empty($data['topics']))
{
array_walk($data['topics'], function(&$value, $key)
{
$value = $this->db->sql_escape($value);
}
);
$sql = 'SELECT *
FROM phpbb_topics
WHERE ' . $this->db->sql_in_set('topic_title', $data['topics']);
@@ -262,6 +272,11 @@ class phpbb_functional_download_test extends phpbb_functional_test_case
$post_ids = array();
if (!empty($data['posts']))
{
array_walk($data['posts'], function(&$value, $key)
{
$value = $this->db->sql_escape($value);
}
);
$sql = 'SELECT *
FROM phpbb_posts
WHERE ' . $this->db->sql_in_set('post_subject', $data['posts']);
@@ -276,7 +291,7 @@ class phpbb_functional_download_test extends phpbb_functional_test_case
}
$this->db->sql_freeresult($result);
if (isset($data['attachments']))
if (isset($data['attachments']) && !empty($post_ids))
{
$sql = 'SELECT *
FROM phpbb_attachments

View File

@@ -23,16 +23,10 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case
protected function setUp(): void
{
parent::setUp();
$this->purge_cache();
}
public function __construct($name = null, array $data = array(), $dataName = '')
{
parent::__construct($name, $data, $dataName);
$this->backupStaticAttributesExcludeList += [
$this->setBackupStaticPropertiesExcludeList([
'phpbb_functional_feed_test' => ['init_values'],
];
]);
$this->purge_cache();
}

View File

@@ -34,7 +34,7 @@ class phpbb_functional_forum_password_test extends phpbb_functional_test_case
$crawler = self::submit($form);
}
public function data_enter_forum_with_password()
public static function data_enter_forum_with_password()
{
return array(
array('foowrong', 'WRONG_PASSWORD'),

View File

@@ -16,6 +16,8 @@
*/
class phpbb_functional_jumpbox_test extends phpbb_functional_test_case
{
protected $crawler;
public function test_jumpbox()
{
$this->login();

View File

@@ -72,7 +72,7 @@ class phpbb_functional_mcp_main_test extends phpbb_functional_test_case
return $post;
}
public function mcp_view_forum_actions_data()
public static function mcp_view_forum_actions_data()
{
// action, success message, require_confirmation
return [
@@ -181,7 +181,7 @@ class phpbb_functional_mcp_main_test extends phpbb_functional_test_case
$this->assertStringContainsString($this->lang('TOPICS_DELETED_SUCCESS'), $crawler->filter('#message p')->text());
}
public function mcp_view_topic_actions_data()
public static function mcp_view_topic_actions_data()
{
// action, success message, require_confirmation
return [

View File

@@ -16,7 +16,7 @@
*/
class functional_permission_roles_test extends phpbb_functional_test_case
{
public function data_permission_roles()
public static function data_permission_roles()
{
return array(
array(

View File

@@ -60,7 +60,7 @@ class phpbb_functional_plupload_test extends phpbb_functional_test_case
}
}
public function get_urls()
public static function get_urls()
{
return array(
array('posting.php?mode=reply&t=1'),

View File

@@ -301,7 +301,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
);
}
public function nonexistent_post_id_data()
public static function nonexistent_post_id_data()
{
$nonexistent_post_id = 999999; // Random value
return [

View File

@@ -18,13 +18,13 @@ class phpbb_functional_ucp_allow_pm_test extends phpbb_functional_test_case
{
protected static $data = array();
public function __construct()
protected function setUp(): void
{
parent::__construct();
parent::setUp();
$this->backupStaticAttributesExcludeList += [
$this->setBackupStaticPropertiesExcludeList([
'phpbb_functional_ucp_allow_pm_test' => ['data'],
];
]);
}
// user A sends a PM to user B where B accepts PM

View File

@@ -102,7 +102,7 @@ class phpbb_functional_user_password_reset_test extends phpbb_functional_test_ca
$this->login(self::TEST_USER);
}
public function data_reset_user_password()
public static function data_reset_user_password()
{
return [
['RESET_TOKEN_EXPIRED_OR_INVALID', 0, 'abcdef'],

View File

@@ -14,7 +14,7 @@
/**
* @group functional
*/
class phpbb_functional_visibility_unapproved_test extends phpbb_functional_test_case
class phpbb_functional_visibility_unapproved_posts_test extends phpbb_functional_test_case
{
protected $data = [];

View File

@@ -15,13 +15,16 @@ class phpbb_build_url_test extends phpbb_test_case
{
protected function setUp(): void
{
global $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpbb_path_helper;
global $user, $phpbb_dispatcher, $phpbb_container, $phpbb_root_path, $phpbb_path_helper, $config;
parent::setUp();
$phpbb_container = new phpbb_mock_container_builder();
$user = new phpbb_mock_user();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$config = new \phpbb\config\config([
'enable_mod_rewrite' => 0,
]);
$phpbb_path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
@@ -33,7 +36,7 @@ class phpbb_build_url_test extends phpbb_test_case
);
$phpbb_container->set('path_helper', $phpbb_path_helper);
}
public function build_url_test_data()
public static function build_url_test_data()
{
return array(
array(
@@ -79,8 +82,9 @@ class phpbb_build_url_test extends phpbb_test_case
*/
public function test_build_url($page, $strip_vars, $expected)
{
global $user;
global $config, $user, $phpbb_path_helper, $phpbb_dispatcher, $_SID;
$_SID = '';
$user->page['page'] = $page;
$output = build_url($strip_vars);

View File

@@ -13,7 +13,7 @@
class phpbb_convert_30_dbms_to_31_test extends phpbb_test_case
{
public function convert_30_dbms_to_31_data()
public static function convert_30_dbms_to_31_data()
{
return array(
array('mssql_odbc'),

View File

@@ -29,7 +29,7 @@ class phpbb_generate_string_list_test extends phpbb_test_case
$this->user->add_lang('common');
}
public function generate_string_list_data()
public static function generate_string_list_data()
{
return array(
array(

View File

@@ -13,7 +13,7 @@
class phpbb_get_formatted_filesize_test extends phpbb_test_case
{
public function get_formatted_filesize_test_data()
public static function get_formatted_filesize_test_data()
{
return array(
// exact powers of 2

View File

@@ -13,7 +13,7 @@
class phpbb_functions_get_preg_expression_test extends phpbb_test_case
{
public function data_path_remove_dot_trailing_slash()
public static function data_path_remove_dot_trailing_slash()
{
return array(
array('./../', '$2', '/..'),

View File

@@ -17,7 +17,11 @@ class phpbb_functions_make_clickable_email_test extends phpbb_test_case
{
parent::setUp();
global $user, $request, $symfony_request;
global $user, $request, $symfony_request, $config;
$config = new \phpbb\config\config([
'force_server_vars' => 0,
'server_name' => 'testhost',
]);
$user = new phpbb_mock_user();
$request = new phpbb_mock_request();
$symfony_request = new \phpbb\symfony_request($request);
@@ -26,7 +30,7 @@ class phpbb_functions_make_clickable_email_test extends phpbb_test_case
/**
* 'e' tag for email addresses html
**/
public function data_test_make_clickable_email_positive()
public static function data_test_make_clickable_email_positive()
{
return array(
array(
@@ -147,7 +151,7 @@ class phpbb_functions_make_clickable_email_test extends phpbb_test_case
);
}
public function data_test_make_clickable_email_negative()
public static function data_test_make_clickable_email_negative()
{
return array(
array('foo.example.com'), // @ is missing
@@ -206,6 +210,7 @@ class phpbb_functions_make_clickable_email_test extends phpbb_test_case
*/
public function test_email_matching_positive($email, $expected)
{
global $config, $user, $request, $symfony_request;
$this->assertSame($expected, make_clickable($email));
}
@@ -214,6 +219,7 @@ class phpbb_functions_make_clickable_email_test extends phpbb_test_case
*/
public function test_email_matching_negative($email, $expected = null)
{
global $config, $user, $request, $symfony_request;
$expected = ($expected) ?: $email;
$this->assertSame($expected, make_clickable($email));
}

View File

@@ -25,7 +25,7 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case
* "postlink" for the rest of URLs
* empty for email addresses
**/
public function data_test_make_clickable_url_positive()
public static function data_test_make_clickable_url_positive()
{
return [
[
@@ -82,7 +82,7 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case
];
}
public function data_test_make_clickable_url_idn()
public static function data_test_make_clickable_url_idn()
{
return [
[
@@ -135,7 +135,7 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case
];
}
public function data_test_make_clickable_local_url_idn()
public static function data_test_make_clickable_local_url_idn()
{
return [
[
@@ -154,7 +154,7 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case
];
}
public function data_test_make_clickable_custom_classes()
public static function data_test_make_clickable_custom_classes()
{
return [
[
@@ -200,7 +200,11 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case
{
parent::setUp();
global $user, $request, $symfony_request;
global $user, $request, $symfony_request, $config;
$config = new \phpbb\config\config([
'force_server_vars' => 0,
'server_name' => 'testhost',
]);
$user = new phpbb_mock_user();
$request = new phpbb_mock_request();
$symfony_request = new \phpbb\symfony_request($request);
@@ -212,6 +216,7 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case
*/
public function test_urls_matching_positive($url, $expected)
{
global $user, $request, $symfony_request, $config;
$this->assertSame($expected, make_clickable($url));
}
@@ -220,6 +225,7 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case
*/
public function test_local_urls_matching_idn($url, $expected)
{
global $user, $request, $symfony_request, $config;
$this->assertSame($expected, make_clickable($url, "http://www.домен.рф"));
}
@@ -228,6 +234,7 @@ class phpbb_functions_make_clickable_test extends phpbb_test_case
*/
public function test_make_clickable_custom_classes($url, $server_url, $class, $expected)
{
global $user, $request, $symfony_request, $config;
$this->assertSame($expected, make_clickable($url, $server_url, $class));
}
}

View File

@@ -33,7 +33,7 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case
);
}
static public function obtain_guest_count_data()
public static function obtain_guest_count_data()
{
return array(
array(0, 2),
@@ -53,7 +53,7 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case
$this->assertEquals($expected, obtain_guest_count($forum_id));
}
static public function obtain_users_online_data()
public static function obtain_users_online_data()
{
return array(
array(0, false, array(
@@ -123,7 +123,7 @@ class phpbb_functions_obtain_online_test extends phpbb_database_test_case
$this->assertEquals($expected, obtain_users_online($forum_id));
}
static public function obtain_users_online_string_data()
public static function obtain_users_online_string_data()
{
return array(
array(0, false, array(

View File

@@ -11,9 +11,9 @@
*
*/
class phpbb_functions_parse_cfg_file extends phpbb_test_case
class phpbb_functions_parse_cfg_file_test extends phpbb_test_case
{
public function parse_cfg_file_data()
public static function parse_cfg_file_data()
{
return array(
array(

View File

@@ -61,7 +61,7 @@ class phpbb_get_banned_user_ids_test extends phpbb_database_test_case
$phpbb_container->set('ban.manager', $ban_manager);
}
public function phpbb_get_banned_user_ids_data()
public static function phpbb_get_banned_user_ids_data()
{
return array(
// Input to phpbb_get_banned_user_ids (user_id list, ban_end)

View File

@@ -13,7 +13,7 @@
class phpbb_get_install_redirect_test extends phpbb_test_case
{
public function data_redirect(): array
public static function data_redirect(): array
{
return [
[

View File

@@ -13,7 +13,7 @@
class phpbb_quoteattr_test extends phpbb_test_case
{
public function quoteattr_test_data()
public static function quoteattr_test_data()
{
return array(
array('foo', null, '"foo"'),

View File

@@ -13,7 +13,7 @@
class short_ipv6__test extends phpbb_test_case
{
public function data_short_ipv6(): array
public static function data_short_ipv6(): array
{
return [
['::1', 0, ''],

View File

@@ -18,7 +18,7 @@ class phpbb_functions_style_select_test extends phpbb_database_test_case
return $this->createXMLDataSet(__DIR__.'/fixtures/style_select.xml');
}
static public function style_select_data()
public static function style_select_data()
{
return [
[

Some files were not shown because too many files have changed in this diff Show More