mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Refactor email validation into provider based test
This commit is contained in:
parent
dcebf56056
commit
7d15d0af70
@ -58,18 +58,34 @@ class EmailTest extends SapphireTest
|
||||
$this->assertEquals('foo.txt', $child->getFilename());
|
||||
}
|
||||
|
||||
public function testValidEmailAddress()
|
||||
/**
|
||||
* @dataProvider provideValidEmailAddresses
|
||||
*/
|
||||
public function testValidEmailAddress($email)
|
||||
{
|
||||
$validEmails = array('test@example.com', 'test-123@example.sub.com');
|
||||
$invalidEmails = array('foo.bar@', '@example.com', 'foo@');
|
||||
$this->assertTrue(Email::is_valid_address($email));
|
||||
}
|
||||
|
||||
foreach ($validEmails as $email) {
|
||||
$this->assertTrue(Email::is_valid_address($email));
|
||||
}
|
||||
/**
|
||||
* @dataProvider provideInvalidEmailAddresses
|
||||
*/
|
||||
public function testInvalidEmailAddress($email)
|
||||
{
|
||||
$this->assertFalse(Email::is_valid_address($email));
|
||||
}
|
||||
|
||||
foreach ($invalidEmails as $email) {
|
||||
$this->assertFalse(Email::is_valid_address($email));
|
||||
}
|
||||
public function provideValidEmailAddresses()
|
||||
{
|
||||
return [
|
||||
['test@example.com', 'test-123@sub.example.com'],
|
||||
];
|
||||
}
|
||||
|
||||
public function provideInvalidEmailAddresses()
|
||||
{
|
||||
return [
|
||||
['foo.bar@', '@example.com', 'foo@'],
|
||||
];
|
||||
}
|
||||
|
||||
public function testObfuscate()
|
||||
|
Loading…
Reference in New Issue
Block a user