Skip to content

Commit 7545a05

Browse files
committed
restore the overriden locale on tearDown - avoid interfering with any configured value
Previously this change was not resetting the locale after changing it to 'en' - which affected other tests which relied on this value being the configured value (however it was configured). This mirrors the pattern used for the timezone, storing it to be reset on tearDown.
1 parent c4cf6b0 commit 7545a05

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Test/ConstraintValidatorTestCase.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ abstract class ConstraintValidatorTestCase extends TestCase
5858
protected $propertyPath;
5959
protected $constraint;
6060
protected $defaultTimezone;
61+
private $defaultLocale;
6162

6263
private function doSetUp()
6364
{
@@ -76,6 +77,7 @@ private function doSetUp()
7677
$this->validator = $this->createValidator();
7778
$this->validator->initialize($this->context);
7879

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

8183
$this->setDefaultTimezone('UTC');
@@ -84,6 +86,8 @@ private function doSetUp()
8486
private function doTearDown()
8587
{
8688
$this->restoreDefaultTimezone();
89+
90+
\Locale::setDefault($this->defaultLocale);
8791
}
8892

8993
protected function setDefaultTimezone($defaultTimezone)

0 commit comments

Comments
 (0)