Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MNT Fix unit tests #11409

Merged
merged 1 commit into from
Sep 30, 2024
Merged

Conversation

GuySartorelli
Copy link
Member

@GuySartorelli GuySartorelli commented Sep 30, 2024

Fixes various date formatting failures in https://github.com/silverstripe/silverstripe-framework/actions/runs/11091228469/job/30830628977

Two main causes:

  1. IntlDateFormatter output changes based on operating system used php/php-src#16127
    • Bug in upstream dependency results in some "medium" dates being returned as "short" dates for en_NZ locale. We shouldn't try to pre-fix the bug, nor should we attempt to revert to the buggy behaviour. Solution is to test against a locale that didn't exhibit the bug.
  2. strtotime returns false when string includes narrow non breaking space character php/php-src#11600
    • Intentional change in upstream dependency results in "narrow non-breaking spaces" in some formatted dates where a regular space used to be. Solution is to update tests to not care what the space looks like so long as it's there.

Issue

@GuySartorelli GuySartorelli changed the base branch from 5 to 5.2 September 30, 2024 02:51
Comment on lines -51 to +52
'31/03/2008',
'Mar 31, 2008',
Copy link
Member Author

@GuySartorelli GuySartorelli Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old date is effective the same as you'd get when using IntlDateFormatter::SHORT, though we're using IntlDateFormatter::MEDIUM here.

Steve and I had talked in person about making the default configurable.
That would be doable for DateField_Disabled in the above test, because the default for that is returned from DateField::getDateLength() as a fallback value. Though its notable that none of the tests for DateField itself failed... so I'm not sure about the value of making that change but can do if the reviewer wants me to.

That's not possible for DBDate in this test though, because the default value is a default argument in the method signature of DBDate::getFormatter() and we can't change method signatures in patches or minors.

Copy link
Member

@emteknetnz emteknetnz Sep 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though its notable that none of the tests for DateField itself failed

Looks like that's because only the internal values were being validated in DateFieldTest, rather than the formatted values like Nice()

so I'm not sure about the value of making that change but can do if the reviewer wants me to.

Reading php/php-src#16127 (comment) particularly around the "no contract" bit, I guess it's correct to not have config here and not attempt to retain backwards compatibility. Simply updating our unit tests is the correct to test the new format is the correct response I think.

@emteknetnz emteknetnz merged commit 862a65e into silverstripe:5.2 Sep 30, 2024
14 checks passed
@emteknetnz emteknetnz deleted the pulls/5.2/fix-tests branch September 30, 2024 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants