$typed_data->
setValue(NULL
);
$this->
assertNull($typed_data->
getValue(), 'Float wrapper is null-able.'
);
$this->
assertEquals(0,
$typed_data->
validate()->
count());
$typed_data->
setValue('invalid'
);
$this->
assertEquals(1,
$typed_data->
validate()->
count(), 'Validation detected invalid value.'
);
// Date Time type; values with timezone offset.
$value = '2014-01-01T20:00:00+00:00';
$typed_data =
$this->
createTypedData(['type' => 'datetime_iso8601'
],
$value);
$this->
assertInstanceOf(DateTimeInterface::
class,
$typed_data);
$this->
assertSame($value,
$typed_data->
getValue());
$this->
assertEquals($typed_data->
getDateTime()->
format('c'
),
$typed_data->
getValue(), 'Value representation of a date is ISO 8601'
);
$this->
assertSame('+00:00',
$typed_data->
getDateTime()->
getTimezone()->
getName());
$this->
assertEquals(0,
$typed_data->
validate()->
count());
$new_value = '2014-01-02T20:00:00+00:00';
$typed_data->
setValue($new_value);
$this->
assertSame($new_value,
$typed_data->
getDateTime()->
format('c'
), 'Date value was changed and set by an ISO8601 date.'
);
$this->
assertEquals(0,
$typed_data->
validate()->
count());
$this->
assertSame('2014-01-02',
$typed_data->
getDateTime()->
format('Y-m-d'
), 'Date value was changed and set by date string.'
);
$this->
assertSame('+00:00',
$typed_data->
getDateTime()->
getTimezone()->
getName());
$this->
assertEquals(0,
$typed_data->
validate()->
count());
$typed_data->
setValue(NULL
);
$this->
assertNull($typed_data->
getDateTime(), 'Date wrapper is null-able.'
);