mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-07 20:08:53 +00:00
[ticket/17353] Return image src for gravatar image
PHPBB-17353
This commit is contained in:
parent
efece4136b
commit
40881b537e
2 changed files with 25 additions and 10 deletions
|
@ -29,7 +29,7 @@ class gravatar extends \phpbb\avatar\driver\driver
|
|||
public function get_data($row)
|
||||
{
|
||||
return array(
|
||||
'src' => $row['avatar'],
|
||||
'src' => $this->get_gravatar_url($row),
|
||||
'width' => $row['avatar_width'],
|
||||
'height' => $row['avatar_height'],
|
||||
);
|
||||
|
|
|
@ -72,6 +72,14 @@ class phpbb_avatar_driver_gravatar_test extends \phpbb_database_test_case
|
|||
$phpEx
|
||||
);
|
||||
|
||||
global $phpbb_dispatcher;
|
||||
$phpbb_dispatcher = $this->getMockBuilder(\phpbb\event\dispatcher::class)
|
||||
->disableOriginalConstructor()
|
||||
->onlyMethods(['trigger_event'])
|
||||
->getMock();
|
||||
$phpbb_dispatcher->method('trigger_event')
|
||||
->willReturn($this->returnArgument(1));
|
||||
|
||||
$this->gravatar = new gravatar($this->config, $imagesize, $phpbb_root_path, $phpEx, $path_helper, $cache);
|
||||
$this->gravatar->set_name('avatar.driver.gravatar');
|
||||
}
|
||||
|
@ -180,15 +188,6 @@ class phpbb_avatar_driver_gravatar_test extends \phpbb_database_test_case
|
|||
$this->assertEquals('ucp_avatar_options_gravatar.html', $this->gravatar->get_template_name());
|
||||
$this->assertEquals('acp_avatar_options_gravatar.html', $this->gravatar->get_acp_template_name());
|
||||
|
||||
|
||||
global $phpbb_dispatcher;
|
||||
$phpbb_dispatcher = $this->getMockBuilder(\phpbb\event\dispatcher::class)
|
||||
->disableOriginalConstructor()
|
||||
->onlyMethods(['trigger_event'])
|
||||
->getMock();
|
||||
$phpbb_dispatcher->method('trigger_event')
|
||||
->willReturn($this->returnArgument(1));
|
||||
|
||||
$row = [
|
||||
'avatar_type' => 'avatar.driver.gravatar',
|
||||
'avatar' => 'bar@foo.com',
|
||||
|
@ -197,4 +196,20 @@ class phpbb_avatar_driver_gravatar_test extends \phpbb_database_test_case
|
|||
];
|
||||
$this->assertEquals('<img class="gravatar" src="//secure.gravatar.com/avatar/dc8a42aba3651b0b1f088ef928ff3b1d?s=70" width="70" height="60" alt="" />', $this->gravatar->get_custom_html($this->user, $row));
|
||||
}
|
||||
|
||||
public function test_get_data(): void
|
||||
{
|
||||
$row = [
|
||||
'avatar_type' => 'avatar.driver.gravatar',
|
||||
'avatar' => 'bar@foo.com',
|
||||
'avatar_width' => '70',
|
||||
'avatar_height' => '60',
|
||||
];
|
||||
|
||||
$this->assertEquals([
|
||||
'src' => '//secure.gravatar.com/avatar/dc8a42aba3651b0b1f088ef928ff3b1d?s=70',
|
||||
'width' => '70',
|
||||
'height' => '60',
|
||||
], $this->gravatar->get_data($row));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue