From 6f0b4f0b99fce7a9933ec39d9027053e80059aba Mon Sep 17 00:00:00 2001 From: Steve Boyd Date: Tue, 15 Oct 2024 11:03:34 +1300 Subject: [PATCH] MNT Fix unit test --- .../Control/UserDefinedFormControllerTest.php | 43 +++++++++++++++---- 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/tests/php/Control/UserDefinedFormControllerTest.php b/tests/php/Control/UserDefinedFormControllerTest.php index 49600acb..36dccbf9 100644 --- a/tests/php/Control/UserDefinedFormControllerTest.php +++ b/tests/php/Control/UserDefinedFormControllerTest.php @@ -584,16 +584,41 @@ public function testParseByteSizeStringBadValuesThrowException($input) public static function provideValidEmailsToArray() { return [ - [[], [null]], - [[], [' , , ']], - [[], ['broken.email, broken@.email, broken2.@email']], [ - ['broken@email', 'correctemail@email.com'], - [', broken@email, email@-email.com,correctemail@email.com,'] + 'input' => [ + null + ], + 'expected' => [], ], [ - ['correctemail1@email.com', 'correctemail2@email.com', 'correctemail3@email.com'], - ['correctemail1@email.com, correctemail2@email.com, correctemail3@email.com'] + 'input' => [ + ' , , ' + ], + '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 @@ 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'); @@ -610,6 +635,6 @@ public function testValidEmailsToArray(array $expectedOutput, array $input) $controller = new UserDefinedFormController(); - $this->assertEquals($expectedOutput, $method->invokeArgs($controller, $input)); + $this->assertEquals($expected, $method->invokeArgs($controller, $input)); } }