mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
204620b99d
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@79357 467b73ca-7a2a-4603-9d3b-597d59a354a9
46 lines
1.2 KiB
PHP
46 lines
1.2 KiB
PHP
<?php
|
|
/**
|
|
* @package sapphire
|
|
* @subpackage tests
|
|
*/
|
|
class TimeFieldTest extends SapphireTest {
|
|
function testDataValue12h() {
|
|
$field12h = new TimeField('Time', 'Time');
|
|
|
|
$field12h->setValue('11pm');
|
|
$this->assertEquals($field12h->dataValue(), '11:00pm');
|
|
|
|
$field12h->setValue('23:59');
|
|
$this->assertEquals($field12h->dataValue(), '11:59pm');
|
|
|
|
$field12h->setValue('11:59pm');
|
|
$this->assertEquals($field12h->dataValue(), '11:59pm');
|
|
|
|
$field12h->setValue('11:59 pm');
|
|
$this->assertEquals($field12h->dataValue(), '11:59pm');
|
|
}
|
|
|
|
function testDataValue24h() {
|
|
$field24h = new TimeField('Time', 'Time', null, 'H:i');
|
|
|
|
$field24h->setValue('11pm');
|
|
$this->assertEquals($field24h->dataValue(), '23:00');
|
|
|
|
$field24h->setValue('23:59');
|
|
$this->assertEquals($field24h->dataValue(), '23:59');
|
|
|
|
$field24h->setValue('11:59pm');
|
|
$this->assertEquals($field24h->dataValue(), '23:59');
|
|
|
|
$field24h->setValue('11:59 pm');
|
|
$this->assertEquals($field24h->dataValue(), '23:59');
|
|
}
|
|
|
|
function testOverrideWithNull() {
|
|
$field = new TimeField('Time', 'Time');
|
|
|
|
$field->setValue('11:00pm');
|
|
$field->setValue('');
|
|
$this->assertEquals($field->dataValue(), '');
|
|
}
|
|
} |