silverstripe-framework/tests/php/Forms
Nick e456de11b0
Fix clobbering of the upload size validation (#10059)
* Fix clobbering of the upload size validation

When the validation is set here like this, it overrides validation which has already been setup with a simple '*' rule for the size based on PHP.

If you've defined in the sites yml config something like

    SilverStripe\Assets\Upload_Validator:
      default_max_file_size:
        '[image]': '2m'
        '*' : '1m'

then it will not be respected.

If you review SilverStripe\Assets\Upload_Validator and check the getAllowedMaxFileSize method, you'll see the sizing will be populated (if it hasn't been done before).

You can see it fail by;
- Setup a new SilverStripe site.
- Set your PHP to allow max post / max upload size of 10mb.
- Add the above config to your sites yml file and flush.
- In the CMS you'll be able to upload a 5MB file, when you shouldn't.

* Test that FileField will use size validation if defined

Couple of tests which prove a fix so the FileField and others will use the default_max_file_size setting

* Fix variable name in last commit

This is what happens when you refactor in the github window.
Fix the variable names. This will get squashed once merged.

* Updates the pr - white space and non deprecated method for byte conversion

Remove extra white space to appease the CS. Use the non deprecated method for memstring2bytes

* White space fixes for the phpcs

White space fixes for the phpcs

* Ensure that "memstring2bytes" can handle if an empty or value with no number is passed in

* DEP Bump assets constraint to ensure that change is also pulled in

---------

