1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-02-24 20:13:22 +01:00

Merge remote-tracking branch 'marc1706/ticket/11930' into develop

* marc1706/ticket/11930:
  [ticket/11930] Update docblock of avatar driver constructor
  [ticket/11930] Modify order of properties to fit constructor method
  [ticket/11930] Move path_helper in front of optional cache argument
  [ticket/11930] Fix tests after adding phpbb\path_helper to avatar drivers
  [ticket/11930] Use \phpbb\path_helper for avatar URLs
This commit is contained in:
Andreas Fischer 2013-10-21 11:04:23 +02:00
commit ba5b53521a
5 changed files with 25 additions and 5 deletions

View File

@ -5,6 +5,7 @@ services:
- @config
- %core.root_path%
- %core.php_ext%
- @path_helper
- @cache.driver
calls:
- [set_name, [avatar.driver.gravatar]]
@ -17,6 +18,7 @@ services:
- @config
- %core.root_path%
- %core.php_ext%
- @path_helper
- @cache.driver
calls:
- [set_name, [avatar.driver.local]]
@ -29,6 +31,7 @@ services:
- @config
- %core.root_path%
- %core.php_ext%
- @path_helper
- @cache.driver
calls:
- [set_name, [avatar.driver.remote]]
@ -41,6 +44,7 @@ services:
- @config
- %core.root_path%
- %core.php_ext%
- @path_helper
- @cache.driver
calls:
- [set_name, [avatar.driver.upload]]

View File

@ -47,6 +47,12 @@ abstract class driver implements \phpbb\avatar\driver\driver_interface
*/
protected $php_ext;
/**
* Path Helper
* @var \phpbb\path_helper
*/
protected $path_helper;
/**
* Cache driver
* @var \phpbb\cache\driver\driver_interface
@ -75,13 +81,15 @@ abstract class driver implements \phpbb\avatar\driver\driver_interface
* @param \phpbb\request\request $request Request object
* @param string $phpbb_root_path Path to the phpBB root
* @param string $php_ext PHP file extension
* @param \phpbb_path_helper $path_helper phpBB path helper
* @param \phpbb\cache\driver\driver_interface $cache Cache driver
*/
public function __construct(\phpbb\config\config $config, $phpbb_root_path, $php_ext, \phpbb\cache\driver\driver_interface $cache = null)
public function __construct(\phpbb\config\config $config, $phpbb_root_path, $php_ext, \phpbb\path_helper $path_helper, \phpbb\cache\driver\driver_interface $cache = null)
{
$this->config = $config;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
$this->path_helper = $path_helper;
$this->cache = $cache;
}

View File

@ -29,7 +29,7 @@ class local extends \phpbb\avatar\driver\driver
public function get_data($row)
{
return array(
'src' => $this->phpbb_root_path . $this->config['avatar_gallery_path'] . '/' . $row['avatar'],
'src' => $this->path_helper->get_web_root_path() . $this->config['avatar_gallery_path'] . '/' . $row['avatar'],
'width' => $row['avatar_width'],
'height' => $row['avatar_height'],
);

View File

@ -29,7 +29,7 @@ class upload extends \phpbb\avatar\driver\driver
public function get_data($row, $ignore_config = false)
{
return array(
'src' => $this->phpbb_root_path . 'download/file.' . $this->php_ext . '?avatar=' . $row['avatar'],
'src' => $this->path_helper->get_web_root_path() . 'download/file.' . $this->php_ext . '?avatar=' . $row['avatar'],
'width' => $row['avatar_width'],
'height' => $row['avatar_height'],
);

View File

@ -25,9 +25,17 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase
$config = new \phpbb\config\config(array());
$request = $this->getMock('\phpbb\request\request');
$cache = $this->getMock('\phpbb\cache\driver\driver_interface');
$path_helper = new \phpbb\path_helper(
new \phpbb\symfony_request(
new phpbb_mock_request()
),
new \phpbb\filesystem(),
$this->phpbb_root_path,
$this->phpEx
);
// $this->avatar_foobar will be needed later on
$this->avatar_foobar = $this->getMock('\phpbb\avatar\driver\foobar', array('get_name'), array($config, $phpbb_root_path, $phpEx, $cache));
$this->avatar_foobar = $this->getMock('\phpbb\avatar\driver\foobar', array('get_name'), array($config, $phpbb_root_path, $phpEx, $path_helper, $cache));
$this->avatar_foobar->expects($this->any())
->method('get_name')
->will($this->returnValue('avatar.driver.foobar'));
@ -40,7 +48,7 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase
foreach ($this->avatar_drivers() as $driver)
{
$cur_avatar = $this->getMock('\phpbb\avatar\driver\\' . $driver, array('get_name'), array($config, $phpbb_root_path, $phpEx, $cache));
$cur_avatar = $this->getMock('\phpbb\avatar\driver\\' . $driver, array('get_name'), array($config, $phpbb_root_path, $phpEx, $path_helper, $cache));
$cur_avatar->expects($this->any())
->method('get_name')
->will($this->returnValue('avatar.driver.' . $driver));