silverstripe-framework/tests/forms/DateFieldTest.php
Andrew O'Neil 60f75c5ca4 Merged changes from 2.3 branch
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@71172 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-02-01 23:49:53 +00:00

39 lines
1.4 KiB
PHP

<?php
/**
* @package sapphire
* @subpackage tests
*/
class DateFieldTest extends SapphireTest {
function testDMYFormat() {
/* We get YYYY-MM-DD format as the data value for DD/MM/YYYY input value */
$dateField = new DateField('Date', 'Date', '04/03/2003');
$this->assertEquals($dateField->dataValue(), '2003-03-04');
/* Even if value hasn't got leading 0's in it we still get the correct data value */
$dateField2 = new DateField('Date', 'Date', '4/3/03');
$this->assertEquals($dateField2->dataValue(), '03-3-4');
}
function testYMDFormat() {
/* We get YYYY-MM-DD format as the data value for YYYY-MM-DD input value */
$dateField = new DateField('Date', 'Date', '2003/03/04');
$this->assertEquals($dateField->dataValue(), '2003-03-04');
/* Even if input value hasn't got leading 0's in it we still get the correct data value */
$dateField2 = new DateField('Date', 'Date', '2003/3/4');
$this->assertEquals($dateField2->dataValue(), '2003-03-04');
}
function testMDYFormat() {
/* We get MM-DD-YYYY format as the data value for YYYY-MM-DD input value */
$dateField = new DateField('Date', 'Date', '03/04/2003');
$this->assertEquals($dateField->dataValue(), '2003-04-03');
/* Even if input value hasn't got leading 0's in it we still get the correct data value */
$dateField2 = new DateField('Date', 'Date', '3/4/03');
$this->assertEquals($dateField2->dataValue(), '03-4-3');
}
}
?>