MINOR: Fixed DateTest to work on Centos installation with another default date.timezone than Pacific/Auckland

Checking for PHP version and using the correct function for setting timezone
This commit is contained in:
Stig Lindqvist 2011-08-30 00:38:59 +02:00
parent 654173e46b
commit 0aeda5c924

15
tests/model/DateTest.php Normal file → Executable file
View File

@ -10,14 +10,23 @@ class DateTest extends SapphireTest {
function setUp() {
// Set timezone to support timestamp->date conversion.
// We can't use date_default_timezone_set() as its not supported prior to PHP 5.2
$this->originalTZ = ini_get('date.timezone');
ini_set('date.timezone','Pacific/Auckland');
if (version_compare(PHP_VERSION, '5.2.0', '<')) {
$this->originalTZ = ini_get('date.timezone');
ini_set('date.timezone', 'Pacific/Auckland');
} else {
$this->originalTZ = date_default_timezone_get();
date_default_timezone_set('Pacific/Auckland');
}
parent::setUp();
}
function tearDown() {
ini_set('date.timezone',$this->originalTZ);
if(version_compare(PHP_VERSION, '5.2.0', '<') ){
ini_set('date.timezone',$this->originalTZ);
} else {
date_default_timezone_set($this->originalTZ);
}
parent::tearDown();
}