From 77267c0598e98be201eb9c79e928079e4f62fefa Mon Sep 17 00:00:00 2001 From: Rhodri Pugh Date: Mon, 6 Dec 2021 15:17:42 +0000 Subject: [PATCH] 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. --- .../Component/Validator/Test/ConstraintValidatorTestCase.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php index 7e18d71fa607d..087bbf140fb2a 100644 --- a/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php +++ b/src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php @@ -58,6 +58,7 @@ abstract class ConstraintValidatorTestCase extends TestCase protected $propertyPath; protected $constraint; protected $defaultTimezone; + private $defaultLocale; private function doSetUp() { @@ -76,6 +77,7 @@ private function doSetUp() $this->validator = $this->createValidator(); $this->validator->initialize($this->context); + $this->defaultLocale = \Locale::getDefault(); \Locale::setDefault('en'); $this->setDefaultTimezone('UTC'); @@ -84,6 +86,8 @@ private function doSetUp() private function doTearDown() { $this->restoreDefaultTimezone(); + + \Locale::setDefault($this->defaultLocale); } protected function setDefaultTimezone($defaultTimezone)