diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Framework/Utils.php | 26 | ||||
-rw-r--r-- | tests/MailFunc.php | 48 |
2 files changed, 74 insertions, 0 deletions
diff --git a/tests/Framework/Utils.php b/tests/Framework/Utils.php index 2f4aec32e..1f1e57b0e 100644 --- a/tests/Framework/Utils.php +++ b/tests/Framework/Utils.php @@ -294,6 +294,32 @@ class Framework_Utils extends PHPUnit_Framework_TestCase } /** + * rcube:utils::anytodatetime() + */ + function test_anytodatetime() + { + $test = array( + '2013-04-22' => '2013-04-22', + '2013/04/22' => '2013-04-22', + '2013.04.22' => '2013-04-22', + '22-04-2013' => '2013-04-22', + '22/04/2013' => '2013-04-22', + '22.04.2013' => '2013-04-22', + '04/22/2013' => '2013-04-22', + '22.4.2013' => '2013-04-22', + '20130422' => '2013-04-22', + '1900-10-10' => '1900-10-10', + '01-01-1900' => '1900-01-01', + '01/30/1960' => '1960-01-30' + ); + + foreach ($test as $datetime => $ts) { + $result = rcube_utils::anytodatetime($datetime); + $this->assertSame($ts, $result ? $result->format('Y-m-d') : '', "Error parsing date: $datetime"); + } + } + + /** * rcube:utils::normalize _string() */ function test_normalize_string() diff --git a/tests/MailFunc.php b/tests/MailFunc.php index 08cbd4ed0..ab0074ef2 100644 --- a/tests/MailFunc.php +++ b/tests/MailFunc.php @@ -217,4 +217,52 @@ class MailFunc extends PHPUnit_Framework_TestCase $this->assertSame($identities[1], $res); } + + /** + * Test identities selection (#1489378) + */ + function test_rcmail_identity_select2() + { + $identities = array( + array( + 'name' => 'Test 1', + 'email_ascii' => 'addr1@domain.tld', + 'ident' => 'Test 1 <addr1@domain.tld>', + ), + array( + 'name' => 'Test 2', + 'email_ascii' => 'addr2@domain.tld', + 'ident' => 'Test 2 <addr2@domain.tld>', + ), + array( + 'name' => 'Test 3', + 'email_ascii' => 'addr3@domain.tld', + 'ident' => 'Test 3 <addr3@domain.tld>', + ), + array( + 'name' => 'Test 4', + 'email_ascii' => 'addr2@domain.tld', + 'ident' => 'Test 4 <addr2@domain.tld>', + ), + ); + + $message = new stdClass; + $message->headers = new rcube_message_header; + + $message->headers->set('From', '<addr2@domain.tld>'); + $res = rcmail_identity_select($message, $identities); + $this->assertSame($identities[1], $res); + + $message->headers->set('From', 'Test 2 <addr2@domain.tld>'); + $res = rcmail_identity_select($message, $identities); + $this->assertSame($identities[1], $res); + + $message->headers->set('From', 'Other <addr2@domain.tld>'); + $res = rcmail_identity_select($message, $identities); + $this->assertSame($identities[1], $res); + + $message->headers->set('From', 'Test 4 <addr2@domain.tld>'); + $res = rcmail_identity_select($message, $identities); + $this->assertSame($identities[3], $res); + } } |