FIX DatetimeFieldTest

This commit is contained in:
Damian Mooyman 2018-06-14 18:14:12 +12:00
parent 310a259c5f
commit c414388220
No known key found for this signature in database
GPG Key ID: 78B823A10DE27D1A

View File

@ -109,11 +109,11 @@ class DatetimeFieldTest extends SapphireTest
{ {
$f = new DatetimeField('Datetime', 'Datetime'); $f = new DatetimeField('Datetime', 'Datetime');
$f->setValue('2003-03-29 23:59:38'); $f->setValue('2003-03-29 23:59:38');
$this->assertEquals($f->dataValue(), '2003-03-29 23:59:38', 'Accepts ISO'); $this->assertEquals('2003-03-29 23:59:38', $f->dataValue(), 'Accepts ISO');
$f = new DatetimeField('Datetime', 'Datetime'); $f = new DatetimeField('Datetime', 'Datetime');
$f->setValue('2003-03-29T23:59:38'); $f->setValue('2003-03-29T23:59:38');
$this->assertNull($f->dataValue(), 'Rejects normalised ISO'); $this->assertEquals('2003-03-29 23:59:38', $f->dataValue(), 'Accepts normalised ISO');
} }
public function testSubmittedValue() public function testSubmittedValue()
@ -152,7 +152,7 @@ class DatetimeFieldTest extends SapphireTest
$this->assertTrue($f->validate(new RequiredFields())); $this->assertTrue($f->validate(new RequiredFields()));
$f = new DatetimeField('Datetime', 'Datetime', '2003-03-29T23:59:38'); $f = new DatetimeField('Datetime', 'Datetime', '2003-03-29T23:59:38');
$this->assertFalse($f->validate(new RequiredFields()), 'Normalised ISO'); $this->assertTrue($f->validate(new RequiredFields()), 'Normalised ISO');
$f = new DatetimeField('Datetime', 'Datetime', '2003-03-29'); $f = new DatetimeField('Datetime', 'Datetime', '2003-03-29');
$this->assertFalse($f->validate(new RequiredFields()), 'Leaving out time'); $this->assertFalse($f->validate(new RequiredFields()), 'Leaving out time');