1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-04-14 04:42:04 +02:00

[ticket/16549] Fix tests

PHPBB3-16549
This commit is contained in:
rxu 2020-08-10 15:02:25 +07:00
parent 342301a1fc
commit 3df19411b4
No known key found for this signature in database
GPG Key ID: 955F0567380E586A
43 changed files with 351 additions and 54 deletions

View File

@ -144,6 +144,7 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
$this->phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$this->temp = new \phpbb\filesystem\temp($this->filesystem, '');
$this->user = new \phpbb\user($this->language, '\phpbb\datetime');
$this->user->data['user_id'] = ANONYMOUS;
$this->upload = new \phpbb\attachment\upload(
$this->auth,
@ -187,7 +188,14 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
)
),
array('foobar', 1, true,
array(),
// Instead of setting to false or empty array, set default filedata array
// as otherwise it throws PHP undefined array key warnings
// in different file upload related services
array(
'realname' => null,
'type' => null,
'size' => null,
),
array(
'error' => array(
'NOT_UPLOADED',
@ -250,7 +258,16 @@ class phpbb_attachment_upload_test extends \phpbb_database_test_case
$this->user
);
$filedata = $this->upload->upload('foobar', 1, true);
// Instead of setting to false or empty array, set default filedata array
// as otherwise it throws PHP undefined array key warnings
// in different file upload related services
$filedata = $this->upload->upload('foobar', 1, true, '', false,
[
'realname' => null,
'type' => null,
'size' => null,
]
);
$this->assertSame(array(
'error' => array(),

View File

@ -330,7 +330,9 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
'avatar_type' => '',
'avatar_width' => 0,
'avatar_height' => 0,
), 1, array(
),
array(
'id' => 1,
'avatar' => 'foobar@example.com',
'avatar_type' => 'avatar.driver.gravatar',
'avatar_width' => '16',
@ -343,7 +345,9 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
'avatar_type' => '',
'avatar_width' => 0,
'avatar_height' => 0,
), 5, array(
),
array(
'id' => 5,
'avatar' => 'g5_1414350991.jpg',
'avatar_type' => 'avatar.driver.upload',
'avatar_width' => '80',
@ -356,13 +360,13 @@ class phpbb_avatar_manager_test extends \phpbb_database_test_case
/**
* @dataProvider data_handle_avatar_delete
*/
public function test_handle_avatar_delete($expected, $id, $avatar_data, $table, $prefix)
public function test_handle_avatar_delete($expected, $avatar_data, $table, $prefix)
{
$this->config['allow_avatar_gravatar'] = true;
$this->assertNull($this->manager->handle_avatar_delete($this->db, $this->user, $avatar_data, $table, $prefix));
$sql = 'SELECT * FROM ' . $table . '
WHERE ' . $prefix . 'id = ' . $id;
WHERE ' . $prefix . 'id = ' . (int) $avatar_data['id'];
$result = $this->db->sql_query_limit($sql, 1);
$row = $this->manager->clean_row($this->db->sql_fetchrow($result), substr($prefix, 0, -1));

View File

@ -31,7 +31,7 @@ class phpbb_cache_memory extends \phpbb\cache\driver\memory
*/
function _read($var)
{
return $this->data[$var];
return $this->data[$var] ?? false;
}
/**

View File

@ -123,7 +123,7 @@ class phpbb_cache_memory_test extends phpbb_database_test_case
foreach ($sql_queries as $query)
{
$this->assertNotEquals(false, $this->cache->sql_load($query[0]));
$this->assertFalse($this->cache->sql_load($query[0]));
}
}
}

View File

@ -62,7 +62,12 @@ abstract class phpbb_console_user_base extends phpbb_database_test_case
$this->language->expects($this->any())
->method('lang')
->will($this->returnArgument(0));
$user = $this->user = $this->createMock('\phpbb\user');
$user = $this->user = $this->createMock('\phpbb\user', array(), array(
$this->language,
'\phpbb\datetime'
));
$user->data['user_email'] = '';
$this->user_loader = new \phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE);

View File

@ -311,6 +311,8 @@ class phpbb_content_visibility_delete_post_test extends phpbb_database_test_case
$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->data['user_id'] = ANONYMOUS;
$attachment_delete = new \phpbb\attachment\delete($config, $db, new \phpbb_mock_event_dispatcher(), new \phpbb\attachment\resync($db), $storage);
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();

View File

@ -425,7 +425,7 @@ class phpbb_dbal_db_tools_test extends phpbb_database_test_case
public function test_create_int_default_null()
{
$this->assertFalse($this->tools->sql_column_exists('prefix_table_name', 'c_bug_13282'));
$this->assertTrue($this->tools->sql_column_add('prefix_table_name', 'c_bug_13282', array('TINT:2')));
$this->assertTrue($this->tools->sql_column_add('prefix_table_name', 'c_bug_13282', array('TINT:2', null)));
$this->assertTrue($this->tools->sql_column_exists('prefix_table_name', 'c_bug_13282'));
}

View File

@ -52,6 +52,7 @@ class phpbb_email_parsing_test extends phpbb_test_case
$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->data['user_lang'] = 'en';
$phpbb_container->set('user', $user);
$extension_manager = new phpbb_mock_extension_manager(
dirname(__FILE__) . '/',

View File

@ -51,14 +51,16 @@ class phpbb_error_collector_test extends phpbb_test_case
// Cause a warning
1/0; $line = __LINE__;
// Cause a notice
$array = array(0 => 'value');
$value = $array[1]; $line2 = __LINE__;
// Cause a "Notice: unserialize(): Error at offset 0 of 27 bytes in ..."
// "Undefined array index" used earlier was promoted to warning in PHP 8.0,
// see https://github.com/php/php-src/commit/c48b745f0090c944e77c1fbcfb6c4df3b54356ad
unserialize("obvious non-serialized data"); $line2 = __LINE__;
$collector->uninstall();
// The notice should not be collected
$this->assertEmpty($collector->errors[1]);
$this->assertFalse(isset($collector->errors[1]));
$this->assertEquals(count($collector->errors), 1);
list($errno, $msg_text, $errfile, $errline) = $collector->errors[0];
$error_contents = $collector->format_errors();

View File

@ -102,6 +102,7 @@ class phpbb_files_types_local_test extends phpbb_test_case
array(
'foo',
array(
'realname' => null,
'tmp_name' => 'foo',
'size' => 500,
'type' => 'image/png',
@ -110,13 +111,17 @@ class phpbb_files_types_local_test extends phpbb_test_case
),
array(
'none',
false,
array(
'realname' => null,
'size' => null,
'type' => null,
),
array('PHP_SIZE_OVERRUN'),
),
array(
'tests/upload/fixture/png',
array(
'realname' => 'foo.png',
'realname' => 'foo.png',
'size' => 500,
'type' => 'image/png',
'local_mode' => true,
@ -151,7 +156,6 @@ class phpbb_files_types_local_test extends phpbb_test_case
$upload->set_allowed_extensions(array('png'));
$type_local->set_upload($upload);
$file = $type_local->upload($filename, $upload_ary);
$this->assertSame($expected, $file->error);
$this->assertInstanceOf('\phpbb\files\filespec', $file);

View File

@ -117,8 +117,10 @@ class phpbb_functional_acp_groups_test extends phpbb_functional_common_groups_te
else
{
$this->form_data = $form->getValues();
$this->assertEquals($tick_legend, $this->form_data['group_legend']);
$this->assertEquals($tick_teampage, $this->form_data['group_teampage']);
// form_data[] values can be bool or null if not ticked, $tick_* value can be bool or null if not set.
// Cast both to the same type to correctly compare the values.
$this->assertEquals((bool) $tick_legend, (bool) ($this->form_data['group_legend'] ?? false));
$this->assertEquals((bool) $tick_teampage, (bool) ($this->form_data['group_teampage'] ?? false));
}
}
}

View File

@ -80,6 +80,6 @@ class phpbb_functional_avatar_acp_groups_test extends phpbb_functional_common_av
$crawler = self::request('GET', $this->get_url() . '&sid=' . $this->sid);
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
$form_data = $form->getValues();
$this->assertEmpty($form_data['avatar_type']);
$this->assertFalse(isset($form_data['avatar_type']));
}
}

View File

@ -39,7 +39,7 @@ class phpbb_functional_smilies_test extends phpbb_functional_test_case
$crawler = self::request('GET', 'posting.php?mode=smilies');
foreach ($smilies as $index => $smiley)
{
$this->assertContains($smiley['smiley_url'],
$this->assertStringContainsString($smiley['smiley_url'],
$crawler->filter('div[class="inner"] > a > img')->eq($index)->attr('src')
);
}

View File

@ -33,6 +33,7 @@ class phpbb_functions_user_delete_test extends phpbb_database_test_case
$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->data['user_id'] = 2;
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$phpbb_container = new phpbb_mock_container_builder();
$config = new \phpbb\config\config(array(

View File

@ -30,7 +30,7 @@ class phpbb_functions_validate_num_test extends phpbb_test_case
$this->helper->assert_valid_data(array(
'empty' => array(
array(),
'',
null, // '' < 0 is true since PHP 8.0, hence use null instead of '' (empty string)
array('num'),
),
'zero' => array(
@ -54,7 +54,7 @@ class phpbb_functions_validate_num_test extends phpbb_test_case
array('num', false, 2, 3),
),
'string' => array(
array(),
version_compare(PHP_VERSION, '7.5', '<=') ? [] : ['TOO_LARGE'], // See https://wiki.php.net/rfc/string_to_number_comparison
'foobar',
array('num'),
),

View File

@ -38,6 +38,7 @@ class phpbb_functions_validate_user_email_test extends phpbb_database_test_case
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$language = new phpbb\language\language(new phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
$this->user = new phpbb\user($language, '\phpbb\datetime');
$this->user->data['user_email'] = '';
$this->helper = new phpbb_functions_validate_data_helper($this);
}

View File

@ -25,6 +25,7 @@ class phpbb_functions_content_phpbb_format_quote_test extends phpbb_test_case
$lang_file_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
$this->lang = new \phpbb\language\language($lang_file_loader);
$user = new \phpbb\user($this->lang, '\phpbb\datetime');
$user->data['user_options'] = 230271;
$cache = new phpbb_mock_cache();
parent::setUp();

View File

@ -74,6 +74,8 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
$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->data['user_id'] = 0;
$user->data['user_type'] = USER_NORMAL;
$this->user = $user;
$this->user_loader = new \phpbb\user_loader($this->db, $phpbb_root_path, $phpEx, 'phpbb_users');
$auth = $this->auth = new phpbb_mock_notifications_auth();

View File

@ -249,7 +249,16 @@ class notification_method_email_test extends phpbb_tests_notification_base
*/
public function test_notification_email($notification_type, $post_data, $expected_users)
{
$post_data = array_merge(['post_time' => 1349413322], $post_data);
$post_data = array_merge([
'post_time' => 1349413322,
'poster_id' => 1,
'topic_title' => '',
'post_subject' => '',
'post_username' => '',
'forum_name' => '',
],
$post_data);
$notification_options = [
'item_id' => $post_data['post_id'],
'item_parent_id' => $post_data['topic_id'],

View File

@ -160,6 +160,8 @@ class phpbb_notification_test extends phpbb_tests_notification_base
'post_subject' => 'Re: test-title',
'forum_id' => 2,
'forum_name' => 'Your first forum',
'post_username' => '',
'post_text' => 'test text',
));
$this->db->sql_query('INSERT INTO ' . BOOKMARKS_TABLE . ' ' . $this->db->sql_build_array('INSERT', array(
@ -176,6 +178,8 @@ class phpbb_notification_test extends phpbb_tests_notification_base
'post_subject' => 'Re: test-title',
'forum_id' => 2,
'forum_name' => 'Your first forum',
'post_username' => '',
'post_text' => 'test text',
));
$this->notifications->delete_subscription('test');
@ -267,6 +271,9 @@ class phpbb_notification_test extends phpbb_tests_notification_base
'post_subject' => 'Re: test-title2', // change post_subject
'forum_id' => 3, // change forum_id
'forum_name' => 'Your second forum', // change forum_name
'post_username' => '',
'post_text' => 'test text2',
'post_time' => 1349413325,
));
$this->assert_notifications(

View File

@ -39,6 +39,9 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
'bbcode_bitfield' => '',
'bbcode_uid' => '',
'post_edit_locked' => false,
'notify_set' => 0,
'notify' => false,
'forum_name' => 'Test forum name',
//'force_approved_state' => 1,
);
@ -102,6 +105,7 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
'username' => 'user-name',
'is_registered' => true,
'user_colour' => '',
'user_lastmark' => 0,
);
// Request

View File

@ -135,9 +135,10 @@ class phpbb_notification_submit_post_type_topic_test extends phpbb_notification_
$this->db->sql_freeresult($result);
$result = $this->db->sql_query(
'SELECT *
FROM ' . POSTS_TABLE . '
WHERE post_id = ' . $reply_id);
'SELECT p.*, t.topic_posts_approved, t.topic_posts_unapproved, t.topic_posts_softdeleted, t.topic_first_post_id, t.topic_last_post_id
FROM ' . POSTS_TABLE . ' p, ' . TOPICS_TABLE . ' t
WHERE p.topic_id = t.topic_id
AND p.post_id = ' . $reply_id);
$reply_edit_data = array_merge($this->post_data, $this->db->sql_fetchrow($result), array(
'force_approved_state' => false,
'post_edit_reason' => 'PHPBB3-12370',

View File

@ -51,7 +51,10 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case
$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->data = array('user_lang' => 'en');
$user->data = [
'user_id' => 1,
'user_lang' => 'en',
];
$lang->add_lang('common');
$user_loader = new phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE);

View File

@ -63,6 +63,8 @@ class manager_test extends phpbb_database_test_case
$language = new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx));
$collection = new \phpbb\di\service_collection($container);
$user = new \phpbb\user($language, '\phpbb\datetime');
$user->data['user_id'] = 2;
$user->ip = '';
$this->log = new \phpbb\log\log($this->db, $user, $auth, $dispatcher, $phpbb_root_path, 'adm/', $phpEx, $table_prefix . 'log');

View File

@ -65,8 +65,10 @@ class phpbb_profilefield_type_bool_test extends phpbb_test_case
'lang_id' => 1,
'lang_name' => 'field',
'field_required' => false,
'field_default_value' => 1,
'field_length' => 1,
'field_default_value' => 1,
'field_length' => 1,
'field_show_novalue' => null,
'field_novalue' => null,
);
$this->options = array(

View File

@ -55,6 +55,8 @@ class phpbb_profilefield_type_date_test extends phpbb_test_case
'lang_id' => 1,
'lang_name' => 'field',
'field_required' => false,
'field_show_novalue' => null,
'field_novalue' => null,
);
}

View File

@ -66,6 +66,7 @@ class phpbb_profilefield_type_dropdown_test extends phpbb_test_case
'field_required' => false,
'field_validation' => '.*',
'field_novalue' => 0,
'field_show_novalue' => null,
);
$this->dropdown_options = array(
@ -153,7 +154,7 @@ class phpbb_profilefield_type_dropdown_test extends phpbb_test_case
'Field should output nothing for empty value',
),
array(
'',
null, // Since PHP 8, '' == 0 returns false, hence use null instead of '' (empty string)
array('field_show_novalue' => false),
null,
'Field should simply output null for empty value',
@ -184,7 +185,7 @@ class phpbb_profilefield_type_dropdown_test extends phpbb_test_case
'Field should return the correct raw value',
),
array(
'',
null, // Since PHP 8, '' == 0 returns false, hence use null instead of '' (empty string)
array('field_show_novalue' => false),
null,
'Field should null for empty value without show_novalue',

View File

@ -44,6 +44,10 @@ class phpbb_profilefield_type_int_test extends phpbb_test_case
'lang_id' => 1,
'lang_name' => 'field',
'field_required' => false,
'field_show_novalue' => null,
'field_novalue' => null,
'field_minlen' => null,
'field_maxlen' => null,
);
}

