Skip to content

Commit 726f64b

Browse files
committed
Add test for CarbonInterval timezone getter
1 parent 4deb6d0 commit 726f64b

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tests/CarbonInterval/GettersTest.php

+20
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Carbon\Carbon;
1717
use Carbon\CarbonInterval;
1818
use Carbon\Translator;
19+
use DateTimeZone;
1920
use InvalidArgumentException;
2021
use Tests\AbstractTestCase;
2122

@@ -121,4 +122,23 @@ public function testDebugInfo()
121122
's' => 10,
122123
], $ci->__debugInfo());
123124
}
125+
126+
public function testGetTimezone()
127+
{
128+
$this->assertNull(CarbonInterval::day()->tzName);
129+
$this->assertSame(
130+
'America/New_York',
131+
CarbonInterval::day()->setTimezone('America/New_York')->tzName,
132+
);
133+
$this->assertSame(
134+
'America/New_York',
135+
CarbonInterval::day()->setTimezone(
136+
new DateTimeZone('America/New_York'),
137+
)->tzName,
138+
);
139+
$this->assertSame(
140+
'+05:00',
141+
CarbonInterval::day()->setTimezone(5)->tzName,
142+
);
143+
}
124144
}

0 commit comments

Comments
 (0)