diff --git a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php index 52ef5360bc..97ff43fc8f 100644 --- a/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php +++ b/src/Symfony/Component/Form/Tests/AbstractLayoutTest.php @@ -26,6 +26,7 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase protected $csrfTokenManager; protected $testableFeatures = []; + private $defaultLocale; protected function setUp(): void { @@ -33,6 +34,7 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase $this->markTestSkipped('Extension intl is required.'); } + $this->defaultLocale = \Locale::getDefault(); \Locale::setDefault('en'); $this->csrfTokenManager = $this->createMock(CsrfTokenManagerInterface::class); @@ -50,6 +52,7 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase protected function tearDown(): void { $this->csrfTokenManager = null; + \Locale::setDefault($this->defaultLocale); parent::tearDown(); } diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php index e2aa4748d8..cde7cd531a 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/DateTimeToLocalizedStringTransformerTest.php @@ -23,6 +23,7 @@ class DateTimeToLocalizedStringTransformerTest extends TestCase protected $dateTime; protected $dateTimeWithoutSeconds; + private $defaultLocale; protected function setUp(): void { @@ -37,6 +38,7 @@ class DateTimeToLocalizedStringTransformerTest extends TestCase // Since we test against "de_AT", we need the full implementation IntlTestHelper::requireFullIntl($this, '57.1'); + $this->defaultLocale = \Locale::getDefault(); \Locale::setDefault('de_AT'); $this->dateTime = new \DateTime('2010-02-03 04:05:06 UTC'); @@ -47,6 +49,7 @@ class DateTimeToLocalizedStringTransformerTest extends TestCase { $this->dateTime = null; $this->dateTimeWithoutSeconds = null; + \Locale::setDefault($this->defaultLocale); } public function dataProvider() diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php index 4bc43fc8df..d6459acc5e 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/MoneyToLocalizedStringTransformerTest.php @@ -19,15 +19,18 @@ use Symfony\Component\Intl\Util\IntlTestHelper; class MoneyToLocalizedStringTransformerTest extends TestCase { private $previousLocale; + private $defaultLocale; protected function setUp(): void { $this->previousLocale = setlocale(\LC_ALL, '0'); + $this->defaultLocale = \Locale::getDefault(); } protected function tearDown(): void { setlocale(\LC_ALL, $this->previousLocale); + \Locale::setDefault($this->defaultLocale); } public function testTransform() diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php index 506ec11f78..db2623aac9 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php @@ -18,13 +18,20 @@ class DateTimeTypeTest extends BaseTypeTest { public const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\DateTimeType'; + private $defaultLocale; + protected function setUp(): void { + $this->defaultLocale = \Locale::getDefault(); \Locale::setDefault('en'); - parent::setUp(); } + protected function tearDown(): void + { + \Locale::setDefault($this->defaultLocale); + } + public function testSubmitDateTime() { $form = $this->factory->create(static::TESTED_TYPE, null, [ diff --git a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractDataProviderTest.php b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractDataProviderTest.php index 0086fbdffa..84f5eac304 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractDataProviderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Provider/AbstractDataProviderTest.php @@ -733,12 +733,20 @@ abstract class AbstractDataProviderTest extends TestCase private static $rootLocales; + private $defaultLocale; + protected function setUp(): void { + $this->defaultLocale = \Locale::getDefault(); \Locale::setDefault('en'); Locale::setDefaultFallback('en'); } + protected function tearDown(): void + { + \Locale::setDefault($this->defaultLocale); + } + public function provideLocales() { return array_map( diff --git a/src/Symfony/Component/Intl/Tests/ResourceBundleTestCase.php b/src/Symfony/Component/Intl/Tests/ResourceBundleTestCase.php index 5b0096aab6..2f13602f7e 100644 --- a/src/Symfony/Component/Intl/Tests/ResourceBundleTestCase.php +++ b/src/Symfony/Component/Intl/Tests/ResourceBundleTestCase.php @@ -725,13 +725,20 @@ abstract class ResourceBundleTestCase extends TestCase ]; private static $rootLocales; + private $defaultLocale; protected function setUp(): void { + $this->defaultLocale = \Locale::getDefault(); Locale::setDefault('en'); Locale::setDefaultFallback('en'); } + protected function tearDown(): void + { + \Locale::setDefault($this->defaultLocale); + } + public function provideLocales() { return array_map( diff --git a/src/Symfony/Contracts/Translation/Test/TranslatorTest.php b/src/Symfony/Contracts/Translation/Test/TranslatorTest.php index f1261e80d3..89d9fc06d1 100644 --- a/src/Symfony/Contracts/Translation/Test/TranslatorTest.php +++ b/src/Symfony/Contracts/Translation/Test/TranslatorTest.php @@ -30,6 +30,18 @@ use Symfony\Contracts\Translation\TranslatorTrait; */ class TranslatorTest extends TestCase { + private $defaultLocale; + + protected function setUp(): void + { + $this->defaultLocale = \Locale::getDefault(); + } + + protected function tearDown(): void + { + \Locale::setDefault($this->defaultLocale); + } + public function getTranslator() { return new class() implements TranslatorInterface {