Skip to content

Commit d77279d

Browse files
Nyholmderrabus
authored andcommitted
[CI] Make sure to restore default locale
1 parent e69d02b commit d77279d

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

Tests/AbstractLayoutTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,15 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase
2626

2727
protected $csrfTokenManager;
2828
protected $testableFeatures = [];
29+
private $defaultLocale;
2930

3031
protected function setUp(): void
3132
{
3233
if (!\extension_loaded('intl')) {
3334
$this->markTestSkipped('Extension intl is required.');
3435
}
3536

37+
$this->defaultLocale = \Locale::getDefault();
3638
\Locale::setDefault('en');
3739

3840
$this->csrfTokenManager = $this->createMock(CsrfTokenManagerInterface::class);
@@ -50,6 +52,7 @@ protected function getExtensions()
5052
protected function tearDown(): void
5153
{
5254
$this->csrfTokenManager = null;
55+
\Locale::setDefault($this->defaultLocale);
5356

5457
parent::tearDown();
5558
}

Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class DateTimeToLocalizedStringTransformerTest extends TestCase
2323

2424
protected $dateTime;
2525
protected $dateTimeWithoutSeconds;
26+
private $defaultLocale;
2627

2728
protected function setUp(): void
2829
{
@@ -37,6 +38,7 @@ protected function setUp(): void
3738
// Since we test against "de_AT", we need the full implementation
3839
IntlTestHelper::requireFullIntl($this, '57.1');
3940

41+
$this->defaultLocale = \Locale::getDefault();
4042
\Locale::setDefault('de_AT');
4143

4244
$this->dateTime = new \DateTime('2010-02-03 04:05:06 UTC');
@@ -47,6 +49,7 @@ protected function tearDown(): void
4749
{
4850
$this->dateTime = null;
4951
$this->dateTimeWithoutSeconds = null;
52+
\Locale::setDefault($this->defaultLocale);
5053
}
5154

5255
public function dataProvider()

Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,18 @@
1919
class MoneyToLocalizedStringTransformerTest extends TestCase
2020
{
2121
private $previousLocale;
22+
private $defaultLocale;
2223

2324
protected function setUp(): void
2425
{
2526
$this->previousLocale = setlocale(\LC_ALL, '0');
27+
$this->defaultLocale = \Locale::getDefault();
2628
}
2729

2830
protected function tearDown(): void
2931
{
3032
setlocale(\LC_ALL, $this->previousLocale);
33+
\Locale::setDefault($this->defaultLocale);
3134
}
3235

3336
public function testTransform()

Tests/Extension/Core/Type/DateTimeTypeTest.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,20 @@ class DateTimeTypeTest extends BaseTypeTest
1818
{
1919
public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\DateTimeType';
2020

21+
private $defaultLocale;
22+
2123
protected function setUp(): void
2224
{
25+
$this->defaultLocale = \Locale::getDefault();
2326
\Locale::setDefault('en');
24-
2527
parent::setUp();
2628
}
2729

30+
protected function tearDown(): void
31+
{
32+
\Locale::setDefault($this->defaultLocale);
33+
}
34+
2835
public function testSubmitDateTime()
2936
{
3037
$form = $this->factory->create(static::TESTED_TYPE, null, [

0 commit comments

Comments
 (0)