8000 [CI] Make sure to restore default locale by Nyholm · Pull Request #40932 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[CI] Make sure to restore default locale #40932

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

Merged
merged 1 commit into from
Apr 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@ abstract class AbstractLayoutTest extends FormIntegrationTestCase

protected $csrfTokenManager;
protected $testableFeatures = [];
private $defaultLocale;

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

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

$this->csrfTokenManager = $this->createMock(CsrfTokenManagerInterface::class);
Expand All @@ -50,6 +52,7 @@ protected function getExtensions()
protected function tearDown(): void
{
$this->csrfTokenManager = null;
\Locale::setDefault($this->defaultLocale);

parent::tearDown();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class DateTimeToLocalizedStringTransformerTest extends TestCase

protected $dateTime;
protected $dateTimeWithoutSeconds;
private $defaultLocale;

protected function setUp(): void
{
Expand All @@ -37,6 +38,7 @@ protected function setUp(): void
// 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');
Expand All @@ -47,6 +49,7 @@ protected function tearDown(): void
{
$this->dateTime = null;
$this->dateTimeWithoutSeconds = null;
\Locale::setDefault($this->defaultLocale);
}

public function dataProvider()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@
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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
7 changes: 7 additions & 0 deletions src/Symfony/Component/Intl/Tests/ResourceBundleTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
12 changes: 12 additions & 0 deletions src/Symfony/Contracts/Translation/Test/TranslatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@
*/
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 {
Expand Down
0