2009-06-16 08:39:57 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @package sapphire
|
|
|
|
* @subpackage tests
|
|
|
|
*/
|
|
|
|
class TimeFieldTest extends SapphireTest {
|
|
|
|
function testDataValue12h() {
|
2009-06-16 09:03:17 +02:00
|
|
|
$field12h = new TimeField('Time', 'Time');
|
2009-06-16 08:39:57 +02:00
|
|
|
|
2009-06-16 09:03:17 +02:00
|
|
|
$field12h->setValue('11pm');
|
|
|
|
$this->assertEquals($field12h->dataValue(), '11:00pm');
|
2009-06-16 08:39:57 +02:00
|
|
|
|
2009-06-16 09:03:17 +02:00
|
|
|
$field12h->setValue('23:59');
|
|
|
|
$this->assertEquals($field12h->dataValue(), '11:59pm');
|
2009-06-16 08:39:57 +02:00
|
|
|
|
2009-06-16 09:03:17 +02:00
|
|
|
$field12h->setValue('11:59pm');
|
|
|
|
$this->assertEquals($field12h->dataValue(), '11:59pm');
|
|
|
|
|
|
|
|
$field12h->setValue('11:59 pm');
|
|
|
|
$this->assertEquals($field12h->dataValue(), '11:59pm');
|
2009-06-16 08:39:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function testDataValue24h() {
|
2009-06-16 09:03:17 +02:00
|
|
|
$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');
|
2009-06-16 08:39:57 +02:00
|
|
|
|
2009-06-16 09:03:17 +02:00
|
|
|
$field24h->setValue('11:59pm');
|
|
|
|
$this->assertEquals($field24h->dataValue(), '23:59');
|
2009-06-16 08:39:57 +02:00
|
|
|
|
2009-06-16 09:03:17 +02:00
|
|
|
$field24h->setValue('11:59 pm');
|
|
|
|
$this->assertEquals($field24h->dataValue(), '23:59');
|
|
|
|
}
|
|
|
|
|
|
|
|
function testOverrideWithNull() {
|
|
|
|
$field = new TimeField('Time', 'Time');
|
2009-06-16 08:39:57 +02:00
|
|
|
|
2009-06-16 09:03:17 +02:00
|
|
|
$field->setValue('11:00pm');
|
|
|
|
$field->setValue('');
|
|
|
|
$this->assertEquals($field->dataValue(), '');
|
2009-06-16 08:39:57 +02:00
|
|
|
}
|
|
|
|
}
|