silverstripe-framework/tests/forms/TimeFieldTest.php
Ingo Schommer efb6f0ceaf API CHANGE TimeField doesn't internally store value as "Y-m-d g:ia" (including date), but only as "g:ia"
BUGFIX Allowing TimeField and subclasses to be set to NULL through setValue()
BUGFIX Added TimeField->dataValue() to apply same conversion as setValue()
MINOR Added TimeFieldTest

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@79355 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-06-16 06:39:57 +00:00

32 lines
885 B
PHP

<?php
/**
* @package sapphire
* @subpackage tests
*/
class TimeFieldTest extends SapphireTest {
function testDataValue12h() {
$dateField12h = new TimeField('Time', 'Time');
$dateField12h->setValue('11pm');
$this->assertEquals($dateField12h->dataValue(), '11:00pm');
$dateField12h->setValue('23:59');
$this->assertEquals($dateField12h->dataValue(), '11:59pm');
$dateField12h->setValue('11:59pm');
$this->assertEquals($dateField12h->dataValue(), '11:59pm');
}
function testDataValue24h() {
$dateField24h = new TimeField('Time', 'Time', null, 'H:i');
$dateField24h->setValue('11pm');
$this->assertEquals($dateField24h->dataValue(), '23:00');
$dateField24h->setValue('23:59');
$this->assertEquals($dateField24h->dataValue(), '23:59');
$dateField24h->setValue('11:59pm');
$this->assertEquals($dateField24h->dataValue(), '23:59');
}
}