diff --git a/src/Common/Order.php b/src/Common/Order.php index bf32eb7..969091d 100644 --- a/src/Common/Order.php +++ b/src/Common/Order.php @@ -353,7 +353,7 @@ public static function withNumberAndDate(string $Number, \DateTimeInterface $Dat /** * @JMS\XmlAttribute - * @JMS\Type("DateTimeImmutable<'Y-m-d\TH:i:sP', '', 'Y-m-d\TH:i:sP', 'Y-m-d H:i:s'>") + * @JMS\Type("DateTimeImmutable<'Y-m-d\TH:i:sP', '', 'Y-m-d\TH:i:sP', ['Y-m-d H:i:s', 'Y-m-d H:i:sP']>") * * @var \DateTimeImmutable|null */ diff --git a/tests/Deserialization/InfoReportResponseTest.php b/tests/Deserialization/InfoReportResponseTest.php index cd26918..d59238c 100644 --- a/tests/Deserialization/InfoReportResponseTest.php +++ b/tests/Deserialization/InfoReportResponseTest.php @@ -164,4 +164,27 @@ public function test_it_serializes_to_empty_json() $response = new InfoReportResponse(); $this->assertSame([], $response->jsonSerialize()); } + + public function test_date_last_change_with_mixed_datetime_format() + { + $response = $this->getSerializer()->deserialize(FixtureLoader::load('InfoReportDateLastChangeYmdHisPMixed.xml'), InfoReportResponse::class, 'xml'); + + /** @var $response InfoReportResponse */ + $this->assertInstanceOf(InfoReportResponse::class, $response); + + $this->assertCount(3, $response->getOrders()); + $this->assertCount(3, $response); + + $order = $response->getOrders()[0]; + $this->assertSame('ORD-121121', $order->getNumber()); + $this->assertSame('2020-03-05 04:30:00', $order->getDateLastChange()->format('Y-m-d H:i:s')); + + $order = $response->getOrders()[1]; + $this->assertSame('ORD-121122', $order->getNumber()); + $this->assertSame('2020-03-06 05:30:00', $order->getDateLastChange()->format('Y-m-d H:i:s')); + + $order = $response->getOrders()[2]; + $this->assertSame('ORD-121123', $order->getNumber()); + $this->assertSame('2020-03-07 06:30:00+05:00', $order->getDateLastChange()->format('Y-m-d H:i:sP')); + } } diff --git a/tests/Fixtures/data/InfoReportDateLastChangeYmdHisPMixed.xml b/tests/Fixtures/data/InfoReportDateLastChangeYmdHisPMixed.xml new file mode 100644 index 0000000..f19a6df --- /dev/null +++ b/tests/Fixtures/data/InfoReportDateLastChangeYmdHisPMixed.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +