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 test that didn't account for i18n spaces #611

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions tests/Schema/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1434,8 +1434,8 @@ public function testDBFieldArgs()
$node = $result['data']['readOneDataObjectFake'] ?? null;
$this->assertEquals('This is a varchar field', $node['myField']);
$this->assertEquals('Saturday', $node['date1']);
$this->assertEquals('2/29/20, 5:00 PM', $node['date2']);
$this->assertEquals('5:00:00 PM', $node['date3']);
$this->assertMatchesRegularExpression('#2/29/20,\h5:00\hPM#u', $node['date2']);
Copy link
Member

Choose a reason for hiding this comment

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

This seems wrong, SapphireTest should be setting the i18n default locale to en_US.

Copy link
Member

Choose a reason for hiding this comment

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

Actually it might be html5 overriding it - https://github.com/silverstripe/silverstripe-framework/blob/5/src/Forms/DateField.php#L450

However there's a comment that this should force a particular standard of date formats, so even then we still shouldn't get thin spaces?

Copy link
Member Author

Choose a reason for hiding this comment

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

This one is draft for a reason.

Copy link
Member Author

Choose a reason for hiding this comment

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

Based on php/php-src#11600 it seems that there was an intentional change in "ICU" which seems to be what's used under-the-hood for the i18n date formatting. This change includes the narrow non-breaking spaces which seem like they're here to stay.

We'll need to update a bunch of tests to account for it, including this one.

$this->assertMatchesRegularExpression('#5:00:00\hPM#u', $node['date3']);
$this->assertEquals('2020', $node['date4']);
$this->assertEquals('This is a really long text field. It has a few sentences.', $node['myText']);
}
Expand Down
Loading