mirror of
https://github.com/phpbb/phpbb.git
synced 2025-07-30 21:40:43 +02:00
[ticket/10073] Split email validation from email ban and taken checks
PHPBB3-10073
This commit is contained in:
@@ -16,7 +16,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_user.php';
|
||||
require_once dirname(__FILE__) . '/../mock/user.php';
|
||||
require_once dirname(__FILE__) . '/validate_data_helper.php';
|
||||
|
||||
class phpbb_functions_validate_email_test extends phpbb_database_test_case
|
||||
class phpbb_functions_validate_user_email_test extends phpbb_database_test_case
|
||||
{
|
||||
protected $db;
|
||||
protected $user;
|
||||
@@ -51,61 +51,55 @@ class phpbb_functions_validate_email_test extends phpbb_database_test_case
|
||||
$user->optionset('banned_users', array('banned@example.com'));
|
||||
}
|
||||
|
||||
public function test_validate_email()
|
||||
public static function validate_user_email_data()
|
||||
{
|
||||
return array(
|
||||
array('empty', array(), ''),
|
||||
array('allowed', array(), 'foobar@example.com'),
|
||||
array('valid_complex', array(), "'%$~test@example.com"),
|
||||
array('invalid', array('EMAIL_INVALID'), 'fööbar@example.com'),
|
||||
array('taken', array('EMAIL_TAKEN'), 'admin@example.com'),
|
||||
array('banned', array('EMAIL_BANNED'), 'banned@example.com'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider validate_user_email_data
|
||||
*/
|
||||
public function test_validate_user_email($case, $errors, $email)
|
||||
{
|
||||
$this->set_validation_prerequisites(false);
|
||||
|
||||
$this->helper->assert_valid_data(array(
|
||||
'empty' => array(
|
||||
array(),
|
||||
'',
|
||||
array('email'),
|
||||
),
|
||||
'allowed' => array(
|
||||
array(),
|
||||
'foobar@example.com',
|
||||
array('email', 'foobar@example.com'),
|
||||
),
|
||||
'invalid' => array(
|
||||
array('EMAIL_INVALID'),
|
||||
'fööbar@example.com',
|
||||
array('email'),
|
||||
),
|
||||
'valid_complex' => array(
|
||||
array(),
|
||||
"'%$~test@example.com",
|
||||
array('email'),
|
||||
),
|
||||
'taken' => array(
|
||||
array('EMAIL_TAKEN'),
|
||||
'admin@example.com',
|
||||
array('email'),
|
||||
),
|
||||
'banned' => array(
|
||||
array('EMAIL_BANNED'),
|
||||
'banned@example.com',
|
||||
array('email'),
|
||||
$case => array(
|
||||
$errors,
|
||||
$email,
|
||||
array('user_email'),
|
||||
),
|
||||
));
|
||||
}
|
||||
|
||||
public static function validate_user_email_mx_data()
|
||||
{
|
||||
return array(
|
||||
array('valid', array(), 'foobar@phpbb.com'),
|
||||
array('no_mx', array('DOMAIN_NO_MX_RECORD'), 'test@does-not-exist.phpbb.com'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider validate_user_email_mx_data
|
||||
* @group slow
|
||||
*/
|
||||
public function test_validate_email_mx()
|
||||
public function test_validate_user_email_mx($case, $errors, $email)
|
||||
{
|
||||
$this->set_validation_prerequisites(true);
|
||||
|
||||
$this->helper->assert_valid_data(array(
|
||||
'valid' => array(
|
||||
array(),
|
||||
'foobar@phpbb.com',
|
||||
array('email'),
|
||||
),
|
||||
'no_mx' => array(
|
||||
array('DOMAIN_NO_MX_RECORD'),
|
||||
'test@does-not-exist.phpbb.com',
|
||||
array('email'),
|
||||
$case => array(
|
||||
$errors,
|
||||
$email,
|
||||
array('user_email'),
|
||||
),
|
||||
));
|
||||
}
|
Reference in New Issue
Block a user