2009-06-18 02:10:02 +02:00
|
|
|
<?php
|
|
|
|
/**
|
API CHANGE: Renamed conflicting classes to have an "SS_" namespace, and renamed existing "SS" namespace to "SS_". The affected classes are: HTTPRequest, HTTPResponse, Query, Database, SSBacktrace, SSCli, SSDatetime, SSDatetimeTest, SSLog, SSLogTest, SSLogEmailWriter, SSLogErrorEmailFormatter, SSLogErrorFileFormatter, SSLogFileWriter and SSZendLog.
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
2009-10-26 04:06:31 +01:00
|
|
|
* Tests for {@link SS_Datetime} class.
|
2009-06-18 02:10:02 +02:00
|
|
|
*
|
|
|
|
* @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
|
|
|
|
*/
|
API CHANGE: Renamed conflicting classes to have an "SS_" namespace, and renamed existing "SS" namespace to "SS_". The affected classes are: HTTPRequest, HTTPResponse, Query, Database, SSBacktrace, SSCli, SSDatetime, SSDatetimeTest, SSLog, SSLogTest, SSLogEmailWriter, SSLogErrorEmailFormatter, SSLogErrorFileFormatter, SSLogFileWriter and SSZendLog.
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
2009-10-26 04:06:31 +01:00
|
|
|
class SS_DatetimeTest extends SapphireTest {
|
2009-06-18 02:10:02 +02:00
|
|
|
function testNowWithSystemDate() {
|
API CHANGE: Renamed conflicting classes to have an "SS_" namespace, and renamed existing "SS" namespace to "SS_". The affected classes are: HTTPRequest, HTTPResponse, Query, Database, SSBacktrace, SSCli, SSDatetime, SSDatetimeTest, SSLog, SSLogTest, SSLogEmailWriter, SSLogErrorEmailFormatter, SSLogErrorFileFormatter, SSLogFileWriter and SSZendLog.
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
2009-10-26 04:06:31 +01:00
|
|
|
$systemDatetime = DBField::create('SS_Datetime', date('Y-m-d H:i:s'));
|
|
|
|
$nowDatetime = SS_Datetime::now();
|
2009-06-18 02:10:02 +02:00
|
|
|
|
|
|
|
$this->assertEquals($systemDatetime->Date(), $nowDatetime->Date());
|
|
|
|
}
|
|
|
|
|
|
|
|
function testNowWithMockDate() {
|
|
|
|
// Test setting
|
|
|
|
$mockDate = '2001-12-31 22:10:59';
|
API CHANGE: Renamed conflicting classes to have an "SS_" namespace, and renamed existing "SS" namespace to "SS_". The affected classes are: HTTPRequest, HTTPResponse, Query, Database, SSBacktrace, SSCli, SSDatetime, SSDatetimeTest, SSLog, SSLogTest, SSLogEmailWriter, SSLogErrorEmailFormatter, SSLogErrorFileFormatter, SSLogFileWriter and SSZendLog.
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
2009-10-26 04:06:31 +01:00
|
|
|
SS_Datetime::set_mock_now($mockDate);
|
|
|
|
$systemDatetime = DBField::create('SS_Datetime', date('Y-m-d H:i:s'));
|
|
|
|
$nowDatetime = SS_Datetime::now();
|
2009-06-18 02:10:02 +02:00
|
|
|
$this->assertNotEquals($systemDatetime->Date(), $nowDatetime->Date());
|
|
|
|
$this->assertEquals($nowDatetime->getValue(), $mockDate);
|
|
|
|
|
|
|
|
// Test clearing
|
API CHANGE: Renamed conflicting classes to have an "SS_" namespace, and renamed existing "SS" namespace to "SS_". The affected classes are: HTTPRequest, HTTPResponse, Query, Database, SSBacktrace, SSCli, SSDatetime, SSDatetimeTest, SSLog, SSLogTest, SSLogEmailWriter, SSLogErrorEmailFormatter, SSLogErrorFileFormatter, SSLogFileWriter and SSZendLog.
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
2009-10-26 04:06:31 +01:00
|
|
|
SS_Datetime::clear_mock_now();
|
|
|
|
$systemDatetime = DBField::create('SS_Datetime', date('Y-m-d H:i:s'));
|
|
|
|
$nowDatetime = SS_Datetime::now();
|
2009-06-18 02:10:02 +02:00
|
|
|
$this->assertEquals($systemDatetime->Date(), $nowDatetime->Date());
|
|
|
|
}
|
|
|
|
}
|