View File

@ -49,6 +49,10 @@ class phpbb_profilefield_type_string_test extends phpbb_test_case
'lang_name' => 'field',
'field_required' => false,
'field_validation' => '.*',
'field_show_novalue' => null,
'field_novalue' => null,
'field_minlen' => null,
'field_maxlen' => null,
);
}

View File

@ -52,6 +52,10 @@ class phpbb_profilefield_type_url_test extends phpbb_test_case
'lang_id' => 1,
'lang_name' => 'field',
'field_required' => false,
'field_show_novalue' => null,
'field_novalue' => null,
'field_minlen' => null,
'field_maxlen' => null,
);
}

View File

@ -43,6 +43,16 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case
parent::setUp();
// Get session here so that config is mocked correctly
$this->session = $this->session_factory->get_session($this->db);
$this->session->data['user_id'] = ANONYMOUS; // Don't get into the session_kill() procedure
$this->session->lang = [
'BOARD_BAN_TIME' => 'BOARD_BAN_TIME',
'BOARD_BAN_PERM' => 'BOARD_BAN_PERM',
'BOARD_BAN_REASON' => 'BOARD_BAN_REASON',
'BAN_TRIGGERED_BY_EMAIL' => 'BAN_TRIGGERED_BY_EMAIL',
'BAN_TRIGGERED_BY_IP' => 'BAN_TRIGGERED_BY_IP',
'BAN_TRIGGERED_BY_USER' => 'BAN_TRIGGERED_BY_USER',
];
global $cache, $config, $phpbb_root_path, $phpEx, $phpbb_filesystem;
$phpbb_filesystem = new \phpbb\filesystem\filesystem();

