-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Get default locale before setting a new locale #11200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This should fix #11199
|
Sounds reasonable. |
Codecov Report
@@ Coverage Diff @@
## master #11200 +/- ##
============================================
+ Coverage 93.14% 93.14% +<.01%
Complexity 12981 12981
============================================
Files 437 437
Lines 33623 33624 +1
============================================
+ Hits 31318 31319 +1
Misses 2305 2305
Continue to review full report at Codecov.
|
|
Is there anyway we could test for this? |
|
I'm not sure how, since we call But the general idea would be to read the 'default' without setting the class variable, then setting another locale (using I imagine the test to go something like this: public function testDefaultLocale() {
$default = Locale::getDefault() ?: I18n::DEFAULT_LOCALE;
$newLocale = 'de_DE';
I18n::setLocale($newLocale);
$this->assertEquals($newLocale, I18n::getLocale());
$this->assertEquals($default, I18n::getDefaultLocale());
}What do you think? And how can we integrate that in the current test setup? |
|
@liviascapin I think that test looks good. We could also read the class properties with phpunit as well. |
|
Thanks! :) |
|
You should be able to use PHPUnit or Reflection APIs to read the value of the protected property. |
|
Ah I think I get it now :) I tried to write the test, but I still have a problem with it and I feel kind of stuck. I tried to ensure that the test fails in 3.5.2 and doesn't fail with this fix. However, if I run all the tests, this test passes in both cases. If I only run this specific test, it fails as expected (in 3.5.2). I guess it is because other tests (such as the FloatTypeTest or the NumberTest) use |
|
Yeah. I think we're going to have a really hard time testing this. I'll merge as the tests are still useful to have. |
This should fix #11199