Commit 83b5c67
committed
minor symfony#52968 [VarDumper] Test intl formatter broken since dumper does not replace the nnbsp character by standard space (CDR)
This PR was squashed before being merged into the 6.3 branch.
Discussion
----------
[VarDumper] Test intl formatter broken since dumper does not replace the nnbsp character by standard space
| 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 6936845)
// $expectedPattern = str_replace("\u{202F}", "\\u{202F}", $var->getPattern());
$expectedPattern = $this->normalizeU202F($var->getPattern());
```
Commits
-------
46b1edb [VarDumper] Test intl formatter broken since dumper does not replace the nnbsp character by standard spaceFile tree
1 file changed
+6
-1
lines changed- src/Symfony/Component/VarDumper/Tests/Caster
1 file changed
+6
-1
lines changedLines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
234 | 234 | | |
235 | 235 | | |
236 | 236 | | |
237 | | - | |
| 237 | + | |
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
| |||
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
297 | 302 | | |
0 commit comments