diff options
Diffstat (limited to 'tests/Framework')
-rw-r--r-- | tests/Framework/Browser.php | 52 | ||||
-rw-r--r-- | tests/Framework/CacheShared.php | 20 | ||||
-rw-r--r-- | tests/Framework/Contacts.php | 20 | ||||
-rw-r--r-- | tests/Framework/DB.php | 20 | ||||
-rw-r--r-- | tests/Framework/Html2text.php | 28 | ||||
-rw-r--r-- | tests/Framework/ImapCache.php | 20 | ||||
-rw-r--r-- | tests/Framework/LdapGeneric.php | 20 | ||||
-rw-r--r-- | tests/Framework/Mime.php | 2 | ||||
-rw-r--r-- | tests/Framework/ResultIndex.php | 47 | ||||
-rw-r--r-- | tests/Framework/ResultThread.php | 39 | ||||
-rw-r--r-- | tests/Framework/SpellcheckAtd.php | 21 | ||||
-rw-r--r-- | tests/Framework/SpellcheckEnchant.php | 21 | ||||
-rw-r--r-- | tests/Framework/SpellcheckGoogie.php | 21 | ||||
-rw-r--r-- | tests/Framework/SpellcheckPspell.php | 21 | ||||
-rw-r--r-- | tests/Framework/Utils.php | 60 | ||||
-rw-r--r-- | tests/Framework/Washtml.php | 56 |
16 files changed, 456 insertions, 12 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)"); + } + } + } |