Co-authored-by: Guy Sartorelli <guy.sartorelli@silverstripe.com>
2024-01-08 15:49:41 +13:00
..
CheckboxFieldtest Convert array delcarations to short array syntax 2020-04-20 18:58:09 +01:00
CheckboxSetFieldTest Convert array delcarations to short array syntax 2020-04-20 18:58:09 +01:00
DatetimeFieldTest Convert array delcarations to short array syntax 2020-04-20 18:58:09 +01:00
EmailFieldTest MNT Remove legacy upgrader config 2023-01-20 17:05:41 +13:00
FormFactoryTest MNT Remove legacy upgrader config 2023-01-20 17:05:41 +13:00
FormFieldTest NEW: Add extension hook for field-specific validation 2023-02-20 10:24:41 +00:00
FormRequestHandlerTest Update file paths for autoloading compatibility 2020-04-25 10:28:28 +01:00
FormScaffolderTest Convert array delcarations to short array syntax 2020-04-20 18:58:09 +01:00
FormSchemaTest Fix tests 2017-12-08 09:58:52 +13:00
FormTest MNT Remove legacy upgrader config 2023-01-20 17:05:41 +13:00
GridField Merge pull request #11049 from creative-commoners/pulls/5/gridfield-with-viewabledata 2023-12-19 19:55:29 +13:00
HTMLEditor Merge branch '4' into 5.1 2023-11-02 20:08:54 +00:00
ListboxFieldTest Convert array delcarations to short array syntax 2020-04-20 18:58:09 +01:00
MoneyFieldTest Convert array delcarations to short array syntax 2020-04-20 18:58:09 +01:00
NumericFieldTest Convert array delcarations to short array syntax 2020-04-20 18:58:09 +01:00
ValidatorTest Use ReflectionClass for CompositeValidator tests 2020-05-28 11:18:46 +12:00
CheckboxFieldReadonlyTest.php Rename CheckboxFieldReadonlyTest for future PSR-2 compatibility 2018-11-10 10:04:17 +02:00
CheckboxFieldTest.php ENH PHP 8.1 compatibility 2022-04-14 13:12:59 +12:00
CheckboxSetFieldMultiEnumTest.php FIX: Typo in CheckboxSetFieldMultiEnumTest class name (closes #10689) 2023-08-21 15:49:09 +01:00
CheckboxSetFieldTest.php MNT Remove legacy upgrader config 2023-01-20 17:05:41 +13:00
CheckboxSetFieldTest.yml API Namespace framework tests 2016-11-23 19:25:12 +13:00
CompositeFieldTest.php ENH PHP 8.1 compatibility 2022-04-14 13:12:59 +12:00
CompositeValidatorTest.php ENH PHP 8.1 compatibility 2022-04-14 13:12:59 +12:00
ConfirmedPasswordFieldTest.php NEW Generate a random password if a blank password is entered 2023-10-20 11:37:25 +13:00
CurrencyFieldDisabledTest.php MNT Remove TODO comments 2023-10-30 13:21:09 +13:00
CurrencyFieldReadonlyTest.php MNT Remove TODO comments 2023-10-30 13:21:09 +13:00
CurrencyFieldTest.php API Stop using deprecated API 2022-11-15 18:20:54 +13:00
DatalessFieldTest.php API Upgrade SapphireTest to work with phpunit 9 (#10028) 2021-10-27 15:39:47 +13:00
DateFieldDisabledTest.php MNT Remove legacy upgrader config 2023-01-20 17:05:41 +13:00
DateFieldTest.php MNT Remove legacy upgrader config 2023-01-20 17:05:41 +13:00
DatetimeFieldTest.php MNT Remove legacy upgrader config 2023-01-20 17:05:41 +13:00
DefaultFormFactoryTest.php API Upgrade SapphireTest to work with phpunit 9 (#10028) 2021-10-27 15:39:47 +13:00
DisabledTransformationTest.php Add tests for DisabledTransformation, PrintableTransformation and PrintableTransformation_TabSet 2018-10-20 20:06:02 +02:00
DropdownFieldTest.php MNT Remove legacy upgrader config 2023-01-20 17:05:41 +13:00
EmailFieldTest.php MNT Remove TODO comments 2023-10-30 13:21:09 +13:00
EnumFieldTest.php Convert array delcarations to short array syntax 2020-04-20 18:58:09 +01:00
FieldGroupTest.php Apply PSR2 / Namespace to remaining admin / tests 2016-12-19 16:08:19 +13:00
FieldListTest.php MNT Remove TODO comments 2023-10-30 13:21:09 +13:00
FieldsValidatorTest.php NEW Add FieldsValidator to ensure fields get validated 2023-08-08 13:02:27 +12:00
FileFieldTest.php Fix clobbering of the upload size validation (#10059) 2024-01-08 15:49:41 +13:00
FormActionTest.php API Upgrade SapphireTest to work with phpunit 9 (#10028) 2021-10-27 15:39:47 +13:00
FormFactoryTest.php API Normalise trailing slashes for all paths 2023-01-20 10:31:14 +13:00
FormFactoryTest.yml Apply PSR2 / Namespace to remaining admin / tests 2016-12-19 16:08:19 +13:00
FormFieldTest.php NEW SearchableDropdownField 2023-12-14 15:28:19 +13:00
FormRequestHandlerTest.php MNT Remove legacy upgrader config 2023-01-20 17:05:41 +13:00
FormScaffolderTest.php MNT Fix various typos with codespell (#10177) 2021-12-13 21:05:33 +13:00
FormScaffolderTest.yml API Namespace framework tests 2016-11-23 19:25:12 +13:00
FormSchemaTest.php ENH Throw exception when no react component 2023-11-22 14:17:47 +13:00
FormTest.php ENH allow stacked messages on FormMessage 2023-10-09 11:12:03 +13:00
FormTest.yml API Namespace framework tests 2016-11-23 19:25:12 +13:00
GroupedDropdownFieldTest.php API Upgrade SapphireTest to work with phpunit 9 (#10028) 2021-10-27 15:39:47 +13:00
ListboxFieldTest.php MNT Remove TODO comments 2023-10-30 13:21:09 +13:00
ListboxFieldTest.yml API Namespace framework tests 2016-11-23 19:25:12 +13:00
LookupFieldTest.php ENH PHP 8.1 compatibility 2022-04-14 13:12:59 +12:00
LookupFieldTest.yml Move files to psr-2 standard locations 2016-11-23 19:25:12 +13:00
MoneyFieldTest.php Convert array delcarations to short array syntax 2020-04-20 18:58:09 +01:00
NullableFieldTests.php Convert array delcarations to short array syntax 2020-04-20 18:58:09 +01:00
NumericFieldTest.php MNT Remove TODO comments 2023-10-30 13:21:09 +13:00
OptionsetFieldTest.php MNT Remove legacy upgrader config 2023-01-20 17:05:41 +13:00
PasswordFieldTest.php [ss-2018-013] Remove password text from session data on failed submission 2018-05-14 17:14:38 +12:00
PopoverFieldTest.php Apply PSR2 / Namespace to remaining admin / tests 2016-12-19 16:08:19 +13:00
PrintableTransformationTabSetTest.php API Upgrade SapphireTest to work with phpunit 9 (#10028) 2021-10-27 15:39:47 +13:00
PrintableTransformationTest.php Add tests for DisabledTransformation, PrintableTransformation and PrintableTransformation_TabSet 2018-10-20 20:06:02 +02:00
RequiredFieldsTest.php Merge branch '4' into 5.1 2023-11-28 02:04:52 +00:00
SearchableDropdownTraitTest.php NEW SearchableDropdownField 2023-12-14 15:28:19 +13:00
SearchableDropdownTraitTest.yml NEW SearchableDropdownField 2023-12-14 15:28:19 +13:00
SelectionGroupTest.php API Upgrade SapphireTest to work with phpunit 9 (#10028) 2021-10-27 15:39:47 +13:00
SingleLookupFieldTest.php ENH PHP 8.1 compatibility 2022-04-14 13:12:59 +12:00
TextareaFieldTest.php added maxLength validation tests 2023-08-30 10:56:21 +02:00
TextFieldTest.php NEW Extract Tip from TextField, add test coverage 2019-10-22 17:04:58 +13:00
TimeFieldReadonlyTest.php API Upgrade SapphireTest to work with phpunit 9 (#10028) 2021-10-27 15:39:47 +13:00
TimeFieldTest.php MNT Remove TODO comments 2023-10-30 13:21:09 +13:00
TipTest.php API Upgrade SapphireTest to work with phpunit 9 (#10028) 2021-10-27 15:39:47 +13:00
TreeDropdownFieldTest.php Merge branch '4' into 5.1 2023-11-28 02:04:52 +00:00
TreeDropdownFieldTest.yml ENH Add tests for Hierarchy extension when applied to a subclass 2021-09-25 00:23:43 +12:00
TreeMultiselectFieldTest.php ENH PHP 8.1 compatibility 2022-04-14 13:12:59 +12:00
ValidatorTest.php ENH PHP 8.1 compatibility 2022-04-14 13:12:59 +12:00