mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-06 16:56:44 +02:00
Merge remote-tracking branch 'remotes/marc/feature/avatars' into develop
# By Marc Alexander (100) and others # Via Marc Alexander (8) and Igor Wiedler (3) * remotes/marc/feature/avatars: (138 commits) [feature/avatars] Update module_auth of ucp module and fix small issues [feature/avatars] Add migrations data file for avatars [feature/avatars] Reduce module auth of ucp avatar settings [feature/avatars] Auto-clear avatar dimensions when first changing avatars [feature/avatars] Use "Main" as category for avatars in root of gallery [feature/avatars] Remove trailing whitespace from avatar code [feature/avatars] Pass phpbb_user to prepare and process form functions [feature/avatars] Document the use of the allowed extensions array [feature/avatars] Use array for allowed extensions and implode if needed [feature/avatars] Use deprecated for compatibility function [feature/avatars] Correct license, copyright and package info [feature/avatars] Move list of supported formats to avatar driver class [feature/avatars] Add include of functions_display.php in BC function [feature/avatars] Add note about when compatibility function was added [feature/avatars] Add compatibility function for get_user_avatar() [feature/avatars] Move definition of driver_collection to avatars.yml [feature/avatars] Remove the obsolete request argument for avatar drivers [feature/avatars] Add missing @var to docblocks in avatar manager [feature/avatars] Remove not needed inline style [feature/avatars] Differentiate tests for get drivers functions ...
This commit is contained in:
19
tests/avatar/driver/barfoo.php
Normal file
19
tests/avatar/driver/barfoo.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
class phpbb_avatar_driver_barfoo extends phpbb_avatar_driver
|
||||
{
|
||||
public function get_data($row)
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
public function prepare_form($request, $template, $user, $row, &$error)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function process_form($request, $template, $user, $row, &$error)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
19
tests/avatar/driver/foobar.php
Normal file
19
tests/avatar/driver/foobar.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
class phpbb_avatar_driver_foobar extends phpbb_avatar_driver
|
||||
{
|
||||
public function get_data($row)
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
public function prepare_form($request, $template, $user, $row, &$error)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function process_form($request, $template, $user, $row, &$error)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
90
tests/avatar/manager_test.php
Normal file
90
tests/avatar/manager_test.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* @package testing
|
||||
* @version $Id$
|
||||
* @copyright (c) 2012 phpBB Group
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*
|
||||
*/
|
||||
|
||||
require_once dirname(__FILE__) . '/driver/foobar.php';
|
||||
|
||||
class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
{
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
||||
// Mock phpbb_container
|
||||
$this->phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface');
|
||||
$this->phpbb_container->expects($this->any())
|
||||
->method('get')
|
||||
->with('avatar.driver.foobar')->will($this->returnValue('avatar.driver.foobar'));
|
||||
|
||||
// Prepare dependencies for avatar manager and driver
|
||||
$config = new phpbb_config(array());
|
||||
$request = $this->getMock('phpbb_request');
|
||||
$cache = $this->getMock('phpbb_cache_driver_interface');
|
||||
|
||||
$this->avatar_foobar = $this->getMock('phpbb_avatar_driver_foobar', array('get_name'), array($config, $phpbb_root_path, $phpEx, $cache));
|
||||
$this->avatar_foobar->expects($this->any())
|
||||
->method('get_name')
|
||||
->will($this->returnValue('avatar.driver.foobar'));
|
||||
$this->avatar_barfoo = $this->getMock('phpbb_avatar_driver_barfoo', array('get_name'));
|
||||
$this->avatar_barfoo->expects($this->any())
|
||||
->method('get_name')
|
||||
->will($this->returnValue('avatar.driver.barfoo'));
|
||||
|
||||
$avatar_drivers = array($this->avatar_foobar, $this->avatar_barfoo);
|
||||
|
||||
$config['allow_avatar_' . get_class($this->avatar_foobar)] = true;
|
||||
$config['allow_avatar_' . get_class($this->avatar_barfoo)] = false;
|
||||
|
||||
// Set up avatar manager
|
||||
$this->manager = new phpbb_avatar_manager($config, $avatar_drivers, $this->phpbb_container);
|
||||
}
|
||||
|
||||
public function test_get_driver()
|
||||
{
|
||||
$driver = $this->manager->get_driver('avatar.driver.foobar', false);
|
||||
$this->assertEquals('avatar.driver.foobar', $driver);
|
||||
|
||||
$driver = $this->manager->get_driver('avatar.driver.foo_wrong', false);
|
||||
$this->assertNull($driver);
|
||||
|
||||
$driver = $this->manager->get_driver('avatar.driver.foobar');
|
||||
$this->assertEquals('avatar.driver.foobar', $driver);
|
||||
|
||||
$driver = $this->manager->get_driver('avatar.driver.foo_wrong');
|
||||
$this->assertNull($driver);
|
||||
}
|
||||
|
||||
public function test_get_all_drivers()
|
||||
{
|
||||
$drivers = $this->manager->get_all_drivers();
|
||||
$this->assertArrayHasKey('avatar.driver.foobar', $drivers);
|
||||
$this->assertArrayHasKey('avatar.driver.barfoo', $drivers);
|
||||
$this->assertEquals('avatar.driver.foobar', $drivers['avatar.driver.foobar']);
|
||||
$this->assertEquals('avatar.driver.barfoo', $drivers['avatar.driver.barfoo']);
|
||||
}
|
||||
|
||||
public function test_get_enabled_drivers()
|
||||
{
|
||||
$drivers = $this->manager->get_enabled_drivers();
|
||||
$this->assertArrayHasKey('avatar.driver.foobar', $drivers);
|
||||
$this->assertArrayNotHasKey('avatar.driver.barfoo', $drivers);
|
||||
$this->assertEquals('avatar.driver.foobar', $drivers['avatar.driver.foobar']);
|
||||
}
|
||||
|
||||
public function test_get_avatar_settings()
|
||||
{
|
||||
$avatar_settings = $this->manager->get_avatar_settings($this->avatar_foobar);
|
||||
|
||||
$expected_settings = array(
|
||||
'allow_avatar_' . get_class($this->avatar_foobar) => array('lang' => 'ALLOW_' . strtoupper(get_class($this->avatar_foobar)), 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false),
|
||||
);
|
||||
|
||||
$this->assertEquals($expected_settings, $avatar_settings);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user