File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed
test/php/library/Icinga/Util Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ /* Icinga Web 2 | (c) 2017 Icinga Development Team | GPLv2+ */
3+
4+ namespace Tests \Icinga \Util ;
5+
6+ use Icinga \Test \BaseTestCase ;
7+ use Icinga \Util \TimezoneDetect ;
8+
9+ class TimezoneDetectTest extends BaseTestCase
10+ {
11+ public function testInvalidTimezoneNameInCookie (): void
12+ {
13+ $ _COOKIE [TimezoneDetect::$ cookieName ] = 'ABC ' ;
14+ $ tzDetect = new TimezoneDetect ();
15+ $ this ->assertFalse (
16+ $ tzDetect ->success (),
17+ false ,
18+ 'Failed to assert invalid timezone name detected '
19+ );
20+
21+ $ this ->assertNull (
22+ $ tzDetect ->getTimezoneName (),
23+ 'Failed to assert that the timezone name returns null for invalid timezone '
24+ );
25+ }
26+
27+ public function testValidTimezoneNameInCookie (): void
28+ {
29+ $ _COOKIE [TimezoneDetect::$ cookieName ] = "Europe/Berlin " ;
30+ $ tzDetect = new TimezoneDetect ();
31+ $ this ->assertTrue (
32+ $ tzDetect ->success (),
33+ true ,
34+ 'Failed to assert that the valid timezone name detected '
35+ );
36+
37+ $ this ->assertSame (
38+ $ tzDetect ->getTimezoneName (),
39+ "Europe/Berlin " ,
40+ 'Failed to assert that the valid timezone name was correctly set '
41+ );
42+ }
43+ }
You can’t perform that action at this time.
0 commit comments