6 require_once 'application/TimeZone.php';
9 * Unitary tests for timezone utilities
11 class TimeZoneTest
extends PHPUnit_Framework_TestCase
14 * Generate a timezone selection form
16 public function testGenerateTimeZoneForm()
18 $generated = generateTimeZoneForm();
21 $this->assertStringStartsWith('Continent:<select', $generated[0]);
22 $this->assertContains('selected="selected"', $generated[0]);
23 $this->assertStringEndsWith('</select><br />', $generated[0]);
26 $this->assertStringStartsWith('<script>', $generated[1]);
27 $this->assertContains(
28 '<option value=\"Bermuda\">Bermuda<\/option>',
31 $this->assertStringEndsWith('</script>', $generated[1]);
35 * Generate a timezone selection form, with a preselected timezone
37 public function testGenerateTimeZoneFormPreselected()
39 $generated = generateTimeZoneForm('Antarctica/Syowa');
42 $this->assertStringStartsWith('Continent:<select', $generated[0]);
43 $this->assertContains(
44 'value="Antarctica" selected="selected"',
47 $this->assertContains(
48 'value="Syowa" selected="selected"',
51 $this->assertStringEndsWith('</select><br />', $generated[0]);
55 $this->assertStringStartsWith('<script>', $generated[1]);
56 $this->assertContains(
57 '<option value=\"Bermuda\">Bermuda<\/option>',
60 $this->assertStringEndsWith('</script>', $generated[1]);
64 * Check valid timezones
66 public function testValidTimeZone()
68 $this->assertTrue(isTimeZoneValid('America', 'Argentina/Ushuaia'));
69 $this->assertTrue(isTimeZoneValid('Europe', 'Oslo'));
73 * Check invalid timezones
75 public function testInvalidTimeZone()
77 $this->assertFalse(isTimeZoneValid('CEST', 'CEST'));
78 $this->assertFalse(isTimeZoneValid('Europe', 'Atlantis'));
79 $this->assertFalse(isTimeZoneValid('Middle_Earth', 'Moria'));
80 $this->assertFalse(isTimeZoneValid('UTC', 'UTC'));