Skip to content

[VarDumper] Test intl formatter broken since dumper does not replace the nnbsp character by standard space #52968

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

Conversation

celinederoland
Copy link

@celinederoland celinederoland commented Dec 9, 2023

Q A
Branch? 6.3
Bug fix? no
New feature? no
Deprecations? no
Issues I don't know, saw the problem on my machine
License MIT

Fix the \Symfony\Component\VarDumper\Tests\Caster\IntlCasterTest::testCastDateFormatter failure on machines that have Intl >= 72.1 :

Failed asserting that two strings are identical.
--- Expected
+++ Actual
@@ @@
'IntlDateFormatter {
locale: "en"

  • pattern: "EEEE, MMMM d, y 'at' h:mm:ss a zzzz" <--- Notice that between 'ss' and 'a', it look's like a space, but it is an invisible \u{202F} character
  • pattern: "EEEE, MMMM d, y 'at' h:mm:ss\u{202F}a zzzz"

Commit 6936845 says 'display invisible characters'. Since Intl 72.1 version, the getPattern method of IntlDateFormatter returns a string containing an invisible character \u{202F} (alia NNBSP).
I replaced it by \u{202F} in the expected output, but I guess maybe we could go further and do this replacement in the assertDumpEquals method

For example, here is a piece of code I wrote when debugging the problem :

        // Check what happens with Unicode caracters
        $u202F = "\u{202F}";
        $escapedU202F = "\\u{202F}";
        // Obviously those two strings are not equals
        $this->assertNotEquals($u202F, $escapedU202F);

        // this test fails :
        // $this->assertDumpEquals('"' . $u202F . '"', $u202F);
        // Output :
        /// Failed asserting that two strings are identical.
        // -'" "'
        // +'"\u{202F}"'

        // the dump of the first one \u{202F} is equal to the second one \\u{202F}
        // this test passes :
        $this->assertDumpEquals('"' . $escapedU202F . '"', $u202F);

        // since Intl 72, $var->getPatterns returns EEEE, MMMM d, y 'at' h:mm:ss\u{202F}a zzzz
        // The test fails as :
        // - it expects "EEEE, MMMM d, y 'at' h:mm:ss\u{202F}a zzzz" (\u{202F} is invisible, so in the console output it look's like "EEEE, MMMM d, y 'at' h:mm:ss a zzzz"
        // - but gets "EEEE, MMMM d, y 'at' h:mm:ss\\u{202F}a zzzz" (escaped version produced by dump since commit 69368454)
        // $expectedPattern = str_replace("\u{202F}", "\\u{202F}", $var->getPattern());
        $expectedPattern = $this->normalizeU202F($var->getPattern());

@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has a contribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (see https://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (see https://symfony.com/releases)
  • Features and deprecations must be submitted against the 7.1 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

@carsonbot
Copy link

Hey!

Thanks for your PR. You are targeting branch "6.3" but it seems your PR description refers to branch "6.3,".
Could you update the PR description or change target branch? This helps core maintainers a lot.

Cheers!

Carsonbot

@carsonbot carsonbot changed the title Test intl formatter broken since dumper does not replace the nnbsp character by standard space [VarDumper] Test intl formatter broken since dumper does not replace the nnbsp character by standard space Dec 9, 2023
@fabpot fabpot force-pushed the hotfix/test-intl-formatter-broken-since-dumper-does-not-replace-the-nnbsp-character-by-standard-space branch from 7756390 to 46b1edb Compare December 9, 2023 17:18
@fabpot
Copy link
Member

fabpot commented Dec 9, 2023

Thank you @celinederoland.

@fabpot fabpot merged commit 83b5c67 into symfony:6.3 Dec 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants