From e824925290a0fdf3852f4562dc459a4cbd4e5768 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Thu, 16 Aug 2012 19:44:28 +0200 Subject: Rewritten test scripts for PHPUnit --- tests/bootstrap.php | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/bootstrap.php (limited to 'tests/bootstrap.php') diff --git a/tests/bootstrap.php b/tests/bootstrap.php new file mode 100644 index 000000000..b32112592 --- /dev/null +++ b/tests/bootstrap.php @@ -0,0 +1,33 @@ + | + | Author: Aleksander Machniak | + +-----------------------------------------------------------------------+ +*/ + +if (php_sapi_name() != 'cli') + die("Not in shell mode (php-cli)"); + +if (!defined('INSTALL_PATH')) define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' ); + +define('TESTS_DIR', dirname(__FILE__) . '/'); + +if (@is_dir(TESTS_DIR . 'config')) { + define('RCMAIL_CONFIG_DIR', TESTS_DIR . 'config'); +} + +require_once(INSTALL_PATH . 'program/include/iniset.php'); -- cgit v1.2.3 From 9b05f19338e209f05386e5b13fe0a704c94062bb Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Mon, 27 Aug 2012 08:45:13 +0200 Subject: Restructured tests --- tests/Framework/Mime.php | 123 ++++++++++++++++++++++++++++++++++ tests/Framework/Shared.php | 161 +++++++++++++++++++++++++++++++++++++++++++++ tests/Framework/Utils.php | 119 +++++++++++++++++++++++++++++++++ tests/Framework/VCard.php | 59 +++++++++++++++++ tests/MailDecode.php | 123 ---------------------------------- tests/ModCss.php | 39 ----------- tests/Utils.php | 85 ------------------------ tests/VCards.php | 59 ----------------- tests/bootstrap.php | 2 + tests/phpunit.xml | 9 ++- 10 files changed, 468 insertions(+), 311 deletions(-) create mode 100644 tests/Framework/Mime.php create mode 100644 tests/Framework/Shared.php create mode 100644 tests/Framework/Utils.php create mode 100644 tests/Framework/VCard.php delete mode 100644 tests/MailDecode.php delete mode 100644 tests/ModCss.php delete mode 100644 tests/Utils.php delete mode 100644 tests/VCards.php (limited to 'tests/bootstrap.php') diff --git a/tests/Framework/Mime.php b/tests/Framework/Mime.php new file mode 100644 index 000000000..dcd55992a --- /dev/null +++ b/tests/Framework/Mime.php @@ -0,0 +1,123 @@ + 'test@domain.tld', + 1 => '', + 2 => 'Test ', + 3 => 'Test Test ', + 4 => 'Test Test', + 5 => '"Test Test" ', + 6 => '"Test Test"', + 7 => '"Test \\" Test" ', + 8 => '"Test', + 9 => '=?ISO-8859-1?B?VGVzdAo=?= ', + 10 => '=?ISO-8859-1?B?VGVzdAo=?=', // #1487068 + // comments in address (#1487673) + 11 => 'Test (comment) ', + 12 => '"Test" (comment) ', + 13 => '"Test (comment)" (comment) ', + 14 => '(comment) ', + 15 => 'Test ', + 16 => 'Test Test ((comment)) ', + 17 => 'test@domain.tld (comment)', + 18 => '"Test,Test" ', + // 1487939 + 19 => 'Test <"test test"@domain.tld>', + 20 => '<"test test"@domain.tld>', + 21 => '"test test"@domain.tld', + ); + + $results = array( + 0 => array(1, '', 'test@domain.tld'), + 1 => array(1, '', 'test@domain.tld'), + 2 => array(1, 'Test', 'test@domain.tld'), + 3 => array(1, 'Test Test', 'test@domain.tld'), + 4 => array(1, 'Test Test', 'test@domain.tld'), + 5 => array(1, 'Test Test', 'test@domain.tld'), + 6 => array(1, 'Test Test', 'test@domain.tld'), + 7 => array(1, 'Test " Test', 'test@domain.tld'), + 8 => array(1, 'Test array(1, 'Test', 'test@domain.tld'), + 10 => array(1, 'Test', 'test@domain.tld'), + 11 => array(1, 'Test', 'test@domain.tld'), + 12 => array(1, 'Test', 'test@domain.tld'), + 13 => array(1, 'Test (comment)', 'test@domain.tld'), + 14 => array(1, '', 'test@domain.tld'), + 15 => array(1, 'Test', 'test@domain.tld'), + 16 => array(1, 'Test Test', 'test@domain.tld'), + 17 => array(1, '', 'test@domain.tld'), + 18 => array(1, 'Test,Test', 'test@domain.tld'), + 19 => array(1, 'Test', '"test test"@domain.tld'), + 20 => array(1, '', '"test test"@domain.tld'), + 21 => array(1, '', '"test test"@domain.tld'), + ); + + foreach ($headers as $idx => $header) { + $res = rcube_mime::decode_address_list($header); + + $this->assertEquals($results[$idx][0], count($res), "Rows number in result for header: " . $header); + $this->assertEquals($results[$idx][1], $res[1]['name'], "Name part decoding for header: " . $header); + $this->assertEquals($results[$idx][2], $res[1]['mailto'], "Email part decoding for header: " . $header); + } + } + + /** + * Test decoding of header values + * Uses rcube_mime::decode_mime_string() + */ + function test_header_decode_qp() + { + $test = array( + // #1488232: invalid character "?" + 'quoted-printable (1)' => array( + 'in' => '=?utf-8?Q?Certifica=C3=A7=C3=A3??=', + 'out' => 'Certifica=C3=A7=C3=A3?', + ), + 'quoted-printable (2)' => array( + 'in' => '=?utf-8?Q?Certifica=?= =?utf-8?Q?C3=A7=C3=A3?=', + 'out' => 'Certifica=C3=A7=C3=A3', + ), + 'quoted-printable (3)' => array( + 'in' => '=?utf-8?Q??= =?utf-8?Q??=', + 'out' => '', + ), + 'quoted-printable (4)' => array( + 'in' => '=?utf-8?Q??= a =?utf-8?Q??=', + 'out' => ' a ', + ), + 'quoted-printable (5)' => array( + 'in' => '=?utf-8?Q?a?= =?utf-8?Q?b?=', + 'out' => 'ab', + ), + 'quoted-printable (6)' => array( + 'in' => '=?utf-8?Q? ?= =?utf-8?Q?a?=', + 'out' => ' a', + ), + 'quoted-printable (7)' => array( + 'in' => '=?utf-8?Q?___?= =?utf-8?Q?a?=', + 'out' => ' a', + ), + ); + + foreach ($test as $idx => $item) { + $res = rcube_mime::decode_mime_string($item['in'], 'UTF-8'); + $res = quoted_printable_encode($res); + + $this->assertEquals($item['out'], $res, "Header decoding for: " . $idx); + } + } +} diff --git a/tests/Framework/Shared.php b/tests/Framework/Shared.php new file mode 100644 index 000000000..d38fb03a3 --- /dev/null +++ b/tests/Framework/Shared.php @@ -0,0 +1,161 @@ +assertTrue($result, $title); + + $result = in_array_nocase($needle, null); + + $this->assertFalse($result, $title); + } + + /** + * rcube_shared.inc: get_boolean() + */ + function test_get_boolean() + { + $input = array( + false, 'false', '0', 'no', 'off', 'nein', 'FALSE', '', null, + ); + + foreach ($input as $idx => $value) { + $this->assertFalse(get_boolean($value), "Invalid result for $idx test item"); + } + + $input = array( + true, 'true', '1', 1, 'yes', 'anything', 1000, + ); + + foreach ($input as $idx => $value) { + $this->assertTrue(get_boolean($value), "Invalid result for $idx test item"); + } + } + + /** + * rcube_shared.inc: parse_bytes() + */ + function test_parse_bytes() + { + $data = array( + '1' => 1, + '1024' => 1024, + '2k' => 2 * 1024, + '2 k' => 2 * 1024, + '2kb' => 2 * 1024, + '2kB' => 2 * 1024, + '2m' => 2 * 1048576, + '2 m' => 2 * 1048576, + '2mb' => 2 * 1048576, + '2mB' => 2 * 1048576, + '2g' => 2 * 1024 * 1048576, + '2 g' => 2 * 1024 * 1048576, + '2gb' => 2 * 1024 * 1048576, + '2gB' => 2 * 1024 * 1048576, + ); + + foreach ($data as $value => $expected) { + $result = parse_bytes($value); + $this->assertEquals($expected, $result, "Invalid parse_bytes() result for $value"); + } + } + + /** + * rcube_shared.inc: slashify() + */ + function test_slashify() + { + $data = array( + 'test' => 'test/', + 'test/' => 'test/', + '' => '/', + "\\" => "\\/", + ); + + foreach ($data as $value => $expected) { + $result = slashify($value); + $this->assertEquals($expected, $result, "Invalid slashify() result for $value"); + } + + } + + /** + * rcube_shared.inc: unslashify() + */ + function test_unslashify() + { + $data = array( + 'test' => 'test', + 'test/' => 'test', + '/' => '', + "\\/" => "\\", + 'test/test' => 'test/test', + 'test//' => 'test', + ); + + foreach ($data as $value => $expected) { + $result = unslashify($value); + $this->assertEquals($expected, $result, "Invalid unslashify() result for $value"); + } + + } + + /** + * rcube_shared.inc: get_offset_sec() + */ + function test_get_offset_sec() + { + $data = array( + '1s' => 1, + '1m' => 1 * 60, + '1h' => 1 * 60 * 60, + '1d' => 1 * 60 * 60 * 24, + '1w' => 1 * 60 * 60 * 24 * 7, + '1y' => (int) '1y', + 100 => 100, + '100' => 100, + ); + + foreach ($data as $value => $expected) { + $result = get_offset_sec($value); + $this->assertEquals($expected, $result, "Invalid get_offset_sec() result for $value"); + } + + } + + /** + * rcube_shared.inc: array_keys_recursive() + */ + function test_array_keys_recursive() + { + $input = array( + 'one' => array( + 'two' => array( + 'three' => array(), + 'four' => 'something', + ), + ), + 'five' => 'test', + ); + + $result = array_keys_recursive($input); + $input_str = 'one,two,three,four,five'; + $result_str = implode(',', $result); + + $this->assertEquals($input_str, $result_str, "Invalid array_keys_recursive() result"); + } +} diff --git a/tests/Framework/Utils.php b/tests/Framework/Utils.php new file mode 100644 index 000000000..b6cc5d577 --- /dev/null +++ b/tests/Framework/Utils.php @@ -0,0 +1,119 @@ +', 'Encoded html within email is invalid'), + array('email.domain.com', 'Missing @'), + array('email@domain@domain.com', 'Two @ sign'), + array('.email@domain.com', 'Leading dot in address is not allowed'), + array('email.@domain.com', 'Trailing dot in address is not allowed'), + array('email..email@domain.com', 'Multiple dots'), + array('あいうえお@domain.com', 'Unicode char as address'), + array('email@domain.com (Joe Smith)', 'Text followed email is not allowed'), + array('email@domain', 'Missing top level domain (.com/.net/.org/etc)'), + array('email@-domain.com', 'Leading dash in front of domain is invalid'), +// array('email@domain.web', '.web is not a valid top level domain'), + array('email@123.123.123.123', 'IP address without brackets'), + array('email@2001:2d12:c4fe:5afe::1', 'IPv6 address without brackets'), + array('email@IPv6:2001:2d12:c4fe:5afe::1', 'IPv6 address without brackets (2)'), + array('email@[111.222.333.44444]', 'Invalid IP format'), + array('email@[111.222.255.257]', 'Invalid IP format (2)'), + array('email@[.222.255.257]', 'Invalid IP format (3)'), + array('email@[::1]', 'Invalid IPv6 format (1)'), + array('email@[IPv6:2001:23x2:1]', 'Invalid IPv6 format (2)'), + array('email@[IPv6:1111:2222:33333::4444:5555]', 'Invalid IPv6 format (3)'), + array('email@[IPv6:1111::3333::4444:5555]', 'Invalid IPv6 format (4)'), + array('email@domain..com', 'Multiple dot in the domain portion is invalid'), + ); + } + + /** + * @dataProvider data_valid_email + */ + function test_valid_email($email, $title) + { + $this->assertTrue(rcube_utils::check_email($email, false), $title); + } + + /** + * @dataProvider data_invalid_email + */ + function test_invalid_email($email, $title) + { + $this->assertFalse(rcube_utils::check_email($email, false), $title); + } + + /** + * rcube_utils::mod_css_styles() + */ + function test_mod_css_styles() + { + $css = file_get_contents(TESTS_DIR . 'src/valid.css'); + $mod = rcube_utils::mod_css_styles($css, 'rcmbody'); + + $this->assertRegExp('/#rcmbody\s+\{/', $mod, "Replace body style definition"); + $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"); + } + + /** + * rcube_utils::mod_css_styles() + */ + function test_mod_css_styles_xss() + { + $mod = rcube_utils::mod_css_styles("body.main2cols { background-image: url('../images/leftcol.png'); }", 'rcmbody'); + $this->assertEquals("/* evil! */", $mod, "No url() values allowed"); + + $mod = rcube_utils::mod_css_styles("@import url('http://localhost/somestuff/css/master.css');", 'rcmbody'); + $this->assertEquals("/* evil! */", $mod, "No import statements"); + + $mod = rcube_utils::mod_css_styles("left:expression(document.body.offsetWidth-20)", 'rcmbody'); + $this->assertEquals("/* evil! */", $mod, "No expression properties"); + + $mod = rcube_utils::mod_css_styles("left:exp/* */ression( alert('xss3') )", 'rcmbody'); + $this->assertEquals("/* evil! */", $mod, "Don't allow encoding quirks"); + + $mod = rcube_utils::mod_css_styles("background:\\0075\\0072\\006c( javascript:alert('xss') )", 'rcmbody'); + $this->assertEquals("/* evil! */", $mod, "Don't allow encoding quirks (2)"); + } +} diff --git a/tests/Framework/VCard.php b/tests/Framework/VCard.php new file mode 100644 index 000000000..a830c2cbc --- /dev/null +++ b/tests/Framework/VCard.php @@ -0,0 +1,59 @@ +_srcpath('apple.vcf'))); + + $this->assertTrue($vcard->business, "Identify as business record"); + $this->assertEquals("Apple Computer AG", $vcard->displayname, "FN => displayname"); + $this->assertEquals("", $vcard->firstname, "No person name set"); + } + + function test_parse_two() + { + $vcard = new rcube_vcard(file_get_contents($this->_srcpath('johndoe.vcf')), null); + + $this->assertFalse($vcard->business, "Identify as private record"); + $this->assertEquals("John Doë", $vcard->displayname, "Decode according to charset attribute"); + $this->assertEquals("roundcube.net", $vcard->organization, "Test organization field"); + $this->assertCount(2, $vcard->email, "List two e-mail addresses"); + $this->assertEquals("roundcube@gmail.com", $vcard->email[0], "Use PREF e-mail as primary"); + } + + function test_import() + { + $input = file_get_contents($this->_srcpath('apple.vcf')); + $input .= file_get_contents($this->_srcpath('johndoe.vcf')); + + $vcards = rcube_vcard::import($input); + + $this->assertCount(2, $vcards, "Detected 2 vcards"); + $this->assertEquals("Apple Computer AG", $vcards[0]->displayname, "FN => displayname"); + $this->assertEquals("John Doë", $vcards[1]->displayname, "Displayname with correct charset"); + + // http://trac.roundcube.net/ticket/1485542 + $vcards2 = rcube_vcard::import(file_get_contents($this->_srcpath('thebat.vcf'))); + $this->assertEquals("Iksiñski", $vcards2[0]->surname, "Detect charset in encoded values"); + } + + function test_encodings() + { + $input = file_get_contents($this->_srcpath('utf-16_sample.vcf')); + + $vcards = rcube_vcard::import($input); + $this->assertEquals("Ǽgean ĽdaMonté", $vcards[0]->displayname, "Decoded from UTF-16"); + } +} diff --git a/tests/MailDecode.php b/tests/MailDecode.php deleted file mode 100644 index 7969603dd..000000000 --- a/tests/MailDecode.php +++ /dev/null @@ -1,123 +0,0 @@ - 'test@domain.tld', - 1 => '', - 2 => 'Test ', - 3 => 'Test Test ', - 4 => 'Test Test', - 5 => '"Test Test" ', - 6 => '"Test Test"', - 7 => '"Test \\" Test" ', - 8 => '"Test', - 9 => '=?ISO-8859-1?B?VGVzdAo=?= ', - 10 => '=?ISO-8859-1?B?VGVzdAo=?=', // #1487068 - // comments in address (#1487673) - 11 => 'Test (comment) ', - 12 => '"Test" (comment) ', - 13 => '"Test (comment)" (comment) ', - 14 => '(comment) ', - 15 => 'Test ', - 16 => 'Test Test ((comment)) ', - 17 => 'test@domain.tld (comment)', - 18 => '"Test,Test" ', - // 1487939 - 19 => 'Test <"test test"@domain.tld>', - 20 => '<"test test"@domain.tld>', - 21 => '"test test"@domain.tld', - ); - - $results = array( - 0 => array(1, '', 'test@domain.tld'), - 1 => array(1, '', 'test@domain.tld'), - 2 => array(1, 'Test', 'test@domain.tld'), - 3 => array(1, 'Test Test', 'test@domain.tld'), - 4 => array(1, 'Test Test', 'test@domain.tld'), - 5 => array(1, 'Test Test', 'test@domain.tld'), - 6 => array(1, 'Test Test', 'test@domain.tld'), - 7 => array(1, 'Test " Test', 'test@domain.tld'), - 8 => array(1, 'Test array(1, 'Test', 'test@domain.tld'), - 10 => array(1, 'Test', 'test@domain.tld'), - 11 => array(1, 'Test', 'test@domain.tld'), - 12 => array(1, 'Test', 'test@domain.tld'), - 13 => array(1, 'Test (comment)', 'test@domain.tld'), - 14 => array(1, '', 'test@domain.tld'), - 15 => array(1, 'Test', 'test@domain.tld'), - 16 => array(1, 'Test Test', 'test@domain.tld'), - 17 => array(1, '', 'test@domain.tld'), - 18 => array(1, 'Test,Test', 'test@domain.tld'), - 19 => array(1, 'Test', '"test test"@domain.tld'), - 20 => array(1, '', '"test test"@domain.tld'), - 21 => array(1, '', '"test test"@domain.tld'), - ); - - foreach ($headers as $idx => $header) { - $res = rcube_mime::decode_address_list($header); - - $this->assertEquals($results[$idx][0], count($res), "Rows number in result for header: " . $header); - $this->assertEquals($results[$idx][1], $res[1]['name'], "Name part decoding for header: " . $header); - $this->assertEquals($results[$idx][2], $res[1]['mailto'], "Email part decoding for header: " . $header); - } - } - - /** - * Test decoding of header values - * Uses rcube_mime::decode_mime_string() - */ - function test_header_decode_qp() - { - $test = array( - // #1488232: invalid character "?" - 'quoted-printable (1)' => array( - 'in' => '=?utf-8?Q?Certifica=C3=A7=C3=A3??=', - 'out' => 'Certifica=C3=A7=C3=A3?', - ), - 'quoted-printable (2)' => array( - 'in' => '=?utf-8?Q?Certifica=?= =?utf-8?Q?C3=A7=C3=A3?=', - 'out' => 'Certifica=C3=A7=C3=A3', - ), - 'quoted-printable (3)' => array( - 'in' => '=?utf-8?Q??= =?utf-8?Q??=', - 'out' => '', - ), - 'quoted-printable (4)' => array( - 'in' => '=?utf-8?Q??= a =?utf-8?Q??=', - 'out' => ' a ', - ), - 'quoted-printable (5)' => array( - 'in' => '=?utf-8?Q?a?= =?utf-8?Q?b?=', - 'out' => 'ab', - ), - 'quoted-printable (6)' => array( - 'in' => '=?utf-8?Q? ?= =?utf-8?Q?a?=', - 'out' => ' a', - ), - 'quoted-printable (7)' => array( - 'in' => '=?utf-8?Q?___?= =?utf-8?Q?a?=', - 'out' => ' a', - ), - ); - - foreach ($test as $idx => $item) { - $res = rcube_mime::decode_mime_string($item['in'], 'UTF-8'); - $res = quoted_printable_encode($res); - - $this->assertEquals($item['out'], $res, "Header decoding for: " . $idx); - } - } -} diff --git a/tests/ModCss.php b/tests/ModCss.php deleted file mode 100644 index 38cf84c9d..000000000 --- a/tests/ModCss.php +++ /dev/null @@ -1,39 +0,0 @@ -assertRegExp('/#rcmbody\s+\{/', $mod, "Replace body style definition"); - $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"); - } - - function test_xss() - { - $mod = rcmail_mod_css_styles("body.main2cols { background-image: url('../images/leftcol.png'); }", 'rcmbody'); - $this->assertEquals("/* evil! */", $mod, "No url() values allowed"); - - $mod = rcmail_mod_css_styles("@import url('http://localhost/somestuff/css/master.css');", 'rcmbody'); - $this->assertEquals("/* evil! */", $mod, "No import statements"); - - $mod = rcmail_mod_css_styles("left:expression(document.body.offsetWidth-20)", 'rcmbody'); - $this->assertEquals("/* evil! */", $mod, "No expression properties"); - - $mod = rcmail_mod_css_styles("left:exp/* */ression( alert('xss3') )", 'rcmbody'); - $this->assertEquals("/* evil! */", $mod, "Don't allow encoding quirks"); - - $mod = rcmail_mod_css_styles("background:\\0075\\0072\\006c( javascript:alert('xss') )", 'rcmbody'); - $this->assertEquals("/* evil! */", $mod, "Don't allow encoding quirks (2)"); - } -} diff --git a/tests/Utils.php b/tests/Utils.php deleted file mode 100644 index ad0aa1dde..000000000 --- a/tests/Utils.php +++ /dev/null @@ -1,85 +0,0 @@ -', 'Encoded html within email is invalid'), - array('email.domain.com', 'Missing @'), - array('email@domain@domain.com', 'Two @ sign'), - array('.email@domain.com', 'Leading dot in address is not allowed'), - array('email.@domain.com', 'Trailing dot in address is not allowed'), - array('email..email@domain.com', 'Multiple dots'), - array('あいうえお@domain.com', 'Unicode char as address'), - array('email@domain.com (Joe Smith)', 'Text followed email is not allowed'), - array('email@domain', 'Missing top level domain (.com/.net/.org/etc)'), - array('email@-domain.com', 'Leading dash in front of domain is invalid'), -// array('email@domain.web', '.web is not a valid top level domain'), - array('email@123.123.123.123', 'IP address without brackets'), - array('email@2001:2d12:c4fe:5afe::1', 'IPv6 address without brackets'), - array('email@IPv6:2001:2d12:c4fe:5afe::1', 'IPv6 address without brackets (2)'), - array('email@[111.222.333.44444]', 'Invalid IP format'), - array('email@[111.222.255.257]', 'Invalid IP format (2)'), - array('email@[.222.255.257]', 'Invalid IP format (3)'), - array('email@[::1]', 'Invalid IPv6 format (1)'), - array('email@[IPv6:2001:23x2:1]', 'Invalid IPv6 format (2)'), - array('email@[IPv6:1111:2222:33333::4444:5555]', 'Invalid IPv6 format (3)'), - array('email@[IPv6:1111::3333::4444:5555]', 'Invalid IPv6 format (4)'), - array('email@domain..com', 'Multiple dot in the domain portion is invalid'), - ); - } - - /** - * @dataProvider data_valid_email - */ - function test_valid_email($email, $title) - { - $this->assertTrue(rcube_utils::check_email($email, false), $title); - } - - /** - * @dataProvider data_invalid_email - */ - function test_invalid_email($email, $title) - { - $this->assertFalse(rcube_utils::check_email($email, false), $title); - } - -} diff --git a/tests/VCards.php b/tests/VCards.php deleted file mode 100644 index e61dca934..000000000 --- a/tests/VCards.php +++ /dev/null @@ -1,59 +0,0 @@ -_srcpath('apple.vcf'))); - - $this->assertTrue($vcard->business, "Identify as business record"); - $this->assertEquals("Apple Computer AG", $vcard->displayname, "FN => displayname"); - $this->assertEquals("", $vcard->firstname, "No person name set"); - } - - function test_parse_two() - { - $vcard = new rcube_vcard(file_get_contents($this->_srcpath('johndoe.vcf')), null); - - $this->assertFalse($vcard->business, "Identify as private record"); - $this->assertEquals("John Doë", $vcard->displayname, "Decode according to charset attribute"); - $this->assertEquals("roundcube.net", $vcard->organization, "Test organization field"); - $this->assertCount(2, $vcard->email, "List two e-mail addresses"); - $this->assertEquals("roundcube@gmail.com", $vcard->email[0], "Use PREF e-mail as primary"); - } - - function test_import() - { - $input = file_get_contents($this->_srcpath('apple.vcf')); - $input .= file_get_contents($this->_srcpath('johndoe.vcf')); - - $vcards = rcube_vcard::import($input); - - $this->assertCount(2, $vcards, "Detected 2 vcards"); - $this->assertEquals("Apple Computer AG", $vcards[0]->displayname, "FN => displayname"); - $this->assertEquals("John Doë", $vcards[1]->displayname, "Displayname with correct charset"); - - // http://trac.roundcube.net/ticket/1485542 - $vcards2 = rcube_vcard::import(file_get_contents($this->_srcpath('thebat.vcf'))); - $this->assertEquals("Iksiñski", $vcards2[0]->surname, "Detect charset in encoded values"); - } - - function test_encodings() - { - $input = file_get_contents($this->_srcpath('utf-16_sample.vcf')); - - $vcards = rcube_vcard::import($input); - $this->assertEquals("Ǽgean ĽdaMonté", $vcards[0]->displayname, "Decoded from UTF-16"); - } -} diff --git a/tests/bootstrap.php b/tests/bootstrap.php index b32112592..a9e25610c 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -31,3 +31,5 @@ if (@is_dir(TESTS_DIR . 'config')) { } require_once(INSTALL_PATH . 'program/include/iniset.php'); + +rcmail::get_instance()->config->set('devel_mode', false); diff --git a/tests/phpunit.xml b/tests/phpunit.xml index d6212f458..1bde91be1 100644 --- a/tests/phpunit.xml +++ b/tests/phpunit.xml @@ -3,13 +3,12 @@ colors="true"> + Framework/Mime.php + Framework/Shared.php + Framework/Utils.php + Framework/VCard.php HtmlToText.php - MailDecode.php MailFunc.php - ModCss.php - Shared.php - Utils.php - VCards.php -- cgit v1.2.3