Skip to content

Commit

Permalink
Merge pull request #1336 from creative-commoners/pulls/7/field-valida…
Browse files Browse the repository at this point in the history
…tors

MNT Fix unit test
  • Loading branch information
GuySartorelli authored Oct 15, 2024
2 parents 81cba4e + 6f0b4f0 commit 4f821d1
Showing 1 changed file with 34 additions and 9 deletions.
43 changes: 34 additions & 9 deletions tests/php/Control/UserDefinedFormControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -584,16 +584,41 @@ public function testParseByteSizeStringBadValuesThrowException($input)
public static function provideValidEmailsToArray()
{
return [
[[], [null]],
[[], [' , , ']],
[[], ['broken.email, [email protected], broken2.@email']],
[
['broken@email', '[email protected]'],
[', broken@email, [email protected],[email protected],']
'input' => [
null
],
'expected' => [],
],
[
['[email protected]', '[email protected]', '[email protected]'],
['[email protected], [email protected], [email protected]']
'input' => [
' , , '
],
'expected' => [],
],
[
'input' => [
'broken.email, [email protected], broken2.@email'
],
'expected' => [],
],
[
'input' => [
', broken@email, [email protected],[email protected],'
],
'expected' => [
'[email protected]'
],
],
[
'input' => [
'[email protected], [email protected], [email protected]'
],
'expected' => [
'[email protected]',
'[email protected]',
'[email protected]'
],
]
];
}
Expand All @@ -602,14 +627,14 @@ public static function provideValidEmailsToArray()
* Test that provided email is valid
*/
#[DataProvider('provideValidEmailsToArray')]
public function testValidEmailsToArray(array $expectedOutput, array $input)
public function testValidEmailsToArray(array $input, array $expected)
{
$class = new ReflectionClass(UserDefinedFormController::class);
$method = $class->getMethod('validEmailsToArray');
$method->setAccessible(true);

$controller = new UserDefinedFormController();

$this->assertEquals($expectedOutput, $method->invokeArgs($controller, $input));
$this->assertEquals($expected, $method->invokeArgs($controller, $input));
}
}

0 comments on commit 4f821d1

Please sign in to comment.