$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.'
);
$this->
assertEquals(0,
$typed_data->
validate()->
count());
$typed_data->
setValue('invalid'
);
$this->
assertEquals(1,
$typed_data->
validate()->
count(), 'Validation detected invalid value.'
);
// Check implementation of DateTimeInterface.
$typed_data =
$this->
createTypedData(['type' => 'datetime_iso8601'
], '2014-01-01T20:00:00+00:00'
);
$this->
assertInstanceOf(DrupalDateTime::
class,
$typed_data->
getDateTime());
$this->
assertSame('+00:00',
$typed_data->
getDateTime()->
getTimezone()->
getName());
$typed_data->
setDateTime(new DrupalDateTime('2014-01-02T20:00:00+00:00'
));
$this->
assertSame('+00:00',
$typed_data->
getDateTime()->
getTimezone()->
getName());
$this->
assertEquals('2014-01-02T20:00:00+00:00',
$typed_data->
getValue());
$typed_data->
setValue(NULL
);
$this->
assertNull($typed_data->
getDateTime());
// Date Time type; values without timezone offset.
$value = '2014-01-01T20:00';
$typed_data =
$this->
createTypedData(['type' => 'datetime_iso8601'
],
$value);
$this->
assertInstanceOf(DateTimeInterface::
class,
$typed_data);
$this->
assertSame($value,
$typed_data->
getValue(), 'Date value was fetched.'
);
// @todo Uncomment this assertion in https://www.drupal.org/project/drupal/issues/2716891.