View File

@ -34,6 +34,8 @@ class phpbb_session_login_keys_test extends phpbb_session_test_case
$session->cookie_data['k'] = $this->key_id;
// Try to access session with the session key
global $request, $symfony_request, $phpbb_filesystem, $phpbb_root_path;
$session->page = $session->extract_current_page($phpbb_root_path);
$session->session_create(false, false, false);
$this->assertEquals($this->user_id, $session->data['user_id'], 'User should be logged in by the session key');
}
@ -45,6 +47,8 @@ class phpbb_session_login_keys_test extends phpbb_session_test_case
$session = $this->session_factory->get_session($this->db);
// Reset of the keys for this user
$session->cookie_data['k'] = $this->key_id;
$session->data['user_id'] = $this->user_id;
$session->reset_login_keys($this->user_id);
// Using a user_id and key that was in the database (before reset)
@ -52,6 +56,8 @@ class phpbb_session_login_keys_test extends phpbb_session_test_case
$session->cookie_data['k'] = $this->key_id;
// Try to access session with the session key
global $request, $symfony_request, $phpbb_filesystem, $phpbb_root_path;
$session->page = $session->extract_current_page($phpbb_root_path);
$session->session_create(false, false, $this->user_id);
$this->assertNotEquals($this->user_id, $session->data['user_id'], 'User is not logged in because the session key is invalid');

