Permalink
Browse files

MINOR Fixed AggregateTest for MSSQLDatabase (wrong date formatting) (…

…from r103640)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112156 467b73ca-7a2a-4603-9d3b-597d59a354a9
  • Loading branch information...
1 parent 8da5de8 commit f5fb01d11b150b99aa0ebdb93852ca8fd58b10b6 @sminnee sminnee committed Oct 13, 2010
Showing with 14 additions and 4 deletions.
  1. +14 −4 tests/model/AggregateTest.php
@@ -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)
);
}
/* */
@@ -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.