summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Framework/Browser.php52
-rw-r--r--tests/Framework/CacheShared.php20
-rw-r--r--tests/Framework/Contacts.php20
-rw-r--r--tests/Framework/DB.php20
-rw-r--r--tests/Framework/Html2text.php28
-rw-r--r--tests/Framework/ImapCache.php20
-rw-r--r--tests/Framework/LdapGeneric.php20
-rw-r--r--tests/Framework/Mime.php2
-rw-r--r--tests/Framework/ResultIndex.php47
-rw-r--r--tests/Framework/ResultThread.php39
-rw-r--r--tests/Framework/SpellcheckAtd.php21
-rw-r--r--tests/Framework/SpellcheckEnchant.php21
-rw-r--r--tests/Framework/SpellcheckGoogie.php21
-rw-r--r--tests/Framework/SpellcheckPspell.php21
-rw-r--r--tests/Framework/Utils.php60
-rw-r--r--tests/Framework/Washtml.php56
-rw-r--r--tests/MailFunc.php86
-rw-r--r--tests/phpunit.xml9
-rw-r--r--tests/src/imap_thread.txt1
-rw-r--r--tests/src/media.css22
20 files changed, 572 insertions, 14 deletions
diff --git a/tests/Framework/Browser.php b/tests/Framework/Browser.php
index 832d4bf14..6afd2144c 100644
--- a/tests/Framework/Browser.php
+++ b/tests/Framework/Browser.php
@@ -21,7 +21,7 @@ class Framework_Browser extends PHPUnit_Framework_TestCase
/**
* @dataProvider browsers
*/
- function test_browser($useragent, $opera, $chrome, $ie, $ns, $ns4, $khtml, $safari, $mz)
+ function test_browser($useragent, $opera, $chrome, $ie, $ns, $safari, $mz)
{
$object = $this->getBrowser($useragent);
@@ -30,8 +30,6 @@ class Framework_Browser extends PHPUnit_Framework_TestCase
$this->assertEquals($chrome, $object->chrome, 'Check for Chrome failed');
$this->assertEquals($ie, $object->ie, 'Check for IE failed');
$this->assertEquals($ns, $object->ns, 'Check for NS failed');
- $this->assertEquals($ns4, $object->ns4, 'Check for NS4 failed');
- $this->assertEquals($khtml, $object->khtml, 'Check for khtml failed');
$this->assertEquals($safari, $object->safari, 'Check for Safari failed');
$this->assertEquals($mz, $object->mz, 'Check for MZ failed');
}
@@ -132,7 +130,7 @@ class Framework_Browser extends PHPUnit_Framework_TestCase
function browsers()
{
- return $this->extractDataSet(array('isOpera','isChrome','isIE','isNS','isNS4','isKHTML','isSafari','isMZ'));
+ return $this->extractDataSet(array('isOpera','isChrome','isIE','isNS','isSafari','isMZ'));
}
function useragents()
@@ -149,8 +147,6 @@ class Framework_Browser extends PHPUnit_Framework_TestCase
'isChrome' => false, //isChrome
'isIE' => false, //isIE
'isNS' => false, //isNS
- 'isNS4' => false, //isNS4
- 'isKHTML' => false, //isKHTML
'isSafari' => false, //isSafari
'isMZ' => true, //isMZ
'lang' => 'en-US', //lang
@@ -169,8 +165,6 @@ class Framework_Browser extends PHPUnit_Framework_TestCase
'isChrome' => false, //isChrome
'isIE' => false, //isIE
'isNS' => false, //isNS
- 'isNS4' => false, //isNS4
- 'isKHTML' => false, //isKHTML
'isSafari' => false, //isSafari
'isMZ' => true, //isMZ
'lang' => 'en-US', //lang
@@ -181,7 +175,7 @@ class Framework_Browser extends PHPUnit_Framework_TestCase
'Chrome Mac' => array(
'useragent' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_4; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.461.0 Safari/534.3',
- 'version' => '5', //Version
+ 'version' => '6', //Version
'isWin' => false, //isWindows
'isLinux' => false,
'isMac' => true, //isMac
@@ -190,8 +184,6 @@ class Framework_Browser extends PHPUnit_Framework_TestCase
'isChrome' => true, //isChrome
'isIE' => false, //isIE
'isNS' => false, //isNS
- 'isNS4' => false, //isNS4
- 'isKHTML' => true, //isKHTML
'isSafari' => false, //isSafari
'isMZ' => false, //isMZ
'lang' => 'en-US', //lang
@@ -199,6 +191,44 @@ class Framework_Browser extends PHPUnit_Framework_TestCase
'canPNGALPHA' => false, //canPNGALPHA
'canIMGDATA' => true, //canIMGDATA
),
+
+ 'IE 11' => array(
+ 'useragent' => 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; .NET4.0E; .NET4.0C; rv:11.0) like Gecko',
+ 'version' => '11.0', //Version
+ 'isWin' => true, //isWindows
+ 'isLinux' => false,
+ 'isMac' => false, //isMac
+ 'isUnix' => false, //isUnix
+ 'isOpera' => false, //isOpera
+ 'isChrome' => false, //isChrome
+ 'isIE' => true, //isIE
+ 'isNS' => false, //isNS
+ 'isSafari' => false, //isSafari
+ 'isMZ' => false, //isMZ
+ 'lang' => '', //lang
+ 'hasDOM' => true, //hasDOM
+ 'canPNGALPHA' => true, //canPNGALPHA
+ 'canIMGDATA' => false, //canIMGDATA
+ ),
+
+ 'Opera 15' => array(
+ 'useragent' => 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.29 Safari/537.36 OPR/15.0.1147.24',
+ 'version' => '15.0', //Version
+ 'isWin' => true, //isWindows
+ 'isLinux' => false,
+ 'isMac' => false, //isMac
+ 'isUnix' => false, //isUnix
+ 'isOpera' => true, //isOpera
+ 'isChrome' => false, //isChrome
+ 'isIE' => false, //isIE
+ 'isNS' => false, //isNS
+ 'isSafari' => false, //isSafari
+ 'isMZ' => false, //isMZ
+ 'lang' => '', //lang
+ 'hasDOM' => true, //hasDOM
+ 'canPNGALPHA' => true, //canPNGALPHA
+ 'canIMGDATA' => true, //canIMGDATA
+ ),
);
}
diff --git a/tests/Framework/CacheShared.php b/tests/Framework/CacheShared.php
new file mode 100644
index 000000000..9ddcafc7f
--- /dev/null
+++ b/tests/Framework/CacheShared.php
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * Test class to test rcube_cache_shared class
+ *
+ * @package Tests
+ */
+class Framework_CacheShared extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Class constructor
+ */
+ function test_class()
+ {
+ $object = new rcube_cache_shared('db');
+
+ $this->assertInstanceOf('rcube_cache_shared', $object, "Class constructor");
+ }
+}
diff --git a/tests/Framework/Contacts.php b/tests/Framework/Contacts.php
new file mode 100644
index 000000000..0167ea366
--- /dev/null
+++ b/tests/Framework/Contacts.php
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * Test class to test rcube_contacts class
+ *
+ * @package Tests
+ */
+class Framework_Contacts extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Class constructor
+ */
+ function test_class()
+ {
+ $object = new rcube_contacts(null, null);
+
+ $this->assertInstanceOf('rcube_contacts', $object, "Class constructor");
+ }
+}
diff --git a/tests/Framework/DB.php b/tests/Framework/DB.php
new file mode 100644
index 000000000..b7a063841
--- /dev/null
+++ b/tests/Framework/DB.php
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * Test class to test rcube_db class
+ *
+ * @package Tests
+ */
+class Framework_DB extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Class constructor
+ */
+ function test_class()
+ {
+ $object = new rcube_db('test');
+
+ $this->assertInstanceOf('rcube_db', $object, "Class constructor");
+ }
+}
diff --git a/tests/Framework/Html2text.php b/tests/Framework/Html2text.php
index 3e0df48d9..2c7759f7d 100644
--- a/tests/Framework/Html2text.php
+++ b/tests/Framework/Html2text.php
@@ -75,4 +75,32 @@ EOF;
$this->assertContains('>> INNER 3', $res, 'Quote inner');
$this->assertContains('> OUTER END', $res, 'Quote outer');
}
+
+ function test_broken_blockquotes()
+ {
+ // no end tag
+ $html = <<<EOF
+Begin<br>
+<blockquote>QUOTED TEXT
+<blockquote>
+NO END TAG FOUND
+EOF;
+ $ht = new rcube_html2text($html, false, false);
+ $res = $ht->get_text();
+
+ $this->assertContains('QUOTED TEXT NO END TAG FOUND', $res, 'No quoating on invalid html');
+
+ // with some (nested) end tags
+ $html = <<<EOF
+Begin<br>
+<blockquote>QUOTED TEXT
+<blockquote>INNER 1</blockquote>
+<blockquote>INNER 2</blockquote>
+NO END TAG FOUND
+EOF;
+ $ht = new rcube_html2text($html, false, false);
+ $res = $ht->get_text();
+
+ $this->assertContains('QUOTED TEXT INNER 1 INNER 2 NO END', $res, 'No quoating on invalid html');
+ }
}
diff --git a/tests/Framework/ImapCache.php b/tests/Framework/ImapCache.php
new file mode 100644
index 000000000..83612c549
--- /dev/null
+++ b/tests/Framework/ImapCache.php
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * Test class to test rcube_imap_cache class
+ *
+ * @package Tests
+ */
+class Framework_ImapCache extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Class constructor
+ */
+ function test_class()
+ {
+ $object = new rcube_imap_cache(null, null, null, null);
+
+ $this->assertInstanceOf('rcube_imap_cache', $object, "Class constructor");
+ }
+}
diff --git a/tests/Framework/LdapGeneric.php b/tests/Framework/LdapGeneric.php
new file mode 100644
index 000000000..8cb1a2ce5
--- /dev/null
+++ b/tests/Framework/LdapGeneric.php
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * Test class to test rcube_ldap_generic class
+ *
+ * @package Tests
+ */
+class Framework_LdapGeneric extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Class constructor
+ */
+ function test_class()
+ {
+ $object = new rcube_ldap_generic(array());
+
+ $this->assertInstanceOf('rcube_ldap_generic', $object, "Class constructor");
+ }
+}
diff --git a/tests/Framework/Mime.php b/tests/Framework/Mime.php
index 1450b4f90..d767905e3 100644
--- a/tests/Framework/Mime.php
+++ b/tests/Framework/Mime.php
@@ -41,6 +41,7 @@ class Framework_Mime extends PHPUnit_Framework_TestCase
21 => '"test test"@domain.tld',
// invalid (#1489092)
22 => '"John Doe @ SomeBusinessName" <MAILER-DAEMON>',
+ 23 => '=?UTF-8?B?IlRlc3QsVGVzdCI=?= <test@domain.tld>',
);
$results = array(
@@ -68,6 +69,7 @@ class Framework_Mime extends PHPUnit_Framework_TestCase
21 => array(1, '', '"test test"@domain.tld'),
// invalid (#1489092)
22 => array(1, 'John Doe @ SomeBusinessName', 'MAILER-DAEMON'),
+ 23 => array(1, 'Test,Test', 'test@domain.tld'),
);
foreach ($headers as $idx => $header) {
diff --git a/tests/Framework/ResultIndex.php b/tests/Framework/ResultIndex.php
index efbba6da7..da1cc628f 100644
--- a/tests/Framework/ResultIndex.php
+++ b/tests/Framework/ResultIndex.php
@@ -17,4 +17,51 @@ class Framework_ResultIndex extends PHPUnit_Framework_TestCase
$this->assertInstanceOf('rcube_result_index', $object, "Class constructor");
}
+
+ /**
+ * thread parser test
+ */
+ function test_parse()
+ {
+ $text = "* SORT 2001 2002 2035 2036 2037 2038 2044 2046 2043 2045 2226 2225 2224 2223";
+ $object = new rcube_result_index('INBOX', $text);
+
+ $this->assertSame(false, $object->is_empty(), "Object is empty");
+ $this->assertSame(false, $object->is_error(), "Object is error");
+ $this->assertSame(2226, $object->max(), "Max message UID");
+ $this->assertSame(2001, $object->min(), "Min message UID");
+ $this->assertSame(14, $object->count_messages(), "Messages count");
+ $this->assertSame(14, $object->count(), "Messages count");
+ $this->assertSame(1, $object->exists(2002, true), "Message exists");
+ $this->assertSame(true, $object->exists(2002), "Message exists (bool)");
+ $this->assertSame(2001, $object->get_element('FIRST'), "Get first element");
+ $this->assertSame(2223, $object->get_element('LAST'), "Get last element");
+ $this->assertSame(2035, (int) $object->get_element(2), "Get specified element");
+ $this->assertSame("2001:2002,2035:2038,2043:2046,2223:2226", $object->get_compressed(), "Get compressed index");
+ $this->assertSame('INBOX', $object->get_parameters('MAILBOX'), "Get parameter");
+
+ $clone = clone $object;
+ $clone->filter(array(2035, 2002));
+
+ $this->assertSame(2, $clone->count(), "Messages count (filtered)");
+ $this->assertSame(2002, $clone->get_element('FIRST'), "Get first element (filtered)");
+
+ $clone = clone $object;
+ $clone->revert();
+
+ $this->assertSame(14, $clone->count(), "Messages count (reverted)");
+ $this->assertSame(12, $clone->exists(2002, true), "Message exists (reverted)");
+ $this->assertSame(true, $clone->exists(2002), "Message exists (bool) (reverted)");
+ $this->assertSame(2223, $clone->get_element('FIRST'), "Get first element (reverted)");
+ $this->assertSame(2001, $clone->get_element('LAST'), "Get last element (reverted)");
+ $this->assertSame(2225, (int) $clone->get_element(2), "Get specified element (reverted)");
+
+ $clone = clone $object;
+ $clone->slice(2, 3);
+
+ $this->assertSame(3, $clone->count(), "Messages count (sliced)");
+ $this->assertSame(2035, $clone->get_element('FIRST'), "Get first element (sliced)");
+ $this->assertSame(2037, $clone->get_element('LAST'), "Get last element (sliced)");
+ }
+
}
diff --git a/tests/Framework/ResultThread.php b/tests/Framework/ResultThread.php
index f980845cc..55fca4c6a 100644
--- a/tests/Framework/ResultThread.php
+++ b/tests/Framework/ResultThread.php
@@ -17,4 +17,43 @@ class Framework_ResultThread extends PHPUnit_Framework_TestCase
$this->assertInstanceOf('rcube_result_thread', $object, "Class constructor");
}
+
+ /**
+ * thread parser test
+ */
+ function test_parse_thread()
+ {
+ $text = file_get_contents(__DIR__ . '/../src/imap_thread.txt');
+ $object = new rcube_result_thread('INBOX', $text);
+
+ $this->assertSame(false, $object->is_empty(), "Object is empty");
+ $this->assertSame(false, $object->is_error(), "Object is error");
+ $this->assertSame(1721, $object->max(), "Max message UID");
+ $this->assertSame(1, $object->min(), "Min message UID");
+ $this->assertSame(1721, $object->count_messages(), "Messages count");
+ $this->assertSame(1691, $object->exists(1720, true), "Message exists");
+ $this->assertSame(true, $object->exists(1720), "Message exists (bool)");
+ $this->assertSame(1, $object->get_element('FIRST'), "Get first element");
+ $this->assertSame(1719, $object->get_element('LAST'), "Get last element");
+ $this->assertSame(14, (int) $object->get_element(2), "Get specified element");
+
+ $clone = clone $object;
+ $clone->filter(array(7));
+ $clone = $clone->get_tree();
+
+ $this->assertSame(1, count($clone), "Structure check");
+ $this->assertSame(3, count($clone[7]), "Structure check");
+ $this->assertSame(0, count($clone[7][12]), "Structure check");
+ $this->assertSame(1, count($clone[7][167]), "Structure check");
+ $this->assertSame(0, count($clone[7][167][197]), "Structure check");
+ $this->assertSame(2, count($clone[7][458]), "Structure check");
+ $this->assertSame(1, count($clone[7][458][460]), "Structure check");
+ $this->assertSame(0, count($clone[7][458][460][463]), "Structure check");
+ $this->assertSame(1, count($clone[7][458][464]), "Structure check");
+ $this->assertSame(0, count($clone[7][458][464][471]), "Structure check");
+
+ $object->filter(array(784));
+ $this->assertSame(118, $object->count_messages(), "Messages filter");
+ $this->assertSame(1, $object->count(), "Messages filter (count)");
+ }
}
diff --git a/tests/Framework/SpellcheckAtd.php b/tests/Framework/SpellcheckAtd.php
new file mode 100644
index 000000000..cc828240f
--- /dev/null
+++ b/tests/Framework/SpellcheckAtd.php
@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * Test class to test rcube_spellcheck_atd class
+ *
+ * @package Tests
+ */
+class Framework_SpellcheckAtd extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Class constructor
+ */
+ function test_class()
+ {
+ $object = new rcube_spellcheck_atd(null, 'en');
+
+ $this->assertInstanceOf('rcube_spellcheck_atd', $object, "Class constructor");
+ $this->assertInstanceOf('rcube_spellcheck_engine', $object, "Class constructor");
+ }
+}
diff --git a/tests/Framework/SpellcheckEnchant.php b/tests/Framework/SpellcheckEnchant.php
new file mode 100644
index 000000000..85393e76c
--- /dev/null
+++ b/tests/Framework/SpellcheckEnchant.php
@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * Test class to test rcube_spellcheck_enchant class
+ *
+ * @package Tests
+ */
+class Framework_SpellcheckEnchant extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Class constructor
+ */
+ function test_class()
+ {
+ $object = new rcube_spellcheck_enchant(null, 'en');
+
+ $this->assertInstanceOf('rcube_spellcheck_enchant', $object, "Class constructor");
+ $this->assertInstanceOf('rcube_spellcheck_engine', $object, "Class constructor");
+ }
+}
diff --git a/tests/Framework/SpellcheckGoogie.php b/tests/Framework/SpellcheckGoogie.php
new file mode 100644
index 000000000..dc7d70dcc
--- /dev/null
+++ b/tests/Framework/SpellcheckGoogie.php
@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * Test class to test rcube_spellcheck_googie class
+ *
+ * @package Tests
+ */
+class Framework_SpellcheckGoogie extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Class constructor
+ */
+ function test_class()
+ {
+ $object = new rcube_spellcheck_googie(null, 'en');
+
+ $this->assertInstanceOf('rcube_spellcheck_googie', $object, "Class constructor");
+ $this->assertInstanceOf('rcube_spellcheck_engine', $object, "Class constructor");
+ }
+}
diff --git a/tests/Framework/SpellcheckPspell.php b/tests/Framework/SpellcheckPspell.php
new file mode 100644
index 000000000..bd622b206
--- /dev/null
+++ b/tests/Framework/SpellcheckPspell.php
@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * Test class to test rcube_spellcheck_pspell class
+ *
+ * @package Tests
+ */
+class Framework_SpellcheckPspell extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * Class constructor
+ */
+ function test_class()
+ {
+ $object = new rcube_spellcheck_pspell(null, 'en');
+
+ $this->assertInstanceOf('rcube_spellcheck_pspell', $object, "Class constructor");
+ $this->assertInstanceOf('rcube_spellcheck_engine', $object, "Class constructor");
+ }
+}
diff --git a/tests/Framework/Utils.php b/tests/Framework/Utils.php
index 3f7f48c3a..082aaea3b 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,7 +294,33 @@ class Framework_Utils extends PHPUnit_Framework_TestCase
}
/**
- * rcube:utils::normalize _string()
+ * 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()
{
@@ -302,4 +334,30 @@ class Framework_Utils extends PHPUnit_Framework_TestCase
$this->assertSame($output, $result);
}
}
+
+ /**
+ * rcube:utils::is_absolute_path()
+ */
+ function test_is_absolute_path()
+ {
+ if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
+ $test = array(
+ '' => false,
+ "C:\\" => true,
+ 'some/path' => false,
+ );
+ }
+ else {
+ $test = array(
+ '' => false,
+ '/path' => true,
+ 'some/path' => false,
+ );
+ }
+
+ foreach ($test as $input => $output) {
+ $result = rcube_utils::is_absolute_path($input);
+ $this->assertSame($output, $result);
+ }
+ }
}
diff --git a/tests/Framework/Washtml.php b/tests/Framework/Washtml.php
index cb7234314..7485d4383 100644
--- a/tests/Framework/Washtml.php
+++ b/tests/Framework/Washtml.php
@@ -68,4 +68,60 @@ class Framework_Washtml extends PHPUnit_Framework_TestCase
$this->assertRegExp('|<textarea>test</textarea>|', $washed, "Self-closing textarea (#1489137)");
}
+ /**
+ * Test fixing of invalid closing tags (#1489446)
+ */
+ function test_closing_tag_attrs()
+ {
+ $html = "<a href=\"http://test.com\">test</a href>";
+
+ $washer = new rcube_washtml;
+ $washed = $washer->wash($html);
+
+ $this->assertRegExp('|</a>|', $washed, "Invalid closing tag (#1489446)");
+ }
+
+ /**
+ * Test fixing of invalid lists nesting (#1488768)
+ */
+ function test_lists()
+ {
+ $data = array(
+ array(
+ "<ol><li>First</li><li>Second</li><ul><li>First sub</li></ul><li>Third</li></ol>",
+ "<ol><li>First</li><li>Second<ul><li>First sub</li></ul></li><li>Third</li></ol>"
+ ),
+ array(
+ "<ol><li>First<ul><li>First sub</li></ul></li></ol>",
+ "<ol><li>First<ul><li>First sub</li></ul></li></ol>",
+ ),
+ array(
+ "<ol><li>First<ol><li>First sub</li></ol></li></ol>",
+ "<ol><li>First<ol><li>First sub</li></ol></li></ol>",
+ ),
+ array(
+ "<ul><li>First</li><ul><li>First sub</li><ul><li>sub sub</li></ul></ul><li></li></ul>",
+ "<ul><li>First<ul><li>First sub<ul><li>sub sub</li></ul></li></ul></li><li></li></ul>",
+ ),
+ array(
+ "<ul><li>First</li><li>second</li><ul><ul><li>sub sub</li></ul></ul></ul>",
+ "<ul><li>First</li><li>second<ul><ul><li>sub sub</li></ul></ul></li></ul>",
+ ),
+ array(
+ "<ol><ol><ol></ol></ol></ol>",
+ "<ol><ol><ol></ol></ol></ol>",
+ ),
+ array(
+ "<div><ol><ol><ol></ol></ol></ol></div>",
+ "<div><ol><ol><ol></ol></ol></ol></div>",
+ ),
+ );
+
+ foreach ($data as $element) {
+ rcube_washtml::fix_broken_lists($element[0]);
+
+ $this->assertSame($element[1], $element[0], "Broken nested lists (#1488768)");
+ }
+ }
+
}
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/phpunit.xml b/tests/phpunit.xml
index a5942c433..bd92e585a 100644
--- a/tests/phpunit.xml
+++ b/tests/phpunit.xml
@@ -7,15 +7,20 @@
<file>Framework/Bootstrap.php</file>
<file>Framework/Browser.php</file>
<file>Framework/Cache.php</file>
+ <file>Framework/CacheShared.php</file>
<file>Framework/Charset.php</file>
+ <file>Framework/Contacts.php</file>
<file>Framework/ContentFilter.php</file>
<file>Framework/Csv2vcard.php</file>
+ <file>Framework/DB.php</file>
<file>Framework/Enriched.php</file>
<file>Framework/Html.php</file>
<file>Framework/Html2text.php</file>
<file>Framework/Imap.php</file>
+ <file>Framework/ImapCache.php</file>
<file>Framework/ImapGeneric.php</file>
<file>Framework/Image.php</file>
+ <file>Framework/LdapGeneric.php</file>
<file>Framework/MessageHeader.php</file>
<file>Framework/MessagePart.php</file>
<file>Framework/Mime.php</file>
@@ -24,6 +29,10 @@
<file>Framework/ResultSet.php</file>
<file>Framework/ResultThread.php</file>
<file>Framework/Smtp.php</file>
+ <file>Framework/SpellcheckAtd.php</file>
+ <file>Framework/SpellcheckEnchant.php</file>
+ <file>Framework/SpellcheckGoogie.php</file>
+ <file>Framework/SpellcheckPspell.php</file>
<file>Framework/Spellchecker.php</file>
<file>Framework/StringReplacer.php</file>
<file>Framework/User.php</file>
diff --git a/tests/src/imap_thread.txt b/tests/src/imap_thread.txt
new file mode 100644
index 000000000..88e0a8a66
--- /dev/null
+++ b/tests/src/imap_thread.txt
@@ -0,0 +1 @@
+* THREAD (1)(2)(14)(3)(4 18 39 100)((5)(6)(8 (11)(13 15)(465))(209))(7 (12)(167 197)(458 (460 463)(464 471)))((9)(10 1057))((16 32)(33))(17)(48)(22 23)((19)(314))(20 21)(26)((24 27 1598)(1578)(1580)(1591)(1592)(1593)(1596))((25)(160)(329)(334)(355)(383)(847)(910))(28 30 31)(29)(34 35 36)(37)(38 (42 (72)(96))(107)(106))(40)(41)((43)(330 (336 (366)(367)(380))(1116)(1150)))(45)(44 49 52 55 56 60 61 62 65 66 68 69 70 71 90 91 93 94 95 103 108 109 111 120 123 125 126 129 130 132 134 136 138)(46)((47)(1117)(1122))(50 58 (77)(110 113 117 122 145))(51)(53)(54 57 64 84 87 88 89 92)(59 99)(63)(67)((73)(133)(141))(74 (98)(205))(75 (101)(200)(202))(76 (82)(201)(203))((78)(504)(534)(535))(79)(80)(81)(83)(85)(86)(97)(114)(115)(102 318 (319 320)(332))(104 (466)(468))(105)(112 118 135 144 146)(116)(119)(147)(121)(124)(127)(128)(131)(137)(139)(148)((140)(384)(682)(713)(881)(967)(991)(996)(1010)(1028)(1080)(1088)(1634))(149)(142 143)(150 151)(152)(153 155 161)(154)(168)(156 157)((158)(159)(163)(164))(162)((165)(361)(362))(166 (229)(232)(240 242 247 292))(169 (172)(177)(178)(179 1058))(170)(171)(173)(174 425 431 476 510 511)(188)(175 176)(180 (182 183)(185)(184 1068))((181)(419)(418)(705)(992)(1123)(1374)(1594))(186 (204)(226)(225))((187)(422)(708))(189)(190)(191)(192)(193 215 246)(194 199 218 245 290)(195)(196)(198)(206)(207)(208)(210 211)((212)(213))(214)(216)(217 (219 (220)(221)(227))(223)(224)(222 (1054)(1055)))(234)(228)(230 235 236)(231)(233 772 1566)(237)(238 (244)(251)(257)(258 1061))(239)(241 (590)(873)(874)(900))(243)(248)(249)(250)(252)((253)(255)(338)(339)(340)(341)(436)(437)(438)(439)(441)(442)(447)(450)(512)(513)(514)(597)(598)(601)(604)(605)(635)(646)(649)(652))(254 313)(256)(296)((259)(260)(359)(358))(261)(262)(263)((264)(803)(804))(265)(266 (268)(283))(267)(269)(270)((271)(272))((273)(842)(844))(274 289 303)(275)(277)(276)(278)(279)(280)(281)(282)((284)(433))((285)(595))(286)(295)(287)(288)(291 310)(293)(294)(297 299)((298)(574)(777)(1083)(1161)(1440)(1711))(300)(301 348 356 357 360 365 392)(302 (304)(305)(323)(324 1059))(306)(308)(307)(309 364)(311)((312)(573))(315)((317)(316))((344)(326))(321)(322)(342)(325)(345)(353 354 (698)(707))(343)(327 328 331)(333)((335)(400))(337)(346 (350)(370)(371)(372 1060))(347)(349 388 524 566 577 690 1491)(351)(352)(363)(368)(369)(390)(373)((374)(376))(375)(377)(378 589)(379)(381)((382)(588)(592)(1496))(385)(386)(387 399 426)(389 397 427)(391)(393)(394)(407)(395 396)(398 408)(401 (402 403)(404 (405 (410)(415))(406 (416)(443)(638)(1291)(1522))(413 414 (448 (449)(451)(478))(484)(485 (477)(515 (527)(554))(1521)))))(409)(411)(412)(428)((417)(480)(482))(420 (421)(564)(565))((423)(808))(424)(429)(430 446)(432)(434)(435)(440 445 (454 470)(456))((444)(555 (763)(764)))(452 (453)(459)(461)(462)(473)(475 1063))(455 457)(518)(467)(469 474 (483)(539)(540))(472)(479 486 525 528 530)(481 (487)(489)(506)(507 1062))(488)(490 (491)(492)(496)(498)(500)(502)(509)(521)(946)(1404)(1681)(1682)(1683)(1685)(1686)(1693)(1721))(494)(493)((495)(1079)(1401)(1582))(497)(499)(501)(503)((505)(517)(520))(508 523)(516)(519)(522)(526 529)(531)(532 538 582)(533)(536)(537)(541 614)((542)(543)(546)(547)(572))(544 545)(548)(549 (550)(551)(553)(552 1056))(556 (559)(562)(563))(557 (558)(561)(560))((567)(1502))(569)(568)(570)((571)(749)(751)(752)(757)(760)(776)(775)(1034)(1035)(1076))(575)(576 579)(578)(580)(581)(583)(584)(585)(586)(587)(591)(593)(594)(624)(596)(625)(628)(599 (600)(603 617)(619)(620)(621 1064))(602 (613 (615)(618))(616 (622)(675)))(606 607 608 609 (610 612)(629))(611)(623)(627)(626)(630)(631)(632)(633)((634)(650)(651))(636 (641 677)(848)(1595 1597))(637)(642 644 645)(639 640)(643)(669)(647)(648)(653)(654)(655)(656 (657)(659)(660 1065))(658 (661 665)(662))(663 664 666)(667)(668)((670)(1008))(671 686)(674)(672)(673)(688)(676)(678)(679 681)(680)(683)(684 689)(685)(687)(691)(692)(693)(699)((694)(704))(695)(696 715 853 899)(697)(700 (701)(710)(720)(721 1066))(702)(703)(709)(706)(711)(712)(714)(716 734)(717)(718 724 (727)(728 730 732 733 735))(719 723 731)(722 729)(725)(726)(736)(738)((737)(1620))(754)(739)(740 (741)(742 (743)(745)(746)(761))(744)(765 (766)(767)))(747)(748)(753)(750)(755)(756)(758)(759)(762)(768)(769)(770)(774)(771)(773)(779)(778)(780)(781)(782)(783)(784 786 787 788 790 791 793 795 796 798 802 805 809 815 (816)(817 818 821 822 824 825 827 829 830 831 832 833 834 836 838 839 840 841 854 856 862 863 879 882 884 885 886 888 890 892 894 895 896 897 898 908 912 924 926 941 943 947 948 952 956 957 958 959 960 961 962 963 964 965 970 971 973 974 975 976 978 979 980 981 982 984 985 986 987 989 993 994 995 997 1000 1002 1003 1007 1009 1011 1013 1014 1015 1016 1018 1020 1021 1022 1023 1027 1029 1031 1033 1040 1041 1043 1044 1045 1047 1048 1049 1052 1053))(785)(789 792)(811)(794)(812)(797)(799)(800)(801)(806)(807)(810 813)(823)(814)(872)(819 (820)(826)(843 845)(916 (921)(923)(922 1067)))(828)(866)(837)(835)((868)(867)(869))(846)(871)(870)(849)(850 (883)(903 (938)(1515)))(851)(852)((855)(857))(858)(859 (928)(933)(935))(860 (929)(931)(934))(861 (930)(932)(936))(864 1469)(865 889 940)(875)(876 (877)(878)(901)(966))(880 939)(905)(887)(891)(893)(902)(904)(907)(906 1102)(909 969)(911)(913 (914 915)(917 918)(919 937)(920 927 942 944 945 1051 (1073 1081)(1103 1106 1125)))(925)(949)(950)(951)(953)(954)(955)(972)(968 (1113)(1147 (1114)(1115)(1148)))(977)(983)(998)(988 1104)(990)(1036)(999 1019)(1004)(1001)(1005 1006 (1279)(1285 1290))(1012)(1017)(1038)(1037)(1024 (1025)(1096)(1097)(1403))(1026)(1030)(1032)(1039)(1042)(1046)(1050)(1084)((1069)(1070))(1071)(1072)(1074)(1075 1078)(1077)(1082)(1085)((1086)(1091))(1087)(1089)(1090)(1093)(1092)(1094)(1095)(1098)(1099)(1100)((1107)(1204))(1101)(1108)(1105 (1152 1395)(1605))((1112 1215 1228)(1231 1233)(1230))(1109)(1110)(1111)(1118)(1119)(1149 (1124 1146 1151)(1218 1219)(1220)(1474))(1120)(1121)(1126)(1127)(1128 1136)(1129)(1130)(1140)(1131)(1132)(1133)(1134 1135)(1137 1138 1203)(1139)(1141)(1142)(1143)(1144)(1145)(1153)(1154)(1155)(1156)(1157)(1158)(1205)((1159)(1160))(1207)((1162)(1481))(1206)(1163)(1164)(1165)(1211 (1241 1366)(1367)(1368 1369))(1166 (1183)(1238 (1239)(1303)(1300)))(1167 (1184)(1334)(1310))(1168 (1185)(1296)(1341))(1169 (1186)(1308)(1337))(1170 (1187)(1240 (1242)(1306)(1298)))(1171 (1188)(1295)(1336))(1172 (1189)(1343)(1339))(1173 (1190)(1299)(1333))(1174 (1191)(1309)(1312))(1175 (1198)(1307)(1332))(1176 (1192)(1335)(1311))(1177 (1193)(1301)(1342))(1178 (1194)(1305)(1314))(1179 (1195)(1302)(1313))(1180 (1196)(1340)(1297))(1181 (1182)(1197)(1304)(1338))(1199)(1200 1201)(1202 1225 1365)(1208)(1209)(1210)(1212 (1216 1236)(1217 1280))(1213)(1221)(1214)(1222)(1223)(1224)(1226)(1227)(1229)(1232 1234 1235)(1282)(1237)(1243 (1259)(1315))(1244 (1260)(1316))(1245 (1261)(1317))(1246 (1262)(1318))(1247 (1263)(1319))(1248 (1264)(1320))(1249 (1265)(1321))(1250 (1266)(1322))(1251 (1268)(1323))(1252 (1269)(1324))(1253 (1270)(1325))(1254 (1271)(1326))(1255 (1272)(1327))(1256 (1273)(1328))(1257 (1274)(1329))(1258 (1267 1276 1277 1278 1331)(1275)(1330))(1281)(1283)(1284)(1370)(1286)((1287)(1288)(1289)(1375)(1377)(1376)(1378)(1380)(1386)(1387))((1292)(1293)(1294)(1381)(1382)(1383)(1384)(1385))(1344 (1354)(1453)(1461))(1346 (1355)(1455)(1472))(1345 (1356)(1392 (1393 1424)(1458)(1459)))(1347 (1357)(1468)(1473))(1348 (1358)(1426 (1431)(1467)(1462)))(1349 (1359)(1465)(1470))(1350 (1360 1362)(1428 (1432)(1456)(1460)))(1351 (1361)(1466)(1463))(1352 (1363)(1430 (1433)(1454)(1464)))(1353 (1364)(1457)(1471))(1371 (1425 1483)(1450 1484 1489))(1372)(1373)(1379)(1388)(1389)(1390)(1391)((1394 1397 1398)(1421))(1396 1400)(1399)(1402)(1405)(1406)(1407 1410)(1408 (1579)(1583 1584 (1585)(1586)))(1409)(1411)(1412)(1413)(1416)(1414)(1415)(1417)(1418)(1419)(1420)(1422)((1442)(1427))(1423)(1429)(1434 (1435)(1451)(1452))(1436)(1439)(1441)(1437)(1438 1495 (1559)(1561))(1443)(1444)(1445)(1446)(1507)(1447)(1448)(1449)(1506)(1475)(1476)(1505)((1477)(1478))((1479)(1480))(1482)(1485)(1486)(1487)(1488)(1490)(1492)(1493)(1494)(1497 (1498)(1644)(1645))(1499)(1500)(1501 1704)(1503)(1504)(1508)(1509)(1510)(1519 (1520)(1523))(1511 1512 1513 1516)(1562)(1514)(1517)(1518)(1524 (1540)(1647)(1666))(1525 (1541)(1656)(1646))(1526 (1542 1643)(1573))(1527 (1543)(1574 1641))(1528 (1544)(1650)(1663))(1529 (1545)(1654)(1649))(1530 1546 1575)(1531 (1547)(1651)(1653))(1532 (1548)(1658)(1672))(1533 (1549)(1665)(1662))(1534 (1550 1603)(1576))(1535 (1551)(1648)(1667))(1536 (1552)(1652)(1669))(1537 (1553)(1655)(1668))(1538 (1554 1604)(1577 (1640)(1657)(1670)))(1539 (1555)(1661)(1671))(1556)(1557)(1558)(1560 1567)(1563)(1564)(1565)(1587)(1568 (1569)(1570)(1581))(1571)(1572 (1589 (1612)(1613)(1617))(1599 1600)(1601)(1602))(1588)(1590)(1606)(1607 1608 (1610)(1629))(1609 (1614)(1618)(1619))(1611)(1615)(1616)(1621 (1622)(1624)(1623 1627)(1628 1632 (1637 1673 1675 1678)(1664)))(1625 1626)(1630)((1631 1635)(1633))(1636 1638)(1639)(1642 (1659)(1660 1679)(1674 1680))(1676)(1677 1684)(1687)(1720)(1689)(1688)(1690 1697)(1691 1694)(1692)(1695)(1696)(1713)(1698)(1699)(1700)(1701 1707)(1702)(1703)(1705 1706)(1708)(1709)(1710)(1712)(1714)(1715)(1716)(1717)(1718)(1719) \ No newline at end of file
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;}