View File

@ -94,10 +94,12 @@ class phpbb_session_testable_facade
$this->session_factory->merge_config_data($config_overrides);
// Bots
$this->session_factory->merge_cache_data(array('_bots' => $bot_overrides));
global $request;
global $request, $symfony_request, $phpbb_filesystem, $phpbb_root_path;
$session = $this->session_factory->get_session($this->db);
$session->browser = $user_agent;
$session->ip = $ip_address;
$session->page = $session->extract_current_page($phpbb_root_path);
// Uri sid
if ($uri_sid)
{

View File

@ -33,6 +33,8 @@ class phpbb_template_extension_test extends phpbb_template_template_test_case
global $auth, $request, $symfony_request, $user;
$user = new phpbb_mock_user();
$user->optionset('user_id', 2);
$user->style['style_path'] = '';
$user->data['user_id'] = 2;
$auth = $this->getMockBuilder('phpbb\auth\auth')
->disableOriginalConstructor()
->setMethods(['acl_get'])

View File

@ -493,7 +493,8 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(
'loop_expressions.html',
array(),
array('loop' => array(array(),array(),array(),array(),array(),array()),),
// Do not use 'loop' as a block name to not override Twig's internal 'loop' object
array('loop1' => array(array(),array(),array(),array(),array(),array()),),
array(),
'yesnononoyesnoyesnonoyesnono',
),

View File

@ -1,11 +1,11 @@
<!-- BEGIN loop -->
<!-- BEGIN loop1 -->
<!-- IF loop.S_ROW_NUM is divisible by(4) -->yes<!-- ELSE -->no<!-- ENDIF -->
<!-- IF loop1.S_ROW_NUM is divisible by(4) -->yes<!-- ELSE -->no<!-- ENDIF -->
<!-- END loop -->
<!-- END loop1 -->
<!-- BEGIN loop -->
<!-- BEGIN loop1 -->
<!-- IF loop.S_ROW_NUM is divisible by(3) -->yes<!-- ELSE -->no<!-- ENDIF -->
<!-- IF loop1.S_ROW_NUM is divisible by(3) -->yes<!-- ELSE -->no<!-- ENDIF -->
<!-- END loop -->
<!-- END loop1 -->

View File

@ -721,7 +721,14 @@ class phpbb_functional_test_case extends phpbb_test_case
$db = $this->get_db();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$user = $this->createMock('\phpbb\user');
$user = $this->createMock('\phpbb\user', array(), array(
new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
'\phpbb\datetime'
));
$user->data['user_id'] = 2; // admin
$user->ip = '';
$auth = $this->createMock('\phpbb\auth\auth');
$phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
@ -755,7 +762,14 @@ class phpbb_functional_test_case extends phpbb_test_case
$db = $this->get_db();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$user = $this->createMock('\phpbb\user');
$user = $this->createMock('\phpbb\user', array(), array(
new \phpbb\language\language(new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx)),
'\phpbb\datetime'
));
$user->data['user_id'] = 2; // admin
$user->ip = '';
$auth = $this->createMock('\phpbb\auth\auth');
$phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);

