From 6019cdd5bdba8623673299e9ae7b765bef8235a9 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Mon, 4 Mar 2013 21:10:18 +0100 Subject: adding test case for getDefaultEmailAddress() + fixing #1844 again --- lib/mail.php | 8 ++++++++ lib/public/util.php | 4 ++-- tests/lib/util.php | 5 +++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/mail.php b/lib/mail.php index 22194045a76..61634632efc 100644 --- a/lib/mail.php +++ b/lib/mail.php @@ -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); + } } diff --git a/lib/public/util.php b/lib/public/util.php index 5d814114a24..db07cbcfff3 100644 --- a/lib/public/util.php +++ b/lib/public/util.php @@ -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'; } diff --git a/tests/lib/util.php b/tests/lib/util.php index ebff3c7381a..b904c359807 100644 --- a/tests/lib/util.php +++ b/tests/lib/util.php @@ -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); + } } \ No newline at end of file -- cgit v1.2.3