Merge branch '3.x' into 4.x

* 3.x:
  Fix intl tests
  Improve error message
  Bump version
  Update CHANGELOG
This commit is contained in:
Fabien Potencier
2023-12-24 09:45:46 +01:00
5 changed files with 26 additions and 19 deletions
@@ -2,15 +2,15 @@
"language_names" function
--TEMPLATE--
{{ language_names('UNKNOWN')|length }}
{{ language_names()|length }}
{{ language_names('fr')|length }}
{{ language_names()|length > 600 ? 'ok' : 'ko' }}
{{ language_names('fr')|length > 600 ? 'ok' : 'ko' }}
{{ language_names()['fr'] }}
{{ language_names('fr')['fr'] }}
--DATA--
return [];
--EXPECT--
0
634
634
ok
ok
French
français
@@ -2,15 +2,15 @@
"locale_names" function
--TEMPLATE--
{{ locale_names('UNKNOWN')|length }}
{{ locale_names()|length }}
{{ locale_names('fr')|length }}
{{ locale_names()|length > 600 ? 'ok' : 'ko' }}
{{ locale_names('fr')|length > 600 ? 'ok' : 'ko' }}
{{ locale_names()['fr'] }}
{{ locale_names('fr')['fr'] }}
--DATA--
return [];
--EXPECT--
0
637
637
ok
ok
French
français
@@ -2,15 +2,15 @@
"timezone_names" function
--TEMPLATE--
{{ timezone_names('UNKNOWN')|length }}
{{ timezone_names()|length }}
{{ timezone_names('fr')|length }}
{{ timezone_names()|length > 400 ? 'ok' : 'ko' }}
{{ timezone_names('fr')|length > 400 ? 'ok' : 'ko' }}
{{ timezone_names()['Europe/Paris'] }}
{{ timezone_names('fr')['Europe/Paris'] }}
--DATA--
return [];
--EXPECT--
0
434
434
ok
ok
Central European Time (Paris)
heure dEurope centrale (Paris)
+10 -7
View File
@@ -25,8 +25,8 @@ class IntlExtensionTest extends TestCase
$env = new Environment(new ArrayLoader());
$this->assertSame('12.346', $ext->formatNumber('12.3456'));
$this->assertSame(
'Feb 20, 2020, 1:37:00 PM',
$this->assertStringStartsWith(
'Feb 20, 2020, 1:37:00',
$ext->formatDateTime($env, new \DateTime('2020-02-20T13:37:00+00:00'))
);
}
@@ -39,8 +39,8 @@ class IntlExtensionTest extends TestCase
// so it has a fixed difference to UTC
$env->getExtension(CoreExtension::class)->setTimezone('EET');
$this->assertSame(
'Feb 20, 2020, 3:37:00 PM',
$this->assertStringStartsWith(
'Feb 20, 2020, 3:37:00',
$ext->formatDateTime($env, new \DateTime('2020-02-20T13:37:00+00:00', new \DateTimeZone('UTC')))
);
}
@@ -55,9 +55,12 @@ class IntlExtensionTest extends TestCase
$env = new Environment(new ArrayLoader());
$this->assertSame('++12,3', $ext->formatNumber('12.3456'));
$this->assertSame(
'jeudi 20 février 2020 à 14:37:00 heure normale dEurope centrale',
$ext->formatDateTime($env, new \DateTime('2020-02-20T13:37:00+00:00'))
$this->assertContains(
$ext->formatDateTime($env, new \DateTime('2020-02-20T13:37:00+00:00', new \DateTimeZone('Europe/Paris'))),
[
'jeudi 20 février 2020 à 13:37:00 heure normale dEurope centrale',
'jeudi 20 février 2020 à 13:37:00 temps universel coordonné',
]
);
}
+4
View File
@@ -1425,6 +1425,10 @@ final class CoreExtension extends AbstractExtension
}
if (!\defined($constant)) {
if ('::class' === strtolower(substr($constant, -7))) {
throw new RuntimeError(sprintf('You cannot use the Twig function "constant()" to access "%s". You could provide an object and call constant("class", $object) or use the class name directly as a string.', $constant));
}
throw new RuntimeError(sprintf('Constant "%s" is undefined.', $constant));
}