View File

@ -531,6 +531,14 @@ class phpbb_test_case_helpers
if ($container->has('user'))
{
$user = $container->get('user');
// Set default required user data if not set
$user->data['is_bot'] = $user->data['is_bot'] ?? false;
$user->data['is_registered'] = $user->data['is_registered'] ?? false;
$user->data['style_id'] = $user->data['style_id'] ?? 1;
$user->data['user_id'] = $user->data['user_id'] ?? ANONYMOUS;
$user->data['user_options'] = $user->data['user_options'] ?? 230271;
$user->style['style_id'] = $user->style['style_id'] ?? 1;
}
else
{
@ -545,6 +553,14 @@ class phpbb_test_case_helpers
->method('format_date')
->will($this->test_case->returnCallback(__CLASS__ . '::format_date'));
// Set default required user data
$user->data['is_bot'] = false;
$user->data['is_registered'] = false;
$user->data['style_id'] = 1;
$user->data['user_id'] = ANONYMOUS;
$user->data['user_options'] = 230271;
$user->style['style_id'] = 1;
$user->date_format = 'Y-m-d H:i:s';
$user->optionset('viewcensors', true);
$user->optionset('viewflash', true);
@ -555,11 +571,6 @@ class phpbb_test_case_helpers
}
$user->add_lang('common');
if (!isset($user->style))
{
$user->style = array('style_id' => 1);
}
// Create and register a quote_helper
$quote_helper = new \phpbb\textformatter\s9e\quote_helper(
$container->get('user'),

View File

@ -61,7 +61,10 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
->getMock();
$factory->expects($this->once())
->method('regenerate')
->will($this->returnValue(array('parser' => $mock)));
->will($this->returnValue([
'parser' => $mock,
'renderer' => $mock,
]));
$renderer = new \phpbb\textformatter\s9e\renderer(
$cache,
@ -160,6 +163,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
$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->data['user_options'] = 230271;
$user->optionset('viewcensors', false);
$phpbb_container->set('user', $user);
@ -175,6 +179,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
$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->data['user_options'] = 230271;
$user->optionset('viewcensors', false);
$config = new \phpbb\config\config(array('allow_nocensors' => true));
@ -193,6 +198,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
$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->data['user_options'] = 230271;
$user->optionset('viewcensors', false);
$config = new \phpbb\config\config(array('allow_nocensors' => true));
@ -222,6 +228,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
$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->data['user_options'] = 230271;
$user->optionset('viewflash', false);
$phpbb_container->set('user', $user);
@ -241,6 +248,7 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
$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->data['user_options'] = 230271;
$user->optionset('viewimg', false);
$phpbb_container->set('user', $user);
@ -260,7 +268,8 @@ class phpbb_textformatter_s9e_renderer_test extends phpbb_test_case
$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->optionset('smilies', false);
$user->data['user_options'] = 230271;
$user->optionset('viewsmilies', false);
$phpbb_container->set('user', $user);
}

View File

@ -37,6 +37,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca
$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->data['user_options'] = 230271;
$user->optionset('viewcensors', true);
$user->optionset('viewflash', true);
$user->optionset('viewimg', true);
@ -72,6 +73,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca
$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->data['user_options'] = 230271;
// Do not ignore word censoring by user (switch censoring on in UCP)
$user->optionset('viewcensors', true);
@ -172,6 +174,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca
$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->data['user_options'] = 230271;
$user->optionset('viewflash', false);
$phpbb_container->set('user', $user);
@ -192,6 +195,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca
$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->data['user_options'] = 230271;
$user->optionset('viewimg', false);
$phpbb_container->set('user', $user);
@ -212,7 +216,8 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca
$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->optionset('smilies', false);
$user->data['user_options'] = 230271;
$user->optionset('viewsmilies', false);
$phpbb_container->set('user', $user);
}

