mirror of
https://github.com/silverstripe/silverstripe-userforms.git
synced 2024-10-22 17:05:42 +02:00
Merge pull request #1336 from creative-commoners/pulls/7/field-validators
MNT Fix unit test
This commit is contained in:
commit
4f821d1188
@ -584,16 +584,41 @@ class UserDefinedFormControllerTest extends FunctionalTest
|
|||||||
public static function provideValidEmailsToArray()
|
public static function provideValidEmailsToArray()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[[], [null]],
|
|
||||||
[[], [' , , ']],
|
|
||||||
[[], ['broken.email, broken@.email, broken2.@email']],
|
|
||||||
[
|
[
|
||||||
['broken@email', 'correctemail@email.com'],
|
'input' => [
|
||||||
[', broken@email, email@-email.com,correctemail@email.com,']
|
null
|
||||||
|
],
|
||||||
|
'expected' => [],
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
['correctemail1@email.com', 'correctemail2@email.com', 'correctemail3@email.com'],
|
'input' => [
|
||||||
['correctemail1@email.com, correctemail2@email.com, correctemail3@email.com']
|
' , , '
|
||||||
|
],
|
||||||
|
'expected' => [],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'input' => [
|
||||||
|
'broken.email, broken@.email, broken2.@email'
|
||||||
|
],
|
||||||
|
'expected' => [],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'input' => [
|
||||||
|
', broken@email, email@-email.com,correctemail@email.com,'
|
||||||
|
],
|
||||||
|
'expected' => [
|
||||||
|
'correctemail@email.com'
|
||||||
|
],
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'input' => [
|
||||||
|
'correctemail1@email.com, correctemail2@email.com, correctemail3@email.com'
|
||||||
|
],
|
||||||
|
'expected' => [
|
||||||
|
'correctemail1@email.com',
|
||||||
|
'correctemail2@email.com',
|
||||||
|
'correctemail3@email.com'
|
||||||
|
],
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -602,7 +627,7 @@ class UserDefinedFormControllerTest extends FunctionalTest
|
|||||||
* Test that provided email is valid
|
* Test that provided email is valid
|
||||||
*/
|
*/
|
||||||
#[DataProvider('provideValidEmailsToArray')]
|
#[DataProvider('provideValidEmailsToArray')]
|
||||||
public function testValidEmailsToArray(array $expectedOutput, array $input)
|
public function testValidEmailsToArray(array $input, array $expected)
|
||||||
{
|
{
|
||||||
$class = new ReflectionClass(UserDefinedFormController::class);
|
$class = new ReflectionClass(UserDefinedFormController::class);
|
||||||
$method = $class->getMethod('validEmailsToArray');
|
$method = $class->getMethod('validEmailsToArray');
|
||||||
@ -610,6 +635,6 @@ class UserDefinedFormControllerTest extends FunctionalTest
|
|||||||
|
|
||||||
$controller = new UserDefinedFormController();
|
$controller = new UserDefinedFormController();
|
||||||
|
|
||||||
$this->assertEquals($expectedOutput, $method->invokeArgs($controller, $input));
|
$this->assertEquals($expected, $method->invokeArgs($controller, $input));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user