[ticket/715] Resolve issues with portal and tests on PHP 8.0

B3P-715
This commit is contained in:
Marc Alexander
2021-09-04 11:09:52 +02:00
parent 9eb415b79c
commit ed54e3ef0c
30 changed files with 233 additions and 143 deletions

View File

@@ -40,7 +40,10 @@ class phpbb_unit_modules_birthday_list_test extends \board3\portal\tests\testfra
$this->template = new \board3\portal\tests\mock\template($this);
$this->config = new \phpbb\config\config(array());
$this->language_file_loader = new \phpbb\language\language_file_loader($phpbb_root_path, 'php');
$this->language = new \phpbb\language\language($this->language_file_loader);
$this->language = new \board3\portal\tests\mock\language($this->language_file_loader);
$this->language->set([
'BIRTHDAYS_AHEAD' => 'BIRTHDAYS_AHEAD',
]);
$this->user = new \phpbb\user($this->language, '\phpbb\datetime');
$this->user->timezone = new \DateTimeZone('UTC');
$this->user->add_lang('common');

View File

@@ -38,7 +38,7 @@ class phpbb_unit_modules_calendar_test extends \board3\portal\tests\testframewor
public function setUp(): void
{
parent::setUp();
global $cache, $phpbb_root_path, $phpEx, $phpbb_dispatcher, $request, $user;
global $cache, $config, $phpbb_root_path, $phpEx, $phpbb_dispatcher, $request, $user;
$this->path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
@@ -57,7 +57,10 @@ class phpbb_unit_modules_calendar_test extends \board3\portal\tests\testframewor
->method('trigger_event')
->with($this->anything())
->will($this->returnArgument(1));
self::$config = new \phpbb\config\config(array());
self::$config = new \phpbb\config\config([
'force_server_vars' => false,
]);
$config = self::$config;
\set_config('foobar', false, false, self::$config);
$this->template = new \board3\portal\tests\mock\template($this);
$controller_helper = new \board3\portal\tests\mock\controller_helper($phpbb_root_path, $phpEx);
@@ -65,10 +68,16 @@ class phpbb_unit_modules_calendar_test extends \board3\portal\tests\testframewor
$modules_helper = new \board3\portal\includes\modules_helper(new \phpbb\auth\auth(), new \phpbb\config\config(array()), $controller_helper, new \phpbb_mock_request());
$request = $this->request = new \phpbb_mock_request();
$this->language_file_loader = new \phpbb\language\language_file_loader($phpbb_root_path, 'php');
$this->language = new \phpbb\language\language($this->language_file_loader);
$this->language = new \board3\portal\tests\mock\language($this->language_file_loader);
$this->language->add_lang('common');
$this->language->add_lang_ext('board3/portal', 'modules/portal_calendar_module');
$user = new \phpbb\user($this->language, '\phpbb\datetime');
$user->data = [
'user_id' => 2,
'user_ip' => '127.0.0.1',
'user_dateformat' => 'dmY',
];
$user->timezone = new \DateTimeZone('UTC');
$user->add_lang('common');
$log = $this->getMockBuilder('\phpbb\log')
->setMethods(array('add'))
->disableOriginalConstructor()
@@ -78,8 +87,6 @@ class phpbb_unit_modules_calendar_test extends \board3\portal\tests\testframewor
->with($this->anything())
->will($this->returnValue(true));
$this->calendar = new \board3\portal\modules\calendar(self::$config, $modules_helper, $this->template, $db, $this->request, dirname(__FILE__) . '/../../../', 'php', $user, $this->path_helper, $log);
define('PORTAL_MODULES_TABLE', 'phpbb_portal_modules');
define('PORTAL_CONFIG_TABLE', 'phpbb_portal_config');
$cache = $this->getMockBuilder('\phpbb\cache\driver\dummy')
->setMethods(['destroy', 'sql_exists', 'get', 'put'])
->getMock();
@@ -188,6 +195,7 @@ class phpbb_unit_modules_calendar_test extends \board3\portal\tests\testframewor
public function test_update_events_no_error()
{
set_portal_config('board3_calendar_events_5', '[]');
$this->calendar->update_events('foobar', 5);
$this->assertNull($this->template->get_row('events'));
}

View File

@@ -32,7 +32,7 @@ class phpbb_unit_modules_clock_test extends \board3\portal\tests\testframework\t
public function test_get_template_side()
{
$this->assertSame('clock_side.html', $this->clock->get_template_side(5));
$this->template->assert_same(null, 'B3P_CLOCK_SRC');
$this->template->assert_not_exist( 'B3P_CLOCK_SRC');
$this->config->set('board3_clock_src_5', 'foobar');
$this->assertSame('clock_side.html', $this->clock->get_template_side(5));
$this->template->assert_same('foobar', 'B3P_CLOCK_SRC');

View File

@@ -45,9 +45,10 @@ class phpbb_unit_modules_welcome_test extends \board3\portal\tests\testframework
$request = $this->request;
$this->template = new \board3\portal\tests\mock\template($this);
$this->language_file_loader = new \phpbb\language\language_file_loader($phpbb_root_path, 'php');
$this->language = new \phpbb\language\language($this->language_file_loader);
$this->language = new \board3\portal\tests\mock\language($this->language_file_loader);
$this->user = new \phpbb\user($this->language, '\phpbb\datetime');
$user = $this->user;
$user->data['user_options'] = 0;
$cache = $this->getMockBuilder('\phpbb\cache\driver\dummy')
->setMethods(['destroy', 'sql_exists', 'get', 'put', 'sql_load'])
->getMock();
@@ -172,6 +173,7 @@ class phpbb_unit_modules_welcome_test extends \board3\portal\tests\testframework
public function test_update_welcome()
{
\set_portal_config('board3_welcome_message_' . 5, 'Welcome to my Community!');
$this->welcome->update_welcome('foobar', 5);
$this->template->assert_same(true, 'S_EDIT');
$this->request->overwrite('preview', true, \phpbb\request\request_interface::POST);
@@ -205,7 +207,7 @@ class phpbb_unit_modules_welcome_test extends \board3\portal\tests\testframework
$this->welcome = new \board3\portal\modules\welcome($this->config, $this->request, $this->template, $this->user, '', '');
$this->request->overwrite('submit', true, \phpbb\request\request_interface::POST);
$this->request->overwrite('welcome_message', '');
$this->setExpectedTriggerError(E_USER_WARNING);
$this->setExpectedTriggerError(E_WARNING);
check_form_key::$form_key_valid = true;
$this->welcome->update_welcome('foobar', 5);
}