19 declare(strict_types=1);
34 protected function setUp(): void
39 #[DataProvider('DateTimeTransformationDataProvider')] 42 $transformedValue = $this->transformation->transform($originVal);
43 $this->assertIsObject($transformedValue);
44 $this->assertInstanceOf(DateTimeImmutable::class, $transformedValue);
45 $this->assertEquals($expectedVal, $transformedValue);
48 #[DataProvider('TransformationFailureDataProvider')] 51 $this->expectException(ConstraintViolationException::class);
52 $this->transformation->transform($failingValue);
59 'datetime' => [$now, $now],
60 'iso8601' => [
'2020-07-06T12:23:05+0000',
61 DateTimeImmutable::createFromFormat(DateTimeInterface::ISO8601,
'2020-07-06T12:23:05+0000')],
62 'atom' => [
'2020-07-06T12:23:05+00:00',
63 DateTimeImmutable::createFromFormat(DateTimeInterface::ATOM,
'2020-07-06T12:23:05+00:00')],
64 'rfc3339_ext' => [
'2020-07-06T12:23:05.000+00:00',
65 DateTimeImmutable::createFromFormat(DateTimeInterface::RFC3339_EXTENDED,
'2020-07-06T12:23:05.000+00:00')],
66 'cookie' => [
'Monday, 06-Jul-2020 12:23:05 GMT+0000',
67 DateTimeImmutable::createFromFormat(DateTimeInterface::COOKIE,
'Monday, 06-Jul-2020 12:23:05 GMT+0000')],
68 'rfc822' => [
'Mon, 06 Jul 20 12:23:05 +0000',
69 DateTimeImmutable::createFromFormat(DateTimeInterface::RFC822,
'Mon, 06 Jul 20 12:23:05 +0000')],
70 'rfc7231' => [
'Mon, 06 Jul 2020 12:23:05 GMT',
71 DateTimeImmutable::createFromFormat(DateTimeInterface::RFC7231,
'Mon, 06 Jul 2020 12:23:05 GMT')],
72 'unix_timestamp' => [481556262, DateTimeImmutable::createFromFormat(DateTimeInterface::ISO8601,
'1985-04-05T13:37:42+0000')],
73 'unix_timestamp_float' => [481556262.4, DateTimeImmutable::createFromFormat(DateTimeInterface::ISO8601,
'1985-04-05T13:37:42+0000')]
80 'no_matching_string_format' => [
'hello']