mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
Merge pull request #52 from stojg/unittest-fix
MINOR: Fixed DateTest to use correct timezone setters
This commit is contained in:
commit
3c3cd8782a
15
tests/model/DateTest.php
Normal file → Executable file
15
tests/model/DateTest.php
Normal file → Executable file
@ -10,14 +10,23 @@ class DateTest extends SapphireTest {
|
|||||||
function setUp() {
|
function setUp() {
|
||||||
// Set timezone to support timestamp->date conversion.
|
// Set timezone to support timestamp->date conversion.
|
||||||
// We can't use date_default_timezone_set() as its not supported prior to PHP 5.2
|
// 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();
|
parent::setUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
function tearDown() {
|
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();
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user