Compare commits

..

4 Commits

Author SHA1 Message Date
Guy Sartorelli
06cd3eecd9
ENH Update code to reflect changes in template layer 2024-10-22 13:12:00 +13:00
Guy Sartorelli
574ca14ee7
ENH Use config instead of runtime code to remove menu item (#1337) 2024-10-21 11:56:02 +13:00
Guy Sartorelli
4f821d1188
Merge pull request #1336 from creative-commoners/pulls/7/field-validators
MNT Fix unit test
2024-10-15 15:10:40 +13:00
Steve Boyd
6f0b4f0b99 MNT Fix unit test 2024-10-15 11:03:34 +13:00
3 changed files with 36 additions and 15 deletions

View File

@ -1,6 +0,0 @@
<?php
use SilverStripe\Admin\CMSMenu;
use SilverStripe\UserForms\Control\UserDefinedFormAdmin;
CMSMenu::remove_menu_class(UserDefinedFormAdmin::class);

View File

@ -47,6 +47,8 @@ class UserDefinedFormAdmin extends LeftAndMain
private static $url_segment = 'user-forms';
private static $ignore_menuitem = true;
/**
* @var string The name of the folder where form submissions will be placed by default
*/

View File

@ -584,16 +584,41 @@ class UserDefinedFormControllerTest extends FunctionalTest
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 @@ class UserDefinedFormControllerTest extends FunctionalTest
* 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 @@ class UserDefinedFormControllerTest extends FunctionalTest
$controller = new UserDefinedFormController();
$this->assertEquals($expectedOutput, $method->invokeArgs($controller, $input));
$this->assertEquals($expected, $method->invokeArgs($controller, $input));
}
}