mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
79773042be
MINOR: Replaced usage of renamed classes with the new namespaced name. From: Andrew Short <andrewjshort@gmail.com> git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@90075 467b73ca-7a2a-4603-9d3b-597d59a354a9
36 lines
1.2 KiB
PHP
36 lines
1.2 KiB
PHP
<?php
|
|
/**
|
|
* Tests for {@link SS_Datetime} class.
|
|
*
|
|
* @todo Current date comparisons are slightly dodgy, as they only compare
|
|
* the current date (not hour, minute, second) and assume that the date
|
|
* doesn't switch throughout the test execution. This means tests might
|
|
* fail when run at 23:59:59.
|
|
*
|
|
* @package sapphire
|
|
* @subpackage tests
|
|
*/
|
|
class SS_DatetimeTest extends SapphireTest {
|
|
function testNowWithSystemDate() {
|
|
$systemDatetime = DBField::create('SS_Datetime', date('Y-m-d H:i:s'));
|
|
$nowDatetime = SS_Datetime::now();
|
|
|
|
$this->assertEquals($systemDatetime->Date(), $nowDatetime->Date());
|
|
}
|
|
|
|
function testNowWithMockDate() {
|
|
// Test setting
|
|
$mockDate = '2001-12-31 22:10:59';
|
|
SS_Datetime::set_mock_now($mockDate);
|
|
$systemDatetime = DBField::create('SS_Datetime', date('Y-m-d H:i:s'));
|
|
$nowDatetime = SS_Datetime::now();
|
|
$this->assertNotEquals($systemDatetime->Date(), $nowDatetime->Date());
|
|
$this->assertEquals($nowDatetime->getValue(), $mockDate);
|
|
|
|
// Test clearing
|
|
SS_Datetime::clear_mock_now();
|
|
$systemDatetime = DBField::create('SS_Datetime', date('Y-m-d H:i:s'));
|
|
$nowDatetime = SS_Datetime::now();
|
|
$this->assertEquals($systemDatetime->Date(), $nowDatetime->Date());
|
|
}
|
|
} |