File tree Expand file tree Collapse file tree 2 files changed +16
-3
lines changed
src/Symfony/Component/Translation Expand file tree Collapse file tree 2 files changed +16
-3
lines changed Original file line number Diff line number Diff line change 19
19
20
20
class TranslatorTest extends TestCase
21
21
{
22
+ private $ defaultLocale ;
23
+
24
+ protected function setUp (): void
25
+ {
26
+ $ this ->defaultLocale = \Locale::getDefault ();
27
+ \Locale::setDefault ('en ' );
28
+ }
29
+
30
+ protected function tearDown (): void
31
+ {
32
+ \Locale::setDefault ($ this ->defaultLocale );
33
+ }
34
+
22
35
/**
23
36
* @dataProvider getInvalidLocalesTests
24
37
*/
@@ -45,7 +58,7 @@ public function testConstructorWithoutLocale()
45
58
{
46
59
$ translator = new Translator (null );
47
60
48
- $ this ->assertNull ( $ translator ->getLocale ());
61
+ $ this ->assertSame ( ' en ' , $ translator ->getLocale ());
49
62
}
50
63
51
64
public function testSetGetLocale ()
@@ -87,7 +100,7 @@ public function testSetNullLocale()
87
100
$ translator = new Translator ('en ' );
88
101
$ translator ->setLocale (null );
89
102
90
- $ this ->assertNull ( $ translator ->getLocale ());
103
+ $ this ->assertSame ( ' en ' , $ translator ->getLocale ());
91
104
}
92
105
93
106
public function testGetCatalogue ()
Original file line number Diff line number Diff line change @@ -171,7 +171,7 @@ public function setLocale($locale)
171
171
*/
172
172
public function getLocale ()
173
173
{
174
- return $ this ->locale ;
174
+ return $ this ->locale ?? \Locale:: getDefault () ;
175
175
}
176
176
177
177
/**
You can’t perform that action at this time.
0 commit comments