Skip to content

[Form] Restore default locale during tests #31448

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
May 10, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@

class IntegerToLocalizedStringTransformerTest extends TestCase
{
private $defaultLocale;

protected function setUp()
{
parent::setUp();

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

protected function tearDown()
{
\Locale::setDefault($this->defaultLocale);
}

public function transformWithRoundingProvider()
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@

class NumberToLocalizedStringTransformerTest extends TestCase
{
private $defaultLocale;

protected function setUp()
{
parent::setUp();

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

protected function tearDown()
{
\Locale::setDefault($this->defaultLocale);
}

public function provideTransformations()
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@

class PercentToLocalizedStringTransformerTest extends TestCase
{
private $defaultLocale;

protected function setUp()
{
parent::setUp();

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

protected function tearDown()
{
\Locale::setDefault($this->defaultLocale);
}

public function testTransform()
{
$transformer = new PercentToLocalizedStringTransformer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@ class DateTypeTest extends BaseTypeTest
const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\DateType';

private $defaultTimezone;
private $defaultLocale;

protected function setUp()
{
parent::setUp();
$this->defaultTimezone = date_default_timezone_get();
$this->defaultLocale = \Locale::getDefault();
}

protected function tearDown()
{
date_default_timezone_set($this->defaultTimezone);
\Locale::setDefault('en');
\Locale::setDefault($this->defaultLocale);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,24 @@ class MoneyTypeTest extends BaseTypeTest
{
const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\MoneyType';

private $defaultLocale;

protected function setUp()
{
// we test against different locales, so we need the full
// implementation
IntlTestHelper::requireFullIntl($this, false);

parent::setUp();

$this->defaultLocale = \Locale::getDefault();
}

protected function tearDown()
{
parent::tearDown();

\Locale::setDefault($this->defaultLocale);
}

public function testPassMoneyPatternToView()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,26 @@ class NumberTypeTest extends BaseTypeTest
{
const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\NumberType';

private $defaultLocale;

protected function setUp()
{
parent::setUp();

// we test against "de_DE", so we need the full implementation
IntlTestHelper::requireFullIntl($this, false);

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

protected function tearDown()
{
parent::tearDown();

\Locale::setDefault($this->defaultLocale);
}

public function testDefaultFormatting()
{
$form = $this->factory->create(static::TESTED_TYPE);
Expand Down