View File

@ -186,7 +186,13 @@ class phpbb_fileupload_test extends phpbb_test_case
->set_max_filesize(1000);
copy($this->path . 'jpg', $this->path . 'jpg.jpg');
$file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg');
// Upload file data should be set to prevent "Undefined array key" PHP 8 warning
$filedata = [
'size' => 519,
'realname' => $this->path . 'jpg.jpg',
'type' => false,
];
$file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg', $filedata);
$this->assertEquals(0, count($file->error));
$this->assertFalse($file->additional_checks());
$this->assertTrue($file->move_file('../tests/upload/fixture/copies', true));
@ -200,7 +206,13 @@ class phpbb_fileupload_test extends phpbb_test_case
->set_max_filesize(1000);
copy($this->path . 'jpg', $this->path . 'jpg.jpg');
$file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg');
// Upload file data should be set to prevent "Undefined array key" PHP 8 warning
$filedata = [
'size' => 519,
'realname' => $this->path . 'jpg.jpg',
'type' => false,
];
$file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg', $filedata);
$this->assertEquals(0, count($file->error));
$this->assertFalse($file->move_file('../tests/upload/fixture'));
$this->assertFalse($file->get('file_moved'));
@ -215,7 +227,13 @@ class phpbb_fileupload_test extends phpbb_test_case
copy($this->path . 'jpg', $this->path . 'jpg.jpg');
copy($this->path . 'jpg', $this->path . 'copies/jpg.jpg');
$file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg');
// Upload file data should be set to prevent "Undefined array key" PHP 8 warning
$filedata = [
'size' => 519,
'realname' => $this->path . 'jpg.jpg',
'type' => false,
];
$file = $upload->handle_upload('files.types.local', $this->path . 'jpg.jpg', $filedata);
$this->assertEquals(0, count($file->error));
$file->move_file('../tests/upload/fixture/copies', true);
$this->assertEquals(0, count($file->error));

View File

@ -353,13 +353,19 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'1.0' => array(
'current' => '1.0.1',
'eol' => false,
'security' => false,
),
'1.1' => array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(
'current' => '1.0.1',
'eol' => false,
'security' => false,
),
),
array(
@ -367,9 +373,13 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'1.0' => array(
'current' => '1.0.1',
'eol' => false,
'security' => false,
),
'1.1' => array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(),
@ -379,13 +389,19 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'1.0' => array(
'current' => '1.0.1-a2',
'eol' => false,
'security' => false,
),
'1.1' => array(
'current' => '1.1.0',
'eol' => false,
'security' => false,
),
),
array(
'current' => '1.0.1-a2',
'eol' => false,
'security' => false,
),
),
array(
@ -393,13 +409,19 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'1.0' => array(
'current' => '1.0.1',
'eol' => false,
'security' => false,
),
'1.1' => array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(
@ -407,9 +429,13 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'1.0' => array(
'current' => '1.0.1',
'eol' => false,
'security' => false,
),
'1.1' => array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(),
@ -419,13 +445,19 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'1.0' => array(
'current' => '1.0.1',
'eol' => false,
'security' => false,
),
'1.1' => array(
'current' => '1.1.0-a2',
'eol' => false,
'security' => false,
),
),
array(
'current' => '1.1.0-a2',
'eol' => false,
'security' => false,
),
),
array(
@ -439,14 +471,18 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'1.0' => array(
'current' => '1.0.1',
'eol' => false,
'security' => '1.0.1',
),
'1.1' => array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(
'current' => '1.0.1',
'eol' => false,
'security' => '1.0.1',
),
),
@ -456,14 +492,18 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'1.0' => array(
'current' => '1.0.1',
'eol' => false,
'security' => '1.0.0',
),
'1.1' => array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(
'current' => '1.0.1',
'eol' => false,
'security' => '1.0.0',
),
),
@ -473,14 +513,19 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'1.0' => array(
'current' => '1.0.1',
'eol' => false,
'security' => '1.1.0',
),
'1.1' => array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
// Latest 1.0 release is EOL
@ -490,13 +535,18 @@ class phpbb_version_helper_test extends phpbb_test_case
'1.0' => array(
'current' => '1.0.1',
'eol' => true,
'security' => false,
),
'1.1' => array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
// All are EOL -- somewhat undefined behavior
@ -506,10 +556,12 @@ class phpbb_version_helper_test extends phpbb_test_case
'1.0' => array(
'current' => '1.0.1',
'eol' => true,
'security' => false,
),
'1.1' => array(
'current' => '1.1.1',
'eol' => true,
'security' => false,
),
),
array(),
@ -560,10 +612,14 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
'eol' => false,
'security' => false,
),
),
array(
'current' => '1.0.1',
'eol' => false,
'security' => false,
),
),
array(
@ -572,6 +628,8 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
'eol' => false,
'security' => false,
),
),
array(),
@ -582,10 +640,14 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.2' => array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(
@ -594,6 +656,8 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.2' => array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(),
@ -605,10 +669,14 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.2' => array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(
@ -617,6 +685,8 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.2' => array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(),
@ -627,10 +697,14 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
'eol' => false,
'security' => false,
),
),
array(
'current' => '1.0.1',
'eol' => false,
'security' => false,
),
),
array(
@ -639,6 +713,8 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
'eol' => false,
'security' => false,
),
),
array(),
@ -649,10 +725,14 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.2' => array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(
@ -661,6 +741,8 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.2' => array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(),
@ -672,13 +754,19 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
'eol' => false,
'security' => false,
),
'3.2' => array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(
'current' => '1.0.1',
'eol' => false,
'security' => false,
),
),
array(
@ -687,9 +775,13 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
'eol' => false,
'security' => false,
),
'3.2' => array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(),
@ -700,9 +792,13 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
'eol' => false,
'security' => false,
),
'3.2' => array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(),
@ -713,13 +809,19 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
'eol' => false,
'security' => false,
),
'3.2' => array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(
@ -728,13 +830,19 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
'eol' => false,
'security' => false,
),
'3.2' => array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(
@ -743,9 +851,13 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
'eol' => false,
'security' => false,
),
'3.2' => array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(),
@ -757,13 +869,19 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
'eol' => false,
'security' => false,
),
'3.2' => array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(
@ -772,13 +890,19 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
'eol' => false,
'security' => false,
),
'3.2' => array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(
@ -787,13 +911,19 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
'eol' => false,
'security' => false,
),
'3.2' => array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(
@ -802,9 +932,13 @@ class phpbb_version_helper_test extends phpbb_test_case
array(
'3.1' => array(
'current' => '1.0.1',
'eol' => false,
'security' => false,
),
'3.2' => array(
'current' => '1.1.1',
'eol' => false,
'security' => false,
),
),
array(),

View File

@ -41,6 +41,6 @@ php ../composer.phar install --dev --no-interaction
if [ "$TRAVIS_PHP_VERSION" == "nightly" ]
then
php ../composer.phar remove phpunit/dbunit --dev --update-with-dependencies \
&& php ../composer.phar require symfony/yaml:~4.4 misantron/dbunit:~5.0 nikic/php-parser:~4.7 phpunit/phpunit:^9.3 --dev --update-with-all-dependencies --ignore-platform-reqs
&& php ../composer.phar require symfony/yaml:~4.4 misantron/dbunit:~5.0 phpunit/phpunit:^9.3 --dev --update-with-all-dependencies --ignore-platform-reqs
fi
cd ..