Skip to content

Commit 2c845fa

Browse files
[Validator] Check Locale class existence before using it
1 parent 52099f9 commit 2c845fa

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Symfony/Component/Validator/Test/ConstraintValidatorTestCase.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ protected function setUp(): void
8080
$this->validator = $this->createValidator();
8181
$this->validator->initialize($this->context);
8282

83-
$this->defaultLocale = \Locale::getDefault();
84-
\Locale::setDefault('en');
83+
if (class_exists(\Locale::class)) {
84+
$this->defaultLocale = \Locale::getDefault();
85+
\Locale::setDefault('en');
86+
}
8587

8688
$this->expectedViolations = [];
8789
$this->call = 0;
@@ -93,7 +95,9 @@ protected function tearDown(): void
9395
{
9496
$this->restoreDefaultTimezone();
9597

96-
\Locale::setDefault($this->defaultLocale);
98+
if (class_exists(\Locale::class)) {
99+
\Locale::setDefault($this->defaultLocale);
100+
}
97101
}
98102

99103
protected function setDefaultTimezone(?string $defaultTimezone)

0 commit comments

Comments
 (0)