Merge pull request #2088 from owncloud/fixing-1844-again-master
adding test case for getDefaultEmailAddress() + fixing #1844 again
This commit is contained in:
commit
62dde34887
3 changed files with 15 additions and 2 deletions
|
@ -119,4 +119,12 @@ class OC_Mail {
|
||||||
return($txt);
|
return($txt);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $emailAddress a given email address to be validated
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function ValidateAddress($emailAddress) {
|
||||||
|
return PHPMailer::ValidateAddress($emailAddress);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -219,11 +219,11 @@ class Util {
|
||||||
$host_name = self::getServerHostName();
|
$host_name = self::getServerHostName();
|
||||||
$defaultEmailAddress = $user_part.'@'.$host_name;
|
$defaultEmailAddress = $user_part.'@'.$host_name;
|
||||||
|
|
||||||
if (\PHPMailer::ValidateAddress($defaultEmailAddress)) {
|
if (\OC_Mail::ValidateAddress($defaultEmailAddress)) {
|
||||||
return $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';
|
return $user_part.'@localhost.localdomain';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,4 +42,9 @@ class Test_Util extends PHPUnit_Framework_TestCase {
|
||||||
$result = strlen(OC_Util::generate_random_bytes(59));
|
$result = strlen(OC_Util::generate_random_bytes(59));
|
||||||
$this->assertEquals(59, $result);
|
$this->assertEquals(59, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function testGetDefaultEmailAddress() {
|
||||||
|
$email = \OCP\Util::getDefaultEmailAddress("no-reply");
|
||||||
|
$this->assertEquals('no-reply@localhost.localdomain', $email);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue