mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
Merge remote-tracking branch 'remotes/Marc/ticket/11404' into develop
# By Marc Alexander # Via Marc Alexander * remotes/Marc/ticket/11404: [ticket/11404] Remove version ID from manager_test.php file header [ticket/11404] Add tests for phpbb_avatar_manager::clean_row() [ticket/11404] Convert manager_test to UNIX line endings [ticket/11404] Use a default data row if $row is empty in clean_row() [ticket/11404] Return empty array of avatar data if $row is empty
This commit is contained in:
commit
d4ee7718b9
2 changed files with 177 additions and 90 deletions
|
@ -45,6 +45,17 @@ class phpbb_avatar_manager
|
||||||
*/
|
*/
|
||||||
protected $container;
|
protected $container;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default avatar data row
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
static protected $default_row = array(
|
||||||
|
'avatar' => '',
|
||||||
|
'avatar_type' => '',
|
||||||
|
'avatar_width' => '',
|
||||||
|
'avatar_height' => '',
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct an avatar manager object
|
* Construct an avatar manager object
|
||||||
*
|
*
|
||||||
|
@ -174,6 +185,12 @@ class phpbb_avatar_manager
|
||||||
*/
|
*/
|
||||||
static public function clean_row($row)
|
static public function clean_row($row)
|
||||||
{
|
{
|
||||||
|
// Upon creation of a user/group $row might be empty
|
||||||
|
if (empty($row))
|
||||||
|
{
|
||||||
|
return self::$default_row;
|
||||||
|
}
|
||||||
|
|
||||||
$keys = array_keys($row);
|
$keys = array_keys($row);
|
||||||
$values = array_values($row);
|
$values = array_values($row);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package testing
|
* @package testing
|
||||||
* @version $Id$
|
|
||||||
* @copyright (c) 2012 phpBB Group
|
* @copyright (c) 2012 phpBB Group
|
||||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||||
*
|
*
|
||||||
|
@ -87,4 +86,75 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
$this->assertEquals($expected_settings, $avatar_settings);
|
$this->assertEquals($expected_settings, $avatar_settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function database_row_data()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
'user_avatar' => '',
|
||||||
|
'user_avatar_type' => '',
|
||||||
|
'user_avatar_width' => '',
|
||||||
|
'user_avatar_height' => '',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'avatar' => '',
|
||||||
|
'avatar_type' => '',
|
||||||
|
'avatar_width' => '',
|
||||||
|
'avatar_height' => '',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
'group_avatar' => '',
|
||||||
|
'group_avatar_type' => '',
|
||||||
|
'group_avatar_width' => '',
|
||||||
|
'group_avatar_height' => '',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'avatar' => '',
|
||||||
|
'avatar_type' => '',
|
||||||
|
'avatar_width' => '',
|
||||||
|
'avatar_height' => '',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array(),
|
||||||
|
array(
|
||||||
|
'avatar' => '',
|
||||||
|
'avatar_type' => '',
|
||||||
|
'avatar_width' => '',
|
||||||
|
'avatar_height' => '',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
array(
|
||||||
|
'foobar_avatar' => '',
|
||||||
|
'foobar_avatar_type' => '',
|
||||||
|
'foobar_avatar_width' => '',
|
||||||
|
'foobar_avatar_height' => '',
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'foobar_avatar' => '',
|
||||||
|
'foobar_avatar_type' => '',
|
||||||
|
'foobar_avatar_width' => '',
|
||||||
|
'foobar_avatar_height' => '',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider database_row_data
|
||||||
|
*/
|
||||||
|
public function test_clean_row(array $input, array $output)
|
||||||
|
{
|
||||||
|
$cleaned_row = array();
|
||||||
|
|
||||||
|
$cleaned_row = phpbb_avatar_manager::clean_row($input);
|
||||||
|
foreach ($output as $key => $null)
|
||||||
|
{
|
||||||
|
$this->assertArrayHasKey($key, $cleaned_row);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue