mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
60f75c5ca4
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@71172 467b73ca-7a2a-4603-9d3b-597d59a354a9
39 lines
1.4 KiB
PHP
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');
|
|
}
|
|
|
|
}
|
|
?>
|