Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c717083

Browse filesBrowse files
committed
minor #31448 [Form] Restore default locale during tests (ro0NL)
This PR was merged into the 3.4 branch. Discussion ---------- [Form] Restore default locale during tests | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes-ish | New feature? | no | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | #31294 (comment) | License | MIT | Doc PR | symfony/symfony-docs#... <!-- required for new features --> This fixes the failing tests in #31294 Commits ------- 7fce86f [Form] Restore default locale during tests
2 parents fb4d928 + 7fce86f commit c717083
Copy full SHA for c717083

File tree

Expand file treeCollapse file tree

6 files changed

+48
-7
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+48
-7
lines changed

‎src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/IntegerToLocalizedStringTransformerTest.php
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,19 @@
1717

1818
class IntegerToLocalizedStringTransformerTest extends TestCase
1919
{
20+
private $defaultLocale;
21+
2022
protected function setUp()
2123
{
22-
parent::setUp();
23-
24+
$this->defaultLocale = \Locale::getDefault();
2425
\Locale::setDefault('en');
2526
}
2627

28+
protected function tearDown()
29+
{
30+
\Locale::setDefault($this->defaultLocale);
31+
}
32+
2733
public function transformWithRoundingProvider()
2834
{
2935
return [

‎src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/NumberToLocalizedStringTransformerTest.php
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,19 @@
1717

1818
class NumberToLocalizedStringTransformerTest extends TestCase
1919
{
20+
private $defaultLocale;
21+
2022
protected function setUp()
2123
{
22-
parent::setUp();
23-
24+
$this->defaultLocale = \Locale::getDefault();
2425
\Locale::setDefault('en');
2526
}
2627

28+
protected function tearDown()
29+
{
30+
\Locale::setDefault($this->defaultLocale);
31+
}
32+
2733
public function provideTransformations()
2834
{
2935
return [

‎src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Extension/Core/DataTransformer/PercentToLocalizedStringTransformerTest.php
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,19 @@
1717

1818
class PercentToLocalizedStringTransformerTest extends TestCase
1919
{
20+
private $defaultLocale;
21+
2022
protected function setUp()
2123
{
22-
parent::setUp();
23-
24+
$this->defaultLocale = \Locale::getDefault();
2425
\Locale::setDefault('en');
2526
}
2627

28+
protected function tearDown()
29+
{
30+
\Locale::setDefault($this->defaultLocale);
31+
}
32+
2733
public function testTransform()
2834
{
2935
$transformer = new PercentToLocalizedStringTransformer();

‎src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTypeTest.php
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,19 @@ class DateTypeTest extends BaseTypeTest
2020
const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\DateType';
2121

2222
private $defaultTimezone;
23+
private $defaultLocale;
2324

2425
protected function setUp()
2526
{
2627
parent::setUp();
2728
$this->defaultTimezone = date_default_timezone_get();
29+
$this->defaultLocale = \Locale::getDefault();
2830
}
2931

3032
protected function tearDown()
3133
{
3234
date_default_timezone_set($this->defaultTimezone);
33-
\Locale::setDefault('en');
35+
\Locale::setDefault($this->defaultLocale);
3436
}
3537

3638
/**

‎src/Symfony/Component/Form/Tests/Extension/Core/Type/MoneyTypeTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Extension/Core/Type/MoneyTypeTest.php
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,24 @@ class MoneyTypeTest extends BaseTypeTest
1717
{
1818
const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\MoneyType';
1919

20+
private $defaultLocale;
21+
2022
protected function setUp()
2123
{
2224
// we test against different locales, so we need the full
2325
// implementation
2426
IntlTestHelper::requireFullIntl($this, false);
2527

2628
parent::setUp();
29+
30+
$this->defaultLocale = \Locale::getDefault();
31+
}
32+
33+
protected function tearDown()
34+
{
35+
parent::tearDown();
36+
37+
\Locale::setDefault($this->defaultLocale);
2738
}
2839

2940
public function testPassMoneyPatternToView()

‎src/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Form/Tests/Extension/Core/Type/NumberTypeTest.php
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,26 @@ class NumberTypeTest extends BaseTypeTest
1717
{
1818
const TESTED_TYPE = 'Symfony\Component\Form\Extension\Core\Type\NumberType';
1919

20+
private $defaultLocale;
21+
2022
protected function setUp()
2123
{
2224
parent::setUp();
2325

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

29+
$this->defaultLocale = \Locale::getDefault();
2730
\Locale::setDefault('de_DE');
2831
}
2932

33+
protected function tearDown()
34+
{
35+
parent::tearDown();
36+
37+
\Locale::setDefault($this->defaultLocale);
38+
}
39+
3040
public function testDefaultFormatting()
3141
{
3242
$form = $this->factory->create(static::TESTED_TYPE);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.