mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
unit test cleanup
This commit is contained in:
parent
1ec2abe75f
commit
a73abbfcb8
@ -1679,6 +1679,7 @@ The `DatetimeField` has changed behaviour:
|
||||
by default in `Value()`, which include a "T" separator between date and time.
|
||||
This is required to allow HTML5 input. Either use `setHTML5(false)` to set your custom format,
|
||||
or use `dataValue()` to retrieve a whitespace separated representation.
|
||||
* It no longer accepts `setValue()` as an array with 'date' and 'time' keys
|
||||
* Added `getHTML5()` / `setHTML5()`
|
||||
|
||||
New `DateField` methods replace `getConfig()` / `setConfig()`:
|
||||
|
@ -80,12 +80,11 @@ class DatetimeFieldTest extends SapphireTest
|
||||
$this->assertEquals($f->dataValue(), null);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @expectedException InvalidArgumentException
|
||||
// */
|
||||
// public function testConstructorWithLocalizedDateString() {
|
||||
// $f = new DatetimeField('Datetime', 'Datetime', '29/03/2003 23:59:38');
|
||||
// }
|
||||
public function testConstructorWithLocalizedDateSetsNullValue()
|
||||
{
|
||||
$f = new DatetimeField('Datetime', 'Datetime', '29/03/2003 23:59:38');
|
||||
$this->assertNull($f->Value());
|
||||
}
|
||||
|
||||
public function testConstructorWithIsoDate()
|
||||
{
|
||||
@ -94,14 +93,6 @@ class DatetimeFieldTest extends SapphireTest
|
||||
$this->assertEquals($f->dataValue(), '2003-03-29 23:59:38');
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @expectedException InvalidArgumentException
|
||||
// */
|
||||
// public function testSetValueWithDateString() {
|
||||
// $f = new DatetimeField('Datetime', 'Datetime');
|
||||
// $f->setValue('29/03/2003');
|
||||
// }
|
||||
|
||||
public function testSetValueWithDateTimeString()
|
||||
{
|
||||
$f = new DatetimeField('Datetime', 'Datetime');
|
||||
@ -132,9 +123,15 @@ class DatetimeFieldTest extends SapphireTest
|
||||
->setHTML5(false)
|
||||
->setLocale('en_NZ');
|
||||
|
||||
// Values can only be localized (= non-ISO) in array notation
|
||||
$datetimeField->setSubmittedValue('29/03/2003 11:00:00 pm');
|
||||
$this->assertEquals($datetimeField->dataValue(), '2003-03-29 23:00:00');
|
||||
|
||||
// Some localisation packages exclude the ',' in default medium format
|
||||
$this->assertRegExp(
|
||||
'#29/03/2003(,)? 11:00:00 (AM|am)#',
|
||||
$datetimeField->Value(),
|
||||
'User value is formatted, and in user timezone'
|
||||
);
|
||||
}
|
||||
|
||||
public function testValidate()
|
||||
@ -246,12 +243,12 @@ class DatetimeFieldTest extends SapphireTest
|
||||
|
||||
$datetimeField
|
||||
->setHTML5(false)
|
||||
->setLocale('en_NZ');
|
||||
->setDatetimeFormat('dd/MM/y HH:mm:ss');
|
||||
|
||||
$datetimeField->setTimezone('Pacific/Auckland');
|
||||
$datetimeField->setValue('2003-12-24 23:59:59');
|
||||
$this->assertEquals(
|
||||
'25/12/2003, 11:59:59 AM',
|
||||
'25/12/2003 11:59:59',
|
||||
$datetimeField->Value(),
|
||||
'User value is formatted, and in user timezone'
|
||||
);
|
||||
|
@ -29,7 +29,7 @@ class DBDatetimeTest extends SapphireTest
|
||||
public function testNowWithMockDate()
|
||||
{
|
||||
// Test setting
|
||||
$mockDate = '2001-12-31T22:10:59';
|
||||
$mockDate = '2001-12-31 22:10:59';
|
||||
DBDatetime::set_mock_now($mockDate);
|
||||
$systemDatetime = DBDatetime::create_field('Datetime', date('Y-m-d H:i:s'));
|
||||
$nowDatetime = DBDatetime::now();
|
||||
@ -55,10 +55,10 @@ class DBDatetimeTest extends SapphireTest
|
||||
$this->assertNull($date->getValue(), 'Boolean FALSE evaluates to NULL');
|
||||
|
||||
$date = DBDatetime::create_field('Datetime', '0');
|
||||
$this->assertEquals('1970-01-01T00:00:00', $date->getValue(), 'String zero is UNIX epoch time');
|
||||
$this->assertEquals('1970-01-01 00:00:00', $date->getValue(), 'String zero is UNIX epoch time');
|
||||
|
||||
$date = DBDatetime::create_field('Datetime', 0);
|
||||
$this->assertEquals('1970-01-01T00:00:00', $date->getValue(), 'Numeric zero is UNIX epoch time');
|
||||
$this->assertEquals('1970-01-01 00:00:00', $date->getValue(), 'Numeric zero is UNIX epoch time');
|
||||
}
|
||||
|
||||
public function testExtendedDateTimes()
|
||||
@ -98,7 +98,7 @@ class DBDatetimeTest extends SapphireTest
|
||||
public function testURLDateTime()
|
||||
{
|
||||
$date = DBDatetime::create_field('Datetime', '2001-12-31 22:10:59');
|
||||
$this->assertEquals('2001-12-31T22%3A10%3A59', $date->URLDateTime());
|
||||
$this->assertEquals('2001-12-31%2022%3A10%3A59', $date->URLDateTime());
|
||||
}
|
||||
|
||||
public function testAgoInPast()
|
||||
|
Loading…
Reference in New Issue
Block a user