Skip to content

Commit 1aeb5b3

Browse files
committed
test: restore changed locale in tearDown()
1 parent a51b07c commit 1aeb5b3

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

tests/system/I18n/TimeDifferenceTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,25 @@
1919
*/
2020
final class TimeDifferenceTest extends CIUnitTestCase
2121
{
22+
private string $currentLocale;
23+
2224
protected function setUp(): void
2325
{
2426
parent::setUp();
2527

2628
helper('date');
29+
30+
$this->currentLocale = Locale::getDefault();
2731
Locale::setDefault('America/Chicago');
2832
}
2933

34+
protected function tearDown(): void
35+
{
36+
parent::tearDown();
37+
38+
Locale::setDefault($this->currentLocale);
39+
}
40+
3041
public function testDifferenceBasics()
3142
{
3243
$current = Time::parse('March 10, 2017', 'America/Chicago');

tests/system/I18n/TimeTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,25 @@
2525
*/
2626
final class TimeTest extends CIUnitTestCase
2727
{
28+
private string $currentLocale;
29+
2830
protected function setUp(): void
2931
{
3032
parent::setUp();
3133

3234
helper('date');
35+
36+
$this->currentLocale = Locale::getDefault();
3337
Locale::setDefault('en_US');
3438
}
3539

40+
protected function tearDown(): void
41+
{
42+
parent::tearDown();
43+
44+
Locale::setDefault($this->currentLocale);
45+
}
46+
3647
public function testNewTimeNow()
3748
{
3849
$formatter = new IntlDateFormatter(

0 commit comments

Comments
 (0)