mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
2451fdbee9
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@105843 467b73ca-7a2a-4603-9d3b-597d59a354a9
40 lines
1.4 KiB
PHP
Executable File
40 lines
1.4 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* @package cms
|
|
* @subpackage tests
|
|
*/
|
|
|
|
class SideReportTest extends SapphireTest {
|
|
static $fixture_file = 'cms/tests/SideReportTest.yml';
|
|
static $daysAgo = 14;
|
|
|
|
function setUp() {
|
|
parent::setUp();
|
|
|
|
// set the dates by hand: impossible to set via yml
|
|
$afterThreshold = strtotime('-'.(SideReportTest::$daysAgo-1).' days', strtotime('31-06-2009 00:00:00'));
|
|
$beforeThreshold = strtotime('-'.(SideReportTest::$daysAgo+1).' days', strtotime('31-06-2009 00:00:00'));
|
|
|
|
$after = $this->objFromFixture('SiteTree', 'after');
|
|
$before = $this->objFromFixture('SiteTree', 'before');
|
|
|
|
DB::query("UPDATE \"SiteTree\" SET \"Created\"='2009-01-01 00:00:00', \"LastEdited\"='".date('Y-m-d H:i:s', $afterThreshold)."' WHERE \"ID\"='".$after->ID."'");
|
|
DB::query("UPDATE \"SiteTree\" SET \"Created\"='2009-01-01 00:00:00', \"LastEdited\"='".date('Y-m-d H:i:s', $beforeThreshold)."' WHERE \"ID\"='".$before->ID."'");
|
|
}
|
|
|
|
function testRecentlyEdited() {
|
|
SS_Datetime::set_mock_now('31-06-2009 00:00:00');
|
|
|
|
$after = $this->objFromFixture('SiteTree', 'after');
|
|
$before = $this->objFromFixture('SiteTree', 'before');
|
|
|
|
$r = new SideReport_RecentlyEdited();
|
|
|
|
// check if contains only elements not older than $daysAgo days
|
|
$this->assertNotNull($r->records(array()));
|
|
$this->assertContains($after->ID, $r->records(array())->column('ID'));
|
|
$this->assertNotContains($before->ID, $r->records(array())->column('ID'));
|
|
|
|
SS_DateTime::clear_mock_now();
|
|
}
|
|
} |