diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/Framework/Utils.php | 32 | ||||
-rw-r--r-- | tests/MailFunc.php | 86 | ||||
-rw-r--r-- | tests/src/media.css | 22 |
3 files changed, 138 insertions, 2 deletions
diff --git a/tests/Framework/Utils.php b/tests/Framework/Utils.php index 3f7f48c3a..1f1e57b0e 100644 --- a/tests/Framework/Utils.php +++ b/tests/Framework/Utils.php @@ -171,6 +171,12 @@ class Framework_Utils extends PHPUnit_Framework_TestCase $this->assertRegExp('/#rcmbody h1\s\{/', $mod, "Prefix tag styles (single)"); $this->assertRegExp('/#rcmbody h1, #rcmbody h2, #rcmbody h3, #rcmbody textarea\s+\{/', $mod, "Prefix tag styles (multiple)"); $this->assertRegExp('/#rcmbody \.noscript\s+\{/', $mod, "Prefix class styles"); + + $css = file_get_contents(TESTS_DIR . 'src/media.css'); + $mod = rcube_utils::mod_css_styles($css, 'rcmbody'); + + $this->assertContains('#rcmbody table[class=w600]', $mod, 'Replace styles nested in @media block'); + $this->assertContains('#rcmbody {width:600px', $mod, 'Replace body selector nested in @media block'); } /** @@ -288,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 6ea39b1ec..ab0074ef2 100644 --- a/tests/MailFunc.php +++ b/tests/MailFunc.php @@ -17,8 +17,6 @@ class MailFunc extends PHPUnit_Framework_TestCase $RCMAIL->storage_init(false); require_once INSTALL_PATH . 'program/steps/mail/func.inc'; - - $GLOBALS['EMAIL_ADDRESS_PATTERN'] = $EMAIL_ADDRESS_PATTERN; } /** @@ -183,4 +181,88 @@ class MailFunc extends PHPUnit_Framework_TestCase $this->assertRegExp('|src="cid:theCID"|', $html, "URI base resolving exception [1]"); $this->assertRegExp('|src="http://other\.domain\.tld/img3\.gif"|', $html, "URI base resolving exception [2]"); } + + /** + * Test identities selection using Return-Path header + */ + function test_rcmail_identity_select() + { + $identities = array( + array( + 'name' => 'Test', + 'email_ascii' => 'addr@domain.tld', + 'ident' => 'Test <addr@domain.tld>', + ), + array( + 'name' => 'Test', + 'email_ascii' => 'thing@domain.tld', + 'ident' => 'Test <thing@domain.tld>', + ), + array( + 'name' => 'Test', + 'email_ascii' => 'other@domain.tld', + 'ident' => 'Test <other@domain.tld>', + ), + ); + + $message = new stdClass; + $message->headers = new rcube_message_header; + $message->headers->set('Return-Path', '<some_thing@domain.tld>'); + $res = rcmail_identity_select($message, $identities); + + $this->assertSame($identities[0], $res); + + $message->headers->set('Return-Path', '<thing@domain.tld>'); + $res = rcmail_identity_select($message, $identities); + + $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); + } } diff --git a/tests/src/media.css b/tests/src/media.css new file mode 100644 index 000000000..24eacc8a1 --- /dev/null +++ b/tests/src/media.css @@ -0,0 +1,22 @@ +.ReadMsgBody{width: 100%;} +.ExternalClass{width: 100%;} +div, p, a, li, td { -webkit-text-size-adjust:none; } +@media (max-width: 450px){ + table[class=w600], td[class=w600], table[class=w540], td[class=w540], img[class=w600]{ width:100% !important; } + table[class=w30], td[class=w30]{ width:20px !important; } + .pict img {max-width:260px; height:auto !important;} +} +@media (min-width: 450px) and (max-width: 600px){ + table[class=w600], td[class=w600], table[class=w540], td[class=w540], img[class=w600]{ width:100% !important; } + table[class=w30], td[class=w30]{ width:20px !important; } + .pict img {max-width:410px; height:auto !important;} +} +@media (min-width:600px){ + body {width:600px !important; margin:auto !important;} + .pict img {max-width:540px !important; height:auto !important;} +} +h1{ font-weight:bold; font-size:14px;color:#3c3c3c ;margin:0px; } +h2{ color:#8DB048 ; font-size:14px; font-weight:bold; margin-top:20px; border-bottom:1px solid #d6d6d6; padding-bottom:4px; } +h3{ color:#7e7e7e ; font-size:14px; font-weight:bold; margin:20px 0px 0px 0px; border-bottom:1px solid #d6d6d6; padding-bottom:0px 0px 4px 0px; } +h4{ color:#8DB048 ; font-size:12px; font-weight:bold; margin:0px; padding:0px; } +a:visited{cursor:pointer; color:#8DB048; text-decoration:none; border:none;} |