diff options
Diffstat (limited to 'tests/Framework')
-rw-r--r-- | tests/Framework/Browser.php | 33 | ||||
-rw-r--r-- | tests/Framework/Mime.php | 4 | ||||
-rw-r--r-- | tests/Framework/ResultThread.php | 41 | ||||
-rw-r--r-- | tests/Framework/StringReplacer.php | 16 | ||||
-rw-r--r-- | tests/Framework/Utils.php | 32 | ||||
-rw-r--r-- | tests/Framework/Washtml.php | 56 |
6 files changed, 171 insertions, 11 deletions
diff --git a/tests/Framework/Browser.php b/tests/Framework/Browser.php index 832d4bf14..a042572a8 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,25 @@ 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 + ), ); } diff --git a/tests/Framework/Mime.php b/tests/Framework/Mime.php index 4db1856be..1450b4f90 100644 --- a/tests/Framework/Mime.php +++ b/tests/Framework/Mime.php @@ -197,6 +197,10 @@ class Framework_Mime extends PHPUnit_Framework_TestCase array("http://xx.xxx.xx.xxx:8080/addressbooks/roundcubexxxxx%40xxxxxxxxxxxxxxxxxxxxxxx.xx.xx/testing/", 70), "http://xx.xxx.xx.xxx:8080/addressbooks/roundcubexxxxx%40xxxxxxxxxxxxxxxxxxxxxxx.xx.xx/testing/", ), + array( + array("this-is-just-some-blabla-to-make-this-more-than-seventy-five-characters-in-a-row -- this line should be wrapped", 20, "\n"), + "this-is-just-some-blabla-to-make-this-more-than-seventy-five-characters-in-a-row\n-- this line should\nbe wrapped", + ), ); foreach ($samples as $sample) { diff --git a/tests/Framework/ResultThread.php b/tests/Framework/ResultThread.php index f980845cc..8f5c5092f 100644 --- a/tests/Framework/ResultThread.php +++ b/tests/Framework/ResultThread.php @@ -17,4 +17,45 @@ 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)"); + +//echo $object->get_compressed(); + } } diff --git a/tests/Framework/StringReplacer.php b/tests/Framework/StringReplacer.php index e23fb9b17..0fa7fae34 100644 --- a/tests/Framework/StringReplacer.php +++ b/tests/Framework/StringReplacer.php @@ -56,4 +56,20 @@ class Framework_StringReplacer extends PHPUnit_Framework_TestCase $this->assertEquals($output, $result); } + + function test_linkrefs() + { + $input = "This is a sample message [1] to test the new linkref [ref0] replacement feature of [Roundcube].\n"; + $input.= "\n"; + $input.= "[1] http://en.wikipedia.org/wiki/Email\n"; + $input.= "[ref0] www.link-ref.com\n"; + + $replacer = new rcube_string_replacer; + $result = $replacer->replace($input); + $result = $replacer->resolve($result); + + $this->assertContains('[<a href="http://en.wikipedia.org/wiki/Email">1</a>] to', $result, "Numeric linkref replacements"); + $this->assertContains('[<a href="http://www.link-ref.com">ref0</a>] repl', $result, "Alphanum linkref replacements"); + $this->assertContains('of [Roundcube].', $result, "Don't touch strings wihtout an index entry"); + } } 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/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)"); + } + } + } |