adding test case for getDefaultEmailAddress() + fixing #1844 again

This commit is contained in:
Thomas Mueller 2013-03-04 21:10:18 +01:00
parent ee00ddeb60
commit 6019cdd5bd
3 changed files with 15 additions and 2 deletions

View File

@ -119,4 +119,12 @@ class OC_Mail {
return($txt);
}
/**
* @param string $emailAddress a given email address to be validated
* @return bool
*/
public static function ValidateAddress($emailAddress) {
return PHPMailer::ValidateAddress($emailAddress);
}
}

View File

@ -219,11 +219,11 @@ class Util {
$host_name = self::getServerHostName();
$defaultEmailAddress = $user_part.'@'.$host_name;
if (\PHPMailer::ValidateAddress($defaultEmailAddress)) {
if (\OC_Mail::ValidateAddress($defaultEmailAddress)) {
return $defaultEmailAddress;
}
// incase we cannot build a valid email address from the hostname let's fallback to 'localhost.localdomain'
// in case we cannot build a valid email address from the hostname let's fallback to 'localhost.localdomain'
return $user_part.'@localhost.localdomain';
}

View File

@ -42,4 +42,9 @@ class Test_Util extends PHPUnit_Framework_TestCase {
$result = strlen(OC_Util::generate_random_bytes(59));
$this->assertEquals(59, $result);
}
function testGetDefaultEmailAddress() {
$email = \OCP\Util::getDefaultEmailAddress("no-reply");
$this->assertEquals('no-reply@localhost.localdomain', $email);
}
}