diff options
Diffstat (limited to 'tests/Framework')
-rw-r--r-- | tests/Framework/ImapGeneric.php | 23 | ||||
-rw-r--r-- | tests/Framework/Utils.php | 65 | ||||
-rw-r--r-- | tests/Framework/Washtml.php | 15 |
3 files changed, 102 insertions, 1 deletions
diff --git a/tests/Framework/ImapGeneric.php b/tests/Framework/ImapGeneric.php index 2f9b6d10f..af73158e5 100644 --- a/tests/Framework/ImapGeneric.php +++ b/tests/Framework/ImapGeneric.php @@ -35,4 +35,27 @@ class Framework_ImapGeneric extends PHPUnit_Framework_TestCase $this->assertSame(array(1, 2, 3), $result); $this->assertCount(3, $result); } + + /** + * Test for tokenizeResponse + */ + function test_tokenizeResponse() + { + $response = "test brack[et] {1}\r\na {0}\r\n (item1 item2)"; + + $result = rcube_imap_generic::tokenizeResponse($response, 1); + $this->assertSame("test", $result); + + $result = rcube_imap_generic::tokenizeResponse($response, 1); + $this->assertSame("brack[et]", $result); + + $result = rcube_imap_generic::tokenizeResponse($response, 1); + $this->assertSame("a", $result); + + $result = rcube_imap_generic::tokenizeResponse($response, 1); + $this->assertSame("", $result); + + $result = rcube_imap_generic::tokenizeResponse($response, 1); + $this->assertSame(array('item1', 'item2'), $result); + } } diff --git a/tests/Framework/Utils.php b/tests/Framework/Utils.php index 7c1e92ac8..abfb7cb65 100644 --- a/tests/Framework/Utils.php +++ b/tests/Framework/Utils.php @@ -195,6 +195,23 @@ class Framework_Utils extends PHPUnit_Framework_TestCase } /** + * Check rcube_utils::explode_quoted_string() + */ + function test_explode_quoted_string() + { + $data = array( + '"a,b"' => array('"a,b"'), + '"a,b","c,d"' => array('"a,b"','"c,d"'), + '"a,\\"b",d' => array('"a,\\"b"', 'd'), + ); + + foreach ($data as $text => $res) { + $result = rcube_utils::explode_quoted_string(',', $text); + $this->assertSame($res, $result); + } + } + + /** * Check rcube_utils::explode_quoted_string() compat. with explode() */ function test_explode_quoted_string_compat() @@ -229,4 +246,52 @@ class Framework_Utils extends PHPUnit_Framework_TestCase } } + /** + * rcube:utils::file2class() + */ + function test_file2class() + { + $test = array( + array('', '', 'unknown'), + array('text', 'text', 'text'), + array('image/png', 'image.png', 'image png'), + ); + + foreach ($test as $v) { + $result = rcube_utils::file2class($v[0], $v[1]); + $this->assertSame($v[2], $result); + } + } + + /** + * rcube:utils::strtotime() + */ + function test_strtotime() + { + $test = array( + '1' => 1, + '' => 0, + ); + + foreach ($test as $datetime => $ts) { + $result = rcube_utils::strtotime($datetime); + $this->assertSame($ts, $result); + } + } + + /** + * rcube:utils::normalize _string() + */ + function test_normalize_string() + { + $test = array( + '' => '', + 'abc def' => 'abc def', + ); + + foreach ($test as $input => $output) { + $result = rcube_utils::normalize_string($input); + $this->assertSame($output, $result); + } + } } diff --git a/tests/Framework/Washtml.php b/tests/Framework/Washtml.php index cd443266f..cb7234314 100644 --- a/tests/Framework/Washtml.php +++ b/tests/Framework/Washtml.php @@ -47,7 +47,7 @@ class Framework_Washtml extends PHPUnit_Framework_TestCase $html = "<!--[if gte mso 10]><p>p1</p><!--><p>p2</p>"; $washed = $washer->wash($html); - $this->assertEquals('<!-- html ignored --><!-- body ignored --><p>p2</p>', $washed, "HTML conditional comments (#1489004)"); + $this->assertEquals('<!-- node type 8 --><!-- html ignored --><!-- body ignored --><p>p2</p>', $washed, "HTML conditional comments (#1489004)"); $html = "<!--TestCommentInvalid><p>test</p>"; $washed = $washer->wash($html); @@ -55,4 +55,17 @@ class Framework_Washtml extends PHPUnit_Framework_TestCase $this->assertEquals('<!-- html ignored --><!-- body ignored --><p>test</p>', $washed, "HTML invalid comments (#1487759)"); } + /** + * Test fixing of invalid self-closing elements (#1489137) + */ + function test_self_closing() + { + $html = "<textarea>test"; + + $washer = new rcube_washtml; + $washed = $washer->wash($html); + + $this->assertRegExp('|<textarea>test</textarea>|', $washed, "Self-closing textarea (#1489137)"); + } + } |