TestCase::setLocale()
resets LC_ALL
locale without respecting format
#5200
Labels
type/bug
Something is broken
version/9
Something affects PHPUnit 9
version/10
Something affects PHPUnit 10
Summary
When using
TestCase::setLocale
in combination with\LC_ALL
, PHPUnit does not reset the locale properly.In the worst case, it throws a warning which stops the test:
Current behavior
Here, PHPUnit saves the currently used locale with
setlocale($category, 0)
.phpunit/src/Framework/TestCase.php
Line 1080 in e00f0fe
Then, it tries to reset the locale based on what was saved.
phpunit/src/Framework/TestCase.php
Line 1790 in e00f0fe
However, when we use
\LC_ALL
and it contains something other thanC
,setlocale(\LC_ALL, 0)
returns a list of key-value pairs separated by semicolons.https://3v4l.org/BNNQu
Therefore, PHPUnit tries to reset the locale for
\LC_ALL
with an invalid value.How to reproduce
Expected behavior
No error.
Locale reset to the previous value.
The text was updated successfully, but these errors were encountered: