[ticket/15233] Amend tests for avatar helper

PHPBB3-15233
This commit is contained in:
mrgoldy 2019-12-17 20:28:59 +01:00 committed by Marc Alexander
parent 34aaf5e6d2
commit a9b63a4724
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
9 changed files with 31 additions and 8 deletions

View file

@ -180,7 +180,7 @@ class helper
* Created for Backwards Compatibility (BC).
* Styles should generate their own HTML element instead.
*
* @deprecated 4.0.0
* @deprecated 4.1.0 After admin style is reworked aswell
*
* @param array $data The avatar data array
* @return string The avatar's HTML <img> element

View file

@ -1484,7 +1484,7 @@ while ($row = $db->sql_fetchrow($result))
'viewonline' => $row['user_allow_viewonline'],
'allow_pm' => $row['user_allow_pm'],
'avatar' => ($user->optionget('viewavatars')) ? $this->get_user_avatar($row) : [],
'avatar' => ($user->optionget('viewavatars')) ? $avatar_helper->get_user_avatar($row) : [],
'age' => '',
'rank_title' => '',

View file

@ -69,7 +69,11 @@ abstract class phpbb_console_user_base extends phpbb_database_test_case
));
$user->data['user_email'] = '';
$this->user_loader = new \phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE);
$avatar_helper = $this->getMockBuilder('\phpbb\avatar\helper')
->disableOriginalConstructor()
->getMock();
$this->user_loader = new \phpbb\user_loader($avatar_helper, $db, $phpbb_root_path, $phpEx, USERS_TABLE);
$driver_helper = new \phpbb\passwords\driver\helper($this->config);
$passwords_drivers = array(

View file

@ -113,7 +113,11 @@ class phpbb_group_helper_test_case extends phpbb_test_case
$user = new \phpbb\user($lang, '\phpbb\datetime');
$user->data['user_id'] = ANONYMOUS;
$this->group_helper = new \phpbb\group\helper($auth, $cache_service, $config, $lang, $phpbb_dispatcher, $path_helper, $user);
$avatar_helper = $this->getMockBuilder('\phpbb\avatar\helper')
->disableOriginalConstructor()
->getMock();
$this->group_helper = new \phpbb\group\helper($auth, $avatar_helper, $cache_service, $config, $lang, $phpbb_dispatcher, $path_helper, $user);
}
protected function setUp(): void

View file

@ -63,6 +63,9 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
global $db, $config, $user, $auth, $cache, $phpbb_container;
$avatar_helper = $this->getMockBuilder('\phpbb\avatar\helper')
->disableOriginalConstructor()
->getMock();
$db = $this->db = $this->new_dbal();
$config = $this->config = new \phpbb\config\config(array(
'allow_privmsg' => true,
@ -77,7 +80,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
$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');
$this->user_loader = new \phpbb\user_loader($avatar_helper, $this->db, $phpbb_root_path, $phpEx, 'phpbb_users');
$auth = $this->auth = new phpbb_mock_notifications_auth();
$cache_driver = new \phpbb\cache\driver\dummy();
$cache = $this->cache = new \phpbb\cache\service(

View file

@ -48,6 +48,7 @@ class phpbb_notification_group_request_test extends phpbb_tests_notification_bas
));
$this->container->set('group_helper', new \phpbb\group\helper(
$this->getMockBuilder('\phpbb\auth\auth')->disableOriginalConstructor()->getMock(),
$this->getMockBuilder('\phpbb\avatar\helper')->disableOriginalConstructor()->getMock(),
$this->cache,
$this->config,
new \phpbb\language\language(

View file

@ -112,8 +112,12 @@ abstract class phpbb_notification_submit_post_base extends phpbb_database_test_c
$type_cast_helper = $this->createMock('\phpbb\request\type_cast_helper_interface');
$request = $this->createMock('\phpbb\request\request');
$avatar_helper = $this->getMockBuilder('\phpbb\avatar\helper')
->disableOriginalConstructor()
->getMock();
$phpbb_dispatcher = new phpbb_mock_event_dispatcher();
$user_loader = new \phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE);
$user_loader = new \phpbb\user_loader($avatar_helper, $db, $phpbb_root_path, $phpEx, USERS_TABLE);
// Container
$phpbb_container = new ContainerBuilder();

View file

@ -57,7 +57,11 @@ class phpbb_notification_user_list_trim_test extends phpbb_database_test_case
];
$lang->add_lang('common');
$user_loader = new phpbb\user_loader($db, $phpbb_root_path, $phpEx, USERS_TABLE);
$avatar_helper = $this->getMockBuilder('\phpbb\avatar\helper')
->disableOriginalConstructor()
->getMock();
$user_loader = new phpbb\user_loader($avatar_helper, $db, $phpbb_root_path, $phpEx, USERS_TABLE);
$user_loader->load_users(array(2, 3, 4, 5, 6));
$this->notification = new phpbb_mock_notification_type_post(

View file

@ -25,8 +25,11 @@ class phpbb_user_loader_test extends phpbb_database_test_case
{
parent::setUp();
$avatar_helper = $this->getMockBuilder('\phpbb\avatar\helper')
->disableOriginalConstructor()
->getMock();
$this->db = $this->new_dbal();
$this->user_loader = new \phpbb\user_loader($this->db, __DIR__ . '/../../phpBB/', 'php', 'phpbb_users');
$this->user_loader = new \phpbb\user_loader($avatar_helper, $this->db, __DIR__ . '/../../phpBB/', 'php', 'phpbb_users');
}
public function test_load_get()