Skip to content

Commit

Permalink
MINOR Fixed AggregateTest for MSSQLDatabase (wrong date formatting) (…
Browse files Browse the repository at this point in the history
…from r103640)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112156 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information
Sam Minnee committed Oct 13, 2010
1 parent 8da5de8 commit f5fb01d
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions tests/model/AggregateTest.php
Expand Up @@ -93,13 +93,13 @@ function testAutoTypeAggregate() {
*/
function testBaseFieldAggregate() {
$this->assertEquals(
DataObject::Aggregate('AggregateTest_Foo')->Max('LastEdited'),
DataObject::get_one('AggregateTest_Foo', '', '', 'LastEdited DESC')->LastEdited
$this->formatDate(DataObject::Aggregate('AggregateTest_Foo')->Max('LastEdited')),
$this->formatDate(DataObject::get_one('AggregateTest_Foo', '', '', 'LastEdited DESC')->LastEdited)
);

$this->assertEquals(
DataObject::Aggregate('AggregateTest_Foo')->Max('Created'),
DataObject::get_one('AggregateTest_Foo', '', '', 'Created DESC')->Created
$this->formatDate(DataObject::Aggregate('AggregateTest_Foo')->Max('Created')),
$this->formatDate(DataObject::get_one('AggregateTest_Foo', '', '', 'Created DESC')->Created)
);
}
/* */
Expand Down Expand Up @@ -175,4 +175,14 @@ function testRelationshipAggregate() {
}
/* */

/**
* Copied from DataObject::__construct(), special case for MSSQLDatabase.
*
* @param String
* @return String
*/
protected function formatDate($dateStr) {
$dateStr = preg_replace('/:[0-9][0-9][0-9]([ap]m)$/i', ' \\1', $dateStr);
return date('Y-m-d H:i:s', strtotime($dateStr));
}
}

0 comments on commit f5fb01d

Please sign in to comment.