1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-18 22:41:28 +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

@@ -21,7 +21,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
{
/** @var phpbb_notification_manager_helper */
protected $notifications;
protected $db, $container, $user, $config, $auth, $cache;
protected $db, $container, $user, $config, $auth, $cache, $user_loader, $phpbb_dispatcher;
protected function get_notification_types()
{

View File

@@ -14,7 +14,9 @@ require_once __DIR__ . '/../mock/sql_insert_buffer.php';
class phpbb_notification_convert_test extends phpbb_database_test_case
{
protected $notifications, $db, $doctrine_db, $container, $user, $config, $auth, $cache;
protected $db;
protected $doctrine_db;
protected $migration;
public function getDataSet()
{

View File

@@ -120,7 +120,7 @@ class notification_method_email_test extends phpbb_tests_notification_base
$phpbb_container->getParameter('tables.notification_emails'),
$phpbb_container->get('messenger.method_collection')
])
->setMethods(['notify_using_messenger'])
->onlyMethods(['notify_using_messenger'])
->getMock();
$notification_method_email = $this->notification_method_email;
@@ -178,7 +178,7 @@ class notification_method_email_test extends phpbb_tests_notification_base
$this->notifications->set_var('notification_methods', $methods);
}
public function data_notification_email()
public static function data_notification_email()
{
return [
/**

View File

@@ -231,7 +231,7 @@ class notification_method_webpush_test extends phpbb_tests_notification_base
$this->notifications->set_var('notification_methods', $methods);
}
public function data_notification_webpush()
public static function data_notification_webpush()
{
return [
/**
@@ -656,7 +656,7 @@ class notification_method_webpush_test extends phpbb_tests_notification_base
$this->assertCount(0, $cur_notifications, 'Assert that no notifications have been pruned');
}
public function data_set_endpoint_padding(): array
public static function data_set_endpoint_padding(): array
{
return [
[

View File

@@ -19,8 +19,7 @@ require_once __DIR__ . '/../../phpBB/includes/functions_posting.php';
abstract class phpbb_notification_submit_post_base extends phpbb_database_test_case
{
protected $notifications, $db, $container, $user, $config, $auth, $cache;
protected $db;
protected $item_type = '';
protected $poll_data = array();
@@ -52,9 +51,9 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
protected function setUp(): void
{
parent::setUp();
global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $lang, $user, $request, $phpEx, $phpbb_root_path, $user_loader, $phpbb_log;
global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $lang, $user, $request, $phpEx, $phpbb_root_path, $user_loader;
parent::setUp();
// Database
$this->db = $this->new_dbal();
@@ -103,15 +102,15 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
$storage = $this->createMock('\phpbb\storage\storage');
// User
$user = $this->createMock('\phpbb\user');
$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->ip = '';
$user->data = array(
'user_id' => 2,
'username' => 'user-name',
'is_registered' => true,
'user_colour' => '',
'user_lastmark' => 0,
);
$user->data['user_id'] = 2;
$user->data['username'] = 'user-name';
$user->data['is_registered'] = true;
$user->data['user_colour'] = '';
$user->data['user_lastmark'] = 0;
// Request
$request = new phpbb_mock_request();
@@ -122,6 +121,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$user_loader = new \phpbb\user_loader($avatar_helper, $db, $phpbb_root_path, $phpEx, USERS_TABLE);
$phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
// Container
$phpbb_container = new ContainerBuilder();
@@ -190,6 +190,14 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
*/
public function test_submit_post($additional_post_data, $expected_before, $expected_after)
{
global $db, $auth, $user, $config, $phpEx, $phpbb_root_path, $phpbb_container, $phpbb_dispatcher, $phpbb_log, $request;
if (isset($additional_post_data['message']))
{
$parser = $this->get_test_case_helpers()->set_s9e_services($phpbb_container)->get('text_formatter.parser');
$additional_post_data['message'] = $parser->parse($additional_post_data['message']);
}
$sql = 'SELECT user_id, item_id, item_parent_id
FROM ' . NOTIFICATIONS_TABLE . ' n, ' . NOTIFICATION_TYPES_TABLE . " nt
WHERE nt.notification_type_name = '" . $this->item_type . "'

View File

@@ -19,6 +19,8 @@ class phpbb_notification_submit_post_type_bookmark_test extends phpbb_notificati
protected function setUp(): void
{
global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $lang, $user, $request, $phpEx, $phpbb_root_path, $user_loader, $phpbb_log;
parent::setUp();
global $auth;
@@ -49,7 +51,7 @@ class phpbb_notification_submit_post_type_bookmark_test extends phpbb_notificati
* submit_post() $mode = 'reply'
* Notification item_type = 'bookmark'
*/
public function submit_post_data()
public static function submit_post_data()
{
return array(
/**

View File

@@ -19,6 +19,8 @@ class phpbb_notification_submit_post_type_forum_test extends phpbb_notification_
public function setUp(): void
{
global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $lang, $user, $request, $phpEx, $phpbb_root_path, $user_loader, $phpbb_log;
parent::setUp();
global $auth;
@@ -59,7 +61,7 @@ class phpbb_notification_submit_post_type_forum_test extends phpbb_notification_
* submit_post() $mode = 'reply'
* Notification item_type = 'notification.type.forum'
*/
public function submit_post_data()
public static function submit_post_data()
{
return array(
/**

View File

@@ -11,7 +11,7 @@
*
*/
require_once dirname(__FILE__) . '/submit_post_base.php';
require_once __DIR__ . '/submit_post_base.php';
class phpbb_notification_submit_post_type_mention_test extends phpbb_notification_submit_post_base
{
@@ -19,9 +19,9 @@ class phpbb_notification_submit_post_type_mention_test extends phpbb_notificatio
public function setUp(): void
{
parent::setUp();
global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $lang, $user, $request, $phpEx, $phpbb_root_path, $user_loader, $phpbb_log;
global $auth;
parent::setUp();
// Add additional permissions
$auth->expects($this->any())
@@ -53,11 +53,8 @@ class phpbb_notification_submit_post_type_mention_test extends phpbb_notificatio
* submit_post() $mode = 'reply'
* Notification item_type = 'mention'
*/
public function submit_post_data()
public static function submit_post_data()
{
// The new mock container is needed because the data providers may be executed before phpunit call setUp()
$parser = $this->get_test_case_helpers()->set_s9e_services(new phpbb_mock_container_builder())->get('text_formatter.parser');
return array(
/**
* Normal post
@@ -73,7 +70,7 @@ class phpbb_notification_submit_post_type_mention_test extends phpbb_notificatio
*/
array(
array(
'message' => $parser->parse(implode(' ', array(
'message' => implode(' ', array(
'[mention=u:2]poster[/mention] poster should not be notified',
'[mention=u:3]test[/mention] test should be notified',
'[mention=u:4]unauthorized[/mention] unauthorized to read, should not receive a notification',
@@ -83,7 +80,7 @@ class phpbb_notification_submit_post_type_mention_test extends phpbb_notificatio
'[mention=g:1]normal group[/mention] group members of a normal group shoud receive a notification',
'[mention=g:2]hidden group[/mention] group members of a hidden group shoud not receive a notification from a non-member',
'[mention=u:10]doesn\'t exist[/mention] user does not exist, should not receive a notification',
))),
)),
'bbcode_uid' => 'uid',
),
array(
@@ -105,7 +102,7 @@ class phpbb_notification_submit_post_type_mention_test extends phpbb_notificatio
*/
array(
array(
'message' => $parser->parse(implode(' ', array(
'message' => implode(' ', array(
'[mention=u:2]poster[/mention] poster should not be notified',
'[mention=u:3]test[/mention] test should be notified',
'[mention=u:4]unauthorized[/mention] unauthorized to read, should not receive a notification',
@@ -113,7 +110,7 @@ class phpbb_notification_submit_post_type_mention_test extends phpbb_notificatio
'[mention=u:6]disabled[/mention] option disabled, should not receive a notification',
'[mention=u:7]default[/mention] option set to default, should receive a notification',
'[mention=u:8]doesn\'t exist[/mention] user does not exist, should not receive a notification',
))),
)),
'bbcode_uid' => 'uid',
'force_approved_state' => false,
),

View File

@@ -19,6 +19,8 @@ class phpbb_notification_submit_post_type_post_in_queue_test extends phpbb_notif
protected function setUp(): void
{
global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $lang, $user, $request, $phpEx, $phpbb_root_path, $user_loader, $phpbb_log;
parent::setUp();
global $auth;
@@ -62,7 +64,7 @@ class phpbb_notification_submit_post_type_post_in_queue_test extends phpbb_notif
* submit_post() $mode = 'reply'
* Notification item_type = 'post_in_queue'
*/
public function submit_post_data()
public static function submit_post_data()
{
return array(
/**

View File

@@ -19,6 +19,8 @@ class phpbb_notification_submit_post_type_post_test extends phpbb_notification_s
protected function setUp(): void
{
global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $lang, $user, $request, $phpEx, $phpbb_root_path, $user_loader, $phpbb_log;
parent::setUp();
global $auth;
@@ -59,7 +61,7 @@ class phpbb_notification_submit_post_type_post_test extends phpbb_notification_s
* submit_post() $mode = 'reply'
* Notification item_type = 'post'
*/
public function submit_post_data()
public static function submit_post_data()
{
return array(
/**

View File

@@ -19,6 +19,8 @@ class phpbb_notification_submit_post_type_quote_test extends phpbb_notification_
protected function setUp(): void
{
global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $lang, $user, $request, $phpEx, $phpbb_root_path, $user_loader, $phpbb_log;
parent::setUp();
global $auth;
@@ -49,11 +51,8 @@ class phpbb_notification_submit_post_type_quote_test extends phpbb_notification_
* submit_post() $mode = 'reply'
* Notification item_type = 'quote'
*/
public function submit_post_data()
public static function submit_post_data()
{
// The new mock container is needed because the data providers may be executed before phpunit call setUp()
$parser = $this->get_test_case_helpers()->set_s9e_services(new phpbb_mock_container_builder())->get('text_formatter.parser');
return array(
/**
* Normal post
@@ -68,7 +67,7 @@ class phpbb_notification_submit_post_type_quote_test extends phpbb_notification_
*/
array(
array(
'message' => $parser->parse(implode(' ', array(
'message' => implode(' ', array(
'[quote="poster"]poster should not be notified[/quote]',
'[quote="test"]test should be notified[/quote]',
'[quote="unauthorized"]unauthorized to read, should not receive a notification[/quote]',
@@ -76,7 +75,7 @@ class phpbb_notification_submit_post_type_quote_test extends phpbb_notification_
'[quote="disabled"]option disabled, should not receive a notification[/quote]',
'[quote="default"]option set to default, should receive a notification[/quote]',
'[quote="doesn\'t exist"]user does not exist, should not receive a notification[/quote]',
))),
)),
'bbcode_uid' => 'uid',
),
array(
@@ -97,7 +96,7 @@ class phpbb_notification_submit_post_type_quote_test extends phpbb_notification_
*/
array(
array(
'message' => $parser->parse(implode(' ', array(
'message' => implode(' ', array(
'[quote="poster"]poster should not be notified[/quote]',
'[quote="test"]test should be notified[/quote]',
'[quote="unauthorized"]unauthorized to read, should not receive a notification[/quote]',
@@ -105,7 +104,7 @@ class phpbb_notification_submit_post_type_quote_test extends phpbb_notification_
'[quote="disabled"]option disabled, should not receive a notification[/quote]',
'[quote="default"]option set to default, should receive a notification[/quote]',
'[quote="doesn\'t exist"]user does not exist, should not receive a notification[/quote]',
))),
)),
'bbcode_uid' => 'uid',
'force_approved_state' => false,
),

View File

@@ -19,9 +19,9 @@ class phpbb_notification_submit_post_type_topic_test extends phpbb_notification_
protected function setUp(): void
{
parent::setUp();
global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $lang, $user, $request, $phpEx, $phpbb_root_path, $user_loader, $phpbb_log;
global $auth, $phpbb_log;
parent::setUp();
// Add additional permissions
$auth->expects($this->any())
@@ -41,8 +41,6 @@ class phpbb_notification_submit_post_type_topic_test extends phpbb_notification_
),
),
)));
$phpbb_log = $this->createMock('\phpbb\log\dummy');
}
/**
@@ -51,7 +49,7 @@ class phpbb_notification_submit_post_type_topic_test extends phpbb_notification_
* submit_post() $mode = 'post'
* Notification item_type = 'topic'
*/
public function submit_post_data()
public static function submit_post_data()
{
return array(
/**
@@ -97,6 +95,8 @@ class phpbb_notification_submit_post_type_topic_test extends phpbb_notification_
*/
public function test_submit_post($additional_post_data, $expected_before, $expected_after)
{
global $auth, $cache, $config, $db, $phpbb_container, $phpbb_dispatcher, $lang, $user, $request, $phpEx, $phpbb_root_path, $user_loader, $phpbb_log;
$sql = 'SELECT user_id, item_id, item_parent_id
FROM ' . NOTIFICATIONS_TABLE . ' n, ' . NOTIFICATION_TYPES_TABLE . " nt
WHERE nt.notification_type_name = '" . $this->item_type . "'

View File

@@ -70,7 +70,7 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case
);
}
public function user_list_trim_data()
public static function user_list_trim_data()
{
return array(
array(