Skip to content

Commit

Permalink
BUGFIX: Correct testSetNullAndZeroValues() of DatetimeTest
Browse files Browse the repository at this point in the history
- Code was assuming NZ time zone
- Set the default timezone to UTC for the test
- Correct the expected times for the epoch from noon to 00:00:00 UTC
  • Loading branch information
oddnoc committed Mar 9, 2012
1 parent 6e6890f commit df050ed
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tests/model/DatetimeTest.php
Expand Up @@ -35,6 +35,8 @@ function testNowWithMockDate() {
}

function testSetNullAndZeroValues() {
date_default_timezone_set('UTC');

$date = DBField::create('SS_Datetime', '');
$this->assertNull($date->getValue(), 'Empty string evaluates to NULL');

Expand All @@ -45,10 +47,10 @@ function testSetNullAndZeroValues() {
$this->assertNull($date->getValue(), 'Boolean FALSE evaluates to NULL');

$date = DBField::create('SS_Datetime', '0');
$this->assertEquals('1970-01-01 12:00:00', $date->getValue(), 'String zero is UNIX epoch time');
$this->assertEquals('1970-01-01 00:00:00', $date->getValue(), 'String zero is UNIX epoch time');

$date = DBField::create('SS_Datetime', 0);
$this->assertEquals('1970-01-01 12:00:00', $date->getValue(), 'Numeric zero is UNIX epoch time');
$this->assertEquals('1970-01-01 00:00:00', $date->getValue(), 'Numeric zero is UNIX epoch time');
}

}

0 comments on commit df050ed

Please sign in to comment.