From aac414ecd525ada242f0dd2991173a0d5b184dd0 Mon Sep 17 00:00:00 2001 From: Neur0toxine Date: Fri, 20 Jan 2023 13:06:36 +0300 Subject: [PATCH] parse dates without nanoseconds --- src/Bot/Model/Entity/Bot.php | 4 +- src/Bot/Model/Entity/Channel/Channel.php | 8 +-- src/Bot/Model/Entity/Chat/Chat.php | 4 +- src/Bot/Model/Entity/Chat/ChatMember.php | 4 +- src/Bot/Model/Entity/Command.php | 4 +- src/Bot/Model/Entity/Customer.php | 4 +- src/Bot/Model/Entity/Dialog.php | 6 +- src/Bot/Model/Entity/Message/Message.php | 6 +- src/Bot/Model/Entity/User.php | 6 +- tests/Bot/Tests/ClientListTest.php | 16 +++--- tests/Resources/bots.json | 18 +++++- tests/Resources/channels.json | 46 ++++++++++++++- tests/Resources/chats.json | 72 ++++++++++++++++++++++++ tests/Resources/customers.json | 18 +++++- tests/Resources/dialogs.json | 18 +++++- tests/Resources/members.json | 11 +++- tests/Resources/messages.json | 25 +++++++- tests/Resources/users.json | 12 +++- 18 files changed, 244 insertions(+), 38 deletions(-) diff --git a/src/Bot/Model/Entity/Bot.php b/src/Bot/Model/Entity/Bot.php index 38f9189..659245e 100644 --- a/src/Bot/Model/Entity/Bot.php +++ b/src/Bot/Model/Entity/Bot.php @@ -33,7 +33,7 @@ class Bot implements ModelInterface /** * @var \DateTime $createdAt * - * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>") * @Accessor(getter="getCreatedAt",setter="setCreatedAt") * @SkipWhenEmpty() */ @@ -42,7 +42,7 @@ class Bot implements ModelInterface /** * @var \DateTime $updatedAt * - * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>") * @Accessor(getter="getUpdatedAt",setter="setUpdatedAt") * @SkipWhenEmpty() */ diff --git a/src/Bot/Model/Entity/Channel/Channel.php b/src/Bot/Model/Entity/Channel/Channel.php index 31a6efb..82c6f63 100644 --- a/src/Bot/Model/Entity/Channel/Channel.php +++ b/src/Bot/Model/Entity/Channel/Channel.php @@ -33,7 +33,7 @@ class Channel implements ModelInterface /** * @var \DateTime $createdAt * - * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>") * @Accessor(getter="getCreatedAt",setter="setCreatedAt") */ private $createdAt; @@ -41,7 +41,7 @@ class Channel implements ModelInterface /** * @var \DateTime $updatedAt * - * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>") * @Accessor(getter="getUpdatedAt",setter="setUpdatedAt") */ private $updatedAt; @@ -49,7 +49,7 @@ class Channel implements ModelInterface /** * @var \DateTime $activatedAt * - * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>") * @Accessor(getter="getActivatedAt",setter="setActivatedAt") */ private $activatedAt; @@ -57,7 +57,7 @@ class Channel implements ModelInterface /** * @var \DateTime $deactivatedAt * - * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>") * @Accessor(getter="getDeactivatedAt",setter="setDeactivatedAt") */ private $deactivatedAt; diff --git a/src/Bot/Model/Entity/Chat/Chat.php b/src/Bot/Model/Entity/Chat/Chat.php index 8282729..f396fad 100644 --- a/src/Bot/Model/Entity/Chat/Chat.php +++ b/src/Bot/Model/Entity/Chat/Chat.php @@ -35,7 +35,7 @@ class Chat implements ModelInterface /** * @var \DateTime $createdAt * - * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>") * @Accessor(getter="getCreatedAt",setter="setCreatedAt") */ private $createdAt; @@ -43,7 +43,7 @@ class Chat implements ModelInterface /** * @var \DateTime $updatedAt * - * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>") * @Accessor(getter="getUpdatedAt",setter="setUpdatedAt") */ private $updatedAt; diff --git a/src/Bot/Model/Entity/Chat/ChatMember.php b/src/Bot/Model/Entity/Chat/ChatMember.php index b483c69..eb14ab7 100644 --- a/src/Bot/Model/Entity/Chat/ChatMember.php +++ b/src/Bot/Model/Entity/Chat/ChatMember.php @@ -33,7 +33,7 @@ class ChatMember implements ModelInterface /** * @var \DateTime $createdAt * - * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>") * @Accessor(getter="getCreatedAt",setter="setCreatedAt") */ private $createdAt; @@ -41,7 +41,7 @@ class ChatMember implements ModelInterface /** * @var \DateTime $updatedAt * - * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>") * @Accessor(getter="getUpdatedAt",setter="setUpdatedAt") * @SkipWhenEmpty() */ diff --git a/src/Bot/Model/Entity/Command.php b/src/Bot/Model/Entity/Command.php index ab7d48b..a03b8cc 100644 --- a/src/Bot/Model/Entity/Command.php +++ b/src/Bot/Model/Entity/Command.php @@ -33,7 +33,7 @@ class Command implements ModelInterface /** * @var \DateTime $createdAt * - * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>") * @Accessor(getter="getCreatedAt",setter="setCreatedAt") */ private $createdAt; @@ -41,7 +41,7 @@ class Command implements ModelInterface /** * @var \DateTime $updatedAt * - * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>") * @Accessor(getter="getUpdatedAt",setter="setUpdatedAt") * @SkipWhenEmpty() */ diff --git a/src/Bot/Model/Entity/Customer.php b/src/Bot/Model/Entity/Customer.php index 4c6b356..cc5162d 100644 --- a/src/Bot/Model/Entity/Customer.php +++ b/src/Bot/Model/Entity/Customer.php @@ -34,7 +34,7 @@ class Customer implements ModelInterface /** * @var \DateTime $createdAt * - * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>") * @Accessor(getter="getCreatedAt",setter="setCreatedAt") */ private $createdAt; @@ -42,7 +42,7 @@ class Customer implements ModelInterface /** * @var \DateTime $updatedAt * - * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>") * @Accessor(getter="getUpdatedAt",setter="setUpdatedAt") * @SkipWhenEmpty() */ diff --git a/src/Bot/Model/Entity/Dialog.php b/src/Bot/Model/Entity/Dialog.php index db539b3..d17e678 100644 --- a/src/Bot/Model/Entity/Dialog.php +++ b/src/Bot/Model/Entity/Dialog.php @@ -33,7 +33,7 @@ class Dialog implements ModelInterface /** * @var \DateTime $createdAt * - * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>") * @Accessor(getter="getCreatedAt",setter="setCreatedAt") */ private $createdAt; @@ -41,7 +41,7 @@ class Dialog implements ModelInterface /** * @var \DateTime $updatedAt * - * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>") * @Accessor(getter="getUpdatedAt",setter="setUpdatedAt") * @SkipWhenEmpty() */ @@ -86,7 +86,7 @@ class Dialog implements ModelInterface /** * @var \DateTime $closedAt * - * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>") * @Accessor(getter="getClosedAt",setter="setClosedAt") * @SkipWhenEmpty() */ diff --git a/src/Bot/Model/Entity/Message/Message.php b/src/Bot/Model/Entity/Message/Message.php index f67c2c0..7c8c961 100644 --- a/src/Bot/Model/Entity/Message/Message.php +++ b/src/Bot/Model/Entity/Message/Message.php @@ -35,7 +35,7 @@ class Message implements ModelInterface /** * @var \DateTime $createdAt * - * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>") * @Accessor(getter="getCreatedAt",setter="setCreatedAt") */ private $createdAt; @@ -43,7 +43,7 @@ class Message implements ModelInterface /** * @var \DateTime $updatedAt * - * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>") * @Accessor(getter="getUpdatedAt",setter="setUpdatedAt") * @SkipWhenEmpty() */ @@ -178,7 +178,7 @@ class Message implements ModelInterface /** * @var \DateTime $channelSentAt * - * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>") * @Accessor(getter="getChannelSentAt",setter="setChannelSentAt") * @SkipWhenEmpty() */ diff --git a/src/Bot/Model/Entity/User.php b/src/Bot/Model/Entity/User.php index 1f959a2..eac6bae 100644 --- a/src/Bot/Model/Entity/User.php +++ b/src/Bot/Model/Entity/User.php @@ -34,7 +34,7 @@ class User implements ModelInterface /** * @var \DateTime $createdAt * - * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>") * @Accessor(getter="getCreatedAt",setter="setCreatedAt") */ private $createdAt; @@ -42,7 +42,7 @@ class User implements ModelInterface /** * @var \DateTime $updatedAt * - * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>") * @Accessor(getter="getUpdatedAt",setter="setUpdatedAt") * @SkipWhenEmpty() */ @@ -136,7 +136,7 @@ class User implements ModelInterface /** * @var \DateTime $revokedAt * - * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z'>") + * @Type("DateTime<'Y-m-d\TH:i:s\.u\Z', null, ['Y-m-d\TH:i:s\.u\Z', 'Y-m-d\TH:i:s\Z']>") * @Accessor(getter="getRevokedAt",setter="setRevokedAt") * @SkipWhenEmpty() */ diff --git a/tests/Bot/Tests/ClientListTest.php b/tests/Bot/Tests/ClientListTest.php index 7fc0b62..432683c 100644 --- a/tests/Bot/Tests/ClientListTest.php +++ b/tests/Bot/Tests/ClientListTest.php @@ -49,7 +49,7 @@ class ClientListTest extends TestCase $response = $client->channels($request); - static::assertCount(4, $response, "Incorrect channels count"); + static::assertCount(5, $response, "Incorrect channels count"); static::assertInstanceOf(Channel\Channel::class, $response[0], "Incorrect channel instance"); } @@ -71,7 +71,7 @@ class ClientListTest extends TestCase $response = $client->chats($request); - static::assertCount(2, $response, "Incorrect chats count"); + static::assertCount(3, $response, "Incorrect chats count"); static::assertInstanceOf(Chat::class, $response[0], "Incorrect chat instance"); } @@ -112,7 +112,7 @@ class ClientListTest extends TestCase $request = new Request\MembersRequest(); $response = $client->members($request); - static::assertCount(4, $response, "Incorrect members count"); + static::assertCount(5, $response, "Incorrect members count"); static::assertInstanceOf(ChatMember::class, $response[0], "Incorrect member instance"); } @@ -135,7 +135,7 @@ class ClientListTest extends TestCase $response = $client->messages($request); - static::assertCount(2, $response, "Incorrect message count"); + static::assertCount(3, $response, "Incorrect message count"); static::assertInstanceOf(Message::class, $response[0], "Incorrect message instance"); } @@ -177,7 +177,7 @@ class ClientListTest extends TestCase $data = $client->bots($request); - static::assertCount(3, $data); + static::assertCount(4, $data); } /** @@ -199,7 +199,7 @@ class ClientListTest extends TestCase $response = $client->users($request); - self::assertCount(2, $response); + self::assertCount(3, $response); self::assertInstanceOf(User::class, $response[0]); } @@ -222,7 +222,7 @@ class ClientListTest extends TestCase $response = $client->dialogs($request); - self::assertCount(2, $response); + self::assertCount(3, $response); self::assertInstanceOf(Dialog::class, $response[0]); } @@ -243,7 +243,7 @@ class ClientListTest extends TestCase $response = $client->customers($request); - self::assertCount(2, $response); + self::assertCount(3, $response); self::assertInstanceOf(Customer::class, $response[0]); } } diff --git a/tests/Resources/bots.json b/tests/Resources/bots.json index 728f667..54505a2 100644 --- a/tests/Resources/bots.json +++ b/tests/Resources/bots.json @@ -42,5 +42,21 @@ "is_active": true, "is_self": false, "is_system": false + }, + { + "id": 5, + "name": "Weird date formats bot", + "events": null, + "client_id": "identifier_4", + "avatar_url": "https://s3.retailcrm.pro/eu-central-1/retailcrm-billing/images/5b97bfd983d2b-bot-logo-2.svg", + "roles": [ + "responsible" + ], + "created_at": "2018-09-06T13:40:02Z", + "updated_at": "2018-09-12T06:15:32Z", + "deactivated_at": "2019-09-12T06:15:32Z", + "is_active": true, + "is_self": false, + "is_system": false } -] \ No newline at end of file +] diff --git a/tests/Resources/channels.json b/tests/Resources/channels.json index fb685d8..1e2f339 100644 --- a/tests/Resources/channels.json +++ b/tests/Resources/channels.json @@ -174,5 +174,49 @@ "activated_at": "2019-06-11T12:33:08.676043Z", "deactivated_at": "2019-06-11T12:38:19.615335Z", "is_active": true + }, + { + "id": 68, + "type": "telegram", + "name": "@oldtestbot", + "settings": { + "status": { + "delivered": "send" + }, + "text": { + "creating": "both", + "editing": "both", + "quoting": "both", + "deleting": "receive", + "max_chars_count": 4096 + }, + "product": { + "creating": "receive", + "editing": "receive" + }, + "order": { + "creating": "receive", + "editing": "receive" + }, + "image": { + "creating": "both", + "editing": "both", + "quoting": "both", + "deleting": "receive", + "max_items_count": 10 + }, + "file": { + "creating": "both", + "editing": "both", + "quoting": "both", + "deleting": "receive", + "max_items_count": 1 + } + }, + "created_at": "2019-06-11T12:33:08Z", + "updated_at": "2019-06-11T12:38:19Z", + "activated_at": "2019-06-11T12:33:08Z", + "deactivated_at": "2019-06-11T12:38:19Z", + "is_active": false } -] \ No newline at end of file +] diff --git a/tests/Resources/chats.json b/tests/Resources/chats.json index 44c0d74..790927d 100644 --- a/tests/Resources/chats.json +++ b/tests/Resources/chats.json @@ -131,5 +131,77 @@ "last_activity": "2019-06-13T11:07:14+03:00", "created_at": "2019-06-11T07:34:16.082957Z", "updated_at": "2019-06-16T08:10:28.657972Z" + }, + { + "id": 28, + "avatar": "", + "name": "", + "channel": { + "id": 61, + "avatar": "", + "transport_id": 1, + "type": "fbmessenger", + "settings": { + "status": { + "delivered": "send", + "read": "send" + }, + "text": { + "creating": "both", + "quoting": "receive", + "max_chars_count": 2000 + }, + "product": { + "creating": "receive" + }, + "order": { + "creating": "receive" + }, + "image": { + "creating": "both", + "max_items_count": 10 + }, + "file": { + "creating": "both", + "max_items_count": 10 + } + }, + "name": "testbot", + "is_active": false + }, + "members": null, + "customer": { + "id": 38, + "type": "customer", + "avatar": "", + "name": "Пётр Петрович", + "username": "Пётр", + "first_name": "Пётр", + "last_name": "Петрович" + }, + "author_id": 0, + "last_message": { + "id": 1, + "time": "2022-12-21T17:15:54+01:00", + "type": "command", + "scope": "private", + "chat_id": 1053, + "is_read": false, + "is_edit": false, + "status": "received", + "from": { + "id": 2, + "external_id": "12", + "type": "user", + "avatar": null, + "name": "Cuenta Soporte", + "first_name": "Cuenta", + "last_name": "Soporte", + "is_technical_account": true + } + }, + "last_activity": "2019-06-13T11:07:14+03:00", + "created_at": "2019-06-11T07:34:16Z", + "updated_at": "2019-06-16T08:10:28Z" } ] diff --git a/tests/Resources/customers.json b/tests/Resources/customers.json index 280b478..8a98480 100644 --- a/tests/Resources/customers.json +++ b/tests/Resources/customers.json @@ -30,5 +30,21 @@ "language": "ru", "phone": "", "email": "" + }, + { + "id": 37, + "external_id": "2272664739519803", + "channel_id": 3, + "username": "user2", + "first_name": "User2", + "last_name": "Lastname2", + "created_at": "2019-06-11T07:34:16Z", + "updated_at": "2019-06-13T08:07:14Z", + "avatar_url": "", + "profile_url": "", + "country": "", + "language": "ru", + "phone": "", + "email": "" } -] \ No newline at end of file +] diff --git a/tests/Resources/dialogs.json b/tests/Resources/dialogs.json index b7e750b..afe5ddd 100644 --- a/tests/Resources/dialogs.json +++ b/tests/Resources/dialogs.json @@ -30,5 +30,21 @@ "assigned_at": "2019-06-11T08:40:14.136916Z" }, "is_active": true + }, + { + "id": 58, + "chat_id": 28, + "begin_message_id": 1, + "ending_message_id": 30, + "created_at": "2019-06-11T07:34:16Z", + "updated_at": "2019-06-16T08:10:28Z", + "closed_at": "2019-06-16T08:10:28Z", + "is_assigned": true, + "responsible": { + "type": "user", + "id": 12, + "assigned_at": "2019-06-11T08:40:14Z" + }, + "is_active": true } -] \ No newline at end of file +] diff --git a/tests/Resources/members.json b/tests/Resources/members.json index e3f8672..a6938ae 100644 --- a/tests/Resources/members.json +++ b/tests/Resources/members.json @@ -34,5 +34,14 @@ "state": "kicked", "chat_id": 29, "user_id": 4 + }, + { + "id": 46, + "created_at": "2019-06-11T07:34:16Z", + "updated_at": "2019-06-11T08:40:14Z", + "is_author": false, + "state": "kicked", + "chat_id": 29, + "user_id": 4 } -] \ No newline at end of file +] diff --git a/tests/Resources/messages.json b/tests/Resources/messages.json index dcd9b55..fd0266c 100644 --- a/tests/Resources/messages.json +++ b/tests/Resources/messages.json @@ -44,5 +44,28 @@ "channel_id": 61, "created_at": "2019-05-20T12:24:52.478633Z", "updated_at": "2019-05-20T12:24:52.585284Z" + }, + { + "id": 3372, + "time": "2019-05-20T15:24:52+03:00", + "type": "text", + "scope": "public", + "chat_id": 26, + "is_read": false, + "is_edit": false, + "status": "seen", + "from": { + "id": 35, + "type": "customer", + "avatar": "", + "name": "Иванов Иван", + "username": "username", + "first_name": "Иванов Иван" + }, + "content": "❤️", + "quote": null, + "channel_id": 61, + "created_at": "2019-05-20T12:24:52Z", + "updated_at": "2019-05-20T12:24:52Z" } -] \ No newline at end of file +] diff --git a/tests/Resources/users.json b/tests/Resources/users.json index 4a47fa8..e0b1274 100644 --- a/tests/Resources/users.json +++ b/tests/Resources/users.json @@ -19,5 +19,15 @@ "updated_at": "2019-06-07T11:36:52.342065Z", "is_online": false, "is_active": true + }, + { + "id": 3, + "external_id": "33", + "username": "User 3", + "first_name": "User", + "created_at": "2018-09-06T13:19:25Z", + "updated_at": "2019-06-07T11:36:52Z", + "is_online": false, + "is_active": true } -] \ No newline at end of file +]