2012-06-12 02:55:27 +02:00
< ? php
2015-12-17 19:50:59 +01:00
class MSSQLDatabaseQueryTest extends SapphireTest
{
2012-06-12 02:55:27 +02:00
2015-12-17 19:50:59 +01:00
public static $fixture_file = 'MSSQLDatabaseQueryTest.yml' ;
2012-06-12 02:55:27 +02:00
2015-12-17 19:50:59 +01:00
protected $extraDataObjects = array (
'MSSQLDatabaseQueryTestDataObject'
);
2012-06-12 02:55:27 +02:00
2015-12-17 19:50:59 +01:00
public function testDateValueFormatting ()
{
$obj = $this -> objFromFixture ( 'MSSQLDatabaseQueryTestDataObject' , 'test-data-1' );
$this -> assertEquals ( '2012-01-01' , $obj -> obj ( 'TestDate' ) -> Format ( 'Y-m-d' ), 'Date field value is formatted correctly (Y-m-d)' );
}
2012-06-12 02:55:27 +02:00
2015-12-17 19:50:59 +01:00
public function testDatetimeValueFormatting ()
{
$obj = $this -> objFromFixture ( 'MSSQLDatabaseQueryTestDataObject' , 'test-data-1' );
$this -> assertEquals ( '2012-01-01 10:30:00' , $obj -> obj ( 'TestDatetime' ) -> Format ( 'Y-m-d H:i:s' ), 'Datetime field value is formatted correctly (Y-m-d H:i:s)' );
}
2012-06-12 02:55:27 +02:00
}
2015-12-17 19:50:59 +01:00
class MSSQLDatabaseQueryTestDataObject extends DataObject implements TestOnly
{
2012-06-12 02:55:27 +02:00
2015-12-17 19:50:59 +01:00
public static $db = array (
'TestDate' => 'Date' ,
'TestDatetime' => 'SS_Datetime'
);
2012-06-12 02:55:27 +02:00
}