mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 20:38:52 +00:00
[ticket/11579] Add method for validating emails for valid MX and mark as slow
A method for setting up the prerequisities also has been added in order to reduce the amount of necessary code. PHPBB3-11579
This commit is contained in:
parent
6a77ee1f30
commit
c6ba894acd
1 changed files with 29 additions and 3 deletions
|
@ -32,14 +32,24 @@ class phpbb_functions_validate_email_test extends phpbb_database_test_case
|
||||||
$this->helper = new phpbb_functions_validate_data_helper($this);
|
$this->helper = new phpbb_functions_validate_data_helper($this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_validate_email()
|
/**
|
||||||
|
* Get validation prerequesites
|
||||||
|
*
|
||||||
|
* @param bool $check_mx Whether mx records should be checked
|
||||||
|
*/
|
||||||
|
protected function set_validation_prerequisites($check_mx)
|
||||||
{
|
{
|
||||||
global $config, $db, $user;
|
global $config, $db, $user;
|
||||||
|
|
||||||
$config['email_check_mx'] = true;
|
$config['email_check_mx'] = $check_mx;
|
||||||
$db = $this->db;
|
$db = $this->db;
|
||||||
$user = $this->user;
|
$user = $this->user;
|
||||||
$user->optionset('banned_users', array('banned@example.com'));
|
$user->optionset('banned_users', array('banned@example.com'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function test_validate_email()
|
||||||
|
{
|
||||||
|
$this->set_validation_prerequisites(false);
|
||||||
|
|
||||||
$this->helper->assert_valid_data(array(
|
$this->helper->assert_valid_data(array(
|
||||||
'empty' => array(
|
'empty' => array(
|
||||||
|
@ -72,9 +82,25 @@ class phpbb_functions_validate_email_test extends phpbb_database_test_case
|
||||||
'banned@example.com',
|
'banned@example.com',
|
||||||
array('email'),
|
array('email'),
|
||||||
),
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group slow
|
||||||
|
*/
|
||||||
|
public function test_validate_email_mx()
|
||||||
|
{
|
||||||
|
$this->set_validation_prerequisites(true);
|
||||||
|
|
||||||
|
$this->helper->assert_valid_data(array(
|
||||||
|
'valid' => array(
|
||||||
|
array(),
|
||||||
|
'foobar@phpbb.com',
|
||||||
|
array('email'),
|
||||||
|
),
|
||||||
'no_mx' => array(
|
'no_mx' => array(
|
||||||
array('DOMAIN_NO_MX_RECORD'),
|
array('DOMAIN_NO_MX_RECORD'),
|
||||||
'test@wwrrrhhghgghgh.ttv',
|
'test@does-not-exist.phpbb.com',
|
||||||
array('email'),
|
array('email'),
|
||||||
),
|
),
|
||||||
));
|
));
|
||||||
|
|
Loading…
Add table
Reference in a new issue