', true, null], ['much."more\ unusual"@example.com', true, null], ['very."(),:;<>[]".VERY."very@\\very".unusual@strange.example.com', true, null], // Invalid e-mails. ['plainaddress', false, 'Invalid email address "plainaddress".'], ['email@example', false, 'Invalid email address "email@example".'], ['example.com', false, 'Invalid email address "example.com".'], ['.email@example.com', false, 'Invalid email address ".email@example.com".'], ['email.@example.com', false, 'Invalid email address "email.@example.com".'], ['email..email@example.com', false, 'Invalid email address "email..email@example.com".'], ['email@example..com', false, 'Invalid email address "email@example..com".'], ['email@example@example.com', false, 'Invalid email address "email@example@example.com".'], ['email@example.com (John Doe)', false, 'Invalid email address "email@example.com (John Doe)".'], ['Administrator (email@example.com)', false, 'Invalid email address "Administrator (email@example.com)".'], ['@example.com', false, 'Invalid email address "@example.com".'], ['email@-example.com', false, 'Invalid email address "email@-example.com".'], ['Abc..123@example.com', false, 'Invalid email address "Abc..123@example.com".'], ['#@%^%#$@#$@#.com', false, 'Invalid email address "#@%^%#$@#$@#.com".'], ['あいうえお@example.com', false, 'Invalid email address "あいうえお@example.com".'], ['admin@localhost', false, 'Invalid email address "admin@localhost".'], ['admin@127.0.0.1', false, 'Invalid email address "admin@127.0.0.1".'], ['"(),:;<>[\]@example.com', false, 'Invalid email address ""(),:;<>[\]@example.com".'], ['just"not"right@example.com', false, 'Invalid email address "just"not"right@example.com".'], ['this\ is"really"not\allowed@example.com', false, 'Invalid email address "this\ is"really"not\allowed@example.com".'], ['Administrator , a, b, c', false, 'Invalid email address "Administrator , a, b, c".'] ]; } /** * @dataProvider dataProvider */ public function testValidateEmail($email, $expected, $error) { $email_validator = new CEmailValidator(); $result = $email_validator->validate($email); $this->assertSame($result, $expected); $this->assertSame($email_validator->getError(), $error); } }