$this->
assertEquals(40,
$typed_data->
getDuration()->d, 'DurationIso8601 value was changed and set by duration string.'
);
$this->
assertIsString($typed_data->
getString());
$this->
assertEquals(0,
$typed_data->
validate()->
count());
$typed_data->
setValue(NULL
);
$this->
assertNull($typed_data->
getValue(), 'DurationIso8601 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 DurationInterface.
$typed_data =
$this->
createTypedData(['type' => 'duration_iso8601'
], 'PT20S'
);
$this->
assertInstanceOf(\DateInterval::
class,
$typed_data->
getDuration());
$typed_data->
setDuration(new \
DateInterval('P40D'
));
// @todo: Should we make this "nicer"?
$this->
assertEquals('P0Y0M40DT0H0M0S',
$typed_data->
getValue());
$typed_data->
setValue(NULL
);
$this->
assertNull($typed_data->
getDuration());
// Time span type.
$value = 20;
$typed_data =
$this->
createTypedData(['type' => 'timespan'
],
$value);
$this->
assertInstanceOf(DurationInterface::
class,
$typed_data);
$this->
assertSame($value,
$typed_data->
getValue(), 'Time span value was fetched.'
);
$this->
assertEquals(0,
$typed_data->
validate()->
count());