From d1e2f8e52c931f84c11d4f54f32959710d528182 Mon Sep 17 00:00:00 2001 From: VirtualTam Date: Sat, 11 Jul 2015 01:29:12 +0200 Subject: PHP: ensure 5.3 compatibility, refactor timezone utilities Relates to #250 Modifications - supported version - bump required version from 5.1.0 to 5.3.x - update README - add PHP 5.3 to Travis environments - rewrite array declarations: explicitely use array() instead of [] - move checkPHPVersion to application/Utils.php - move timezone functions to application/TimeZone.php - cleanup code - improve test coverage Signed-off-by: VirtualTam --- tests/TimeZoneTest.php | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 tests/TimeZoneTest.php (limited to 'tests/TimeZoneTest.php') diff --git a/tests/TimeZoneTest.php b/tests/TimeZoneTest.php new file mode 100644 index 00000000..f3de3913 --- /dev/null +++ b/tests/TimeZoneTest.php @@ -0,0 +1,83 @@ +assertStringStartsWith('Continent:assertContains('selected="selected"', $generated[0]); + $this->assertStringEndsWith('
', $generated[0]); + + // Javascript handler + $this->assertStringStartsWith('', $generated[1]); + } + + /** + * Generate a timezone selection form, with a preselected timezone + */ + public function testGenerateTimeZoneFormPreselected() + { + $generated = generateTimeZoneForm('Antarctica/Syowa'); + + // HTML form + $this->assertStringStartsWith('Continent:assertContains( + 'value="Antarctica" selected="selected"', + $generated[0] + ); + $this->assertContains( + 'value="Syowa" selected="selected"', + $generated[0] + ); + $this->assertStringEndsWith('
', $generated[0]); + + + // Javascript handler + $this->assertStringStartsWith('', $generated[1]); + } + + /** + * Check valid timezones + */ + public function testValidTimeZone() + { + $this->assertTrue(isTimeZoneValid('America', 'Argentina/Ushuaia')); + $this->assertTrue(isTimeZoneValid('Europe', 'Oslo')); + $this->assertTrue(isTimeZoneValid('UTC', 'UTC')); + } + + /** + * Check invalid timezones + */ + public function testInvalidTimeZone() + { + $this->assertFalse(isTimeZoneValid('CEST', 'CEST')); + $this->assertFalse(isTimeZoneValid('Europe', 'Atlantis')); + $this->assertFalse(isTimeZoneValid('Middle_Earth', 'Moria')); + } +} +?> -- cgit v1.2.3