mirror of
https://github.com/e107inc/e107.git
synced 2025-08-16 03:24:20 +02:00
Added 'base64' option to allow for embedded image src. (useful when including avatars in email signatures)
Added test for toAvatar() method. Cleaned up & when found in URL by getRemoteContent()
This commit is contained in:
@@ -629,12 +629,118 @@ TMP;
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
public function testToAvatar()
|
||||
{
|
||||
$icon = codecept_data_dir()."icon_64.png";
|
||||
|
||||
if(!is_dir(e_AVATAR_UPLOAD))
|
||||
{
|
||||
mkdir(e_AVATAR_UPLOAD,0755, true);
|
||||
}
|
||||
|
||||
if(!is_dir(e_AVATAR_DEFAULT))
|
||||
{
|
||||
mkdir(e_AVATAR_DEFAULT,0755, true);
|
||||
}
|
||||
|
||||
if(!copy($icon, e_AVATAR_UPLOAD."avatartest.png"))
|
||||
{
|
||||
echo "Couldn't copy the avatar";
|
||||
}
|
||||
if(!copy($icon, e_AVATAR_DEFAULT."avatartest.png"))
|
||||
{
|
||||
echo "Couldn't copy the avatar";
|
||||
}
|
||||
|
||||
$tests = array(
|
||||
0 => array(
|
||||
'input' => array('user_image'=>'-upload-avatartest.png'),
|
||||
'parms' => array('w'=>50, 'h'=>50),
|
||||
'expected' => array(
|
||||
"thumb.php?src=%7Be_AVATAR%7Dupload%2Favatartest.png&w=50&h=50",
|
||||
"class='img-rounded rounded user-avatar'"
|
||||
)
|
||||
),
|
||||
1 => array(
|
||||
'input' => array('user_image'=>'avatartest.png'),
|
||||
'parms' => array('w'=>50, 'h'=>50),
|
||||
'expected' => array(
|
||||
"thumb.php?src=%7Be_AVATAR%7Ddefault%2Favatartest.png&w=50&h=50",
|
||||
"class='img-rounded rounded user-avatar'"
|
||||
)
|
||||
),
|
||||
2 => array(
|
||||
'input' => array('user_image'=>''),
|
||||
'parms' => array('w'=>50, 'h'=>50),
|
||||
'expected' => array(
|
||||
"thumb.php?src=%7Be_IMAGE%7Dgeneric%2Fblank_avatar.jpg&w=50&h=50",
|
||||
"class='img-rounded rounded user-avatar'"
|
||||
)
|
||||
),
|
||||
3 => array(
|
||||
'input' => array('user_image'=>'https://mydomain.com/remoteavatar.jpg'),
|
||||
'parms' => array('w'=>50, 'h'=>50),
|
||||
'expected' => array(
|
||||
"src='https://mydomain.com/remoteavatar.jpg'",
|
||||
"class='img-rounded rounded user-avatar'",
|
||||
"width='50' height='50'",
|
||||
)
|
||||
),
|
||||
4 => array(
|
||||
'input' => array('user_image'=>'', 'user_id'=>1),
|
||||
'parms' => array('w'=>50, 'h'=>50, 'link'=>true),
|
||||
'expected' => array(
|
||||
"thumb.php?src=%7Be_IMAGE%7Dgeneric%2Fblank_avatar.jpg&w=50&h=50",
|
||||
"class='img-rounded rounded user-avatar'",
|
||||
"<a class='e-tip' title=",
|
||||
"usersettings.php"
|
||||
)
|
||||
),
|
||||
5 => array(
|
||||
'input' => array('user_image'=>'avatartest.png'),
|
||||
'parms' => array('w'=>30, 'h'=>20, 'crop'=>true, 'shape'=>'rounded'),
|
||||
'expected' => array(
|
||||
"thumb.php?src=%7Be_AVATAR%7Ddefault%2Favatartest.png&aw=30&ah=20",
|
||||
"class='img-rounded user-avatar'"
|
||||
)
|
||||
),
|
||||
6 => array(
|
||||
'input' => array('user_image'=>'avatartest.png'),
|
||||
'parms' => array('w'=>30, 'h'=>30, 'shape'=>'circle', 'alt'=>'mytitle'),
|
||||
'expected' => array(
|
||||
"thumb.php?src=%7Be_AVATAR%7Ddefault%2Favatartest.png&w=30&h=30",
|
||||
"class='img-circle user-avatar'",
|
||||
'alt="mytitle"',
|
||||
)
|
||||
),
|
||||
/** @fixme - doesn't pass under CLI */
|
||||
/* 6 => array(
|
||||
'input' => array('user_image'=>'avatartest.png'),
|
||||
'parms' => array('w'=>50, 'h'=>50, 'crop'=>true, 'base64'=>true, 'shape'=>'circle'),
|
||||
'expected' => array(
|
||||
"src='data:image/png;base64,",
|
||||
"class='img-circle user-avatar'"
|
||||
)
|
||||
),*/
|
||||
|
||||
|
||||
);
|
||||
|
||||
foreach($tests as $var)
|
||||
{
|
||||
$result = $this->tp->toAvatar($var['input'], $var['parms']);
|
||||
foreach($var['expected'] as $str)
|
||||
{
|
||||
$this->assertStringContainsString($str, $result);
|
||||
}
|
||||
//var_dump($result);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
public function testToIcon()
|
||||
{
|
||||
$icon = codecept_data_dir()."icon_64.png";
|
||||
|
Reference in New Issue
Block a user