Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

86 lines (79 sloc) 3.967 kb
* Test class to test rcube_utils class
* @package Tests
class Utils extends PHPUnit_Framework_TestCase
* Valid email addresses for test_valid_email()
function data_valid_email()
return array(
array('', 'Valid email'),
array('', 'Email contains dot in the address field'),
array('', 'Email contains dot with subdomain'),
array('', 'Plus sign is considered valid character'),
array('email@[]', 'Square bracket around IP address'),
array('email@[IPv6:::1]', 'Square bracket around IPv6 address (1)'),
array('email@[IPv6:::]', 'Square bracket around IPv6 address (2)'),
array('email@[IPv6:2001:2d12:c4fe:5afe::1]', 'Square bracket around IPv6 address (3)'),
array('"email"', 'Quotes around email is considered valid'),
array('', 'Digits in address are valid'),
array('', 'Dash in domain name is valid'),
array('', 'Underscore in the address field is valid'),
array('', '.name is valid Top Level Domain name'),
array('', 'Dot in Top Level Domain name also considered valid (use as example here)'),
array('', 'Dash in address field is valid'),
* Invalid email addresses for test_invalid_email()
function data_invalid_email()
return array(
array('plainaddress', 'Missing @ sign and domain'),
array('#@%^%#$@#$', 'Garbage'),
array('', 'Missing username'),
array('Joe Smith <>', 'Encoded html within email is invalid'),
array('', 'Missing @'),
array('', 'Two @ sign'),
array('', 'Leading dot in address is not allowed'),
array('', 'Trailing dot in address is not allowed'),
array('', 'Multiple dots'),
array('あいうえお', 'Unicode char as address'),
array(' (Joe Smith)', 'Text followed email is not allowed'),
array('email@domain', 'Missing top level domain (.com/.net/.org/etc)'),
array('', 'Leading dash in front of domain is invalid'),
// array('email@domain.web', '.web is not a valid top level domain'),
array('email@', '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@[]', '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('', '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);
Jump to Line
Something went wrong with that request. Please try again.