From 85231b09628647da766e48db36668da2ee0fc033 Mon Sep 17 00:00:00 2001 From: Alex Date: Sat, 21 Mar 2026 09:44:40 +0300 Subject: [PATCH] Removed deprecated DataAttachment --- src/Enums/AttachmentType.php | 1 - src/ModelFactory.php | 2 - src/Models/Attachments/DataAttachment.php | 21 -------- tests/ModelFactoryTest.php | 24 ++------- .../Models/Attachments/DataAttachmentTest.php | 49 ------------------- 5 files changed, 5 insertions(+), 92 deletions(-) delete mode 100644 src/Models/Attachments/DataAttachment.php delete mode 100644 tests/Models/Attachments/DataAttachmentTest.php diff --git a/src/Enums/AttachmentType.php b/src/Enums/AttachmentType.php index af81056..ccc0484 100644 --- a/src/Enums/AttachmentType.php +++ b/src/Enums/AttachmentType.php @@ -15,5 +15,4 @@ enum AttachmentType: string case InlineKeyboard = 'inline_keyboard'; case Location = 'location'; case Share = 'share'; - case Data = 'data'; } diff --git a/src/ModelFactory.php b/src/ModelFactory.php index ce8a46a..9e8aa67 100644 --- a/src/ModelFactory.php +++ b/src/ModelFactory.php @@ -24,7 +24,6 @@ use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Reply\SendContactBut use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Reply\SendGeoLocationButton; use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Reply\SendMessageButton; use BushlanovDev\MaxMessengerBot\Models\Attachments\ContactAttachment; -use BushlanovDev\MaxMessengerBot\Models\Attachments\DataAttachment; use BushlanovDev\MaxMessengerBot\Models\Attachments\FileAttachment; use BushlanovDev\MaxMessengerBot\Models\Attachments\InlineKeyboardAttachment; use BushlanovDev\MaxMessengerBot\Models\Attachments\LocationAttachment; @@ -259,7 +258,6 @@ readonly class ModelFactory AttachmentType::InlineKeyboard => InlineKeyboardAttachment::fromArray($data), AttachmentType::Location => LocationAttachment::fromArray($data), AttachmentType::Share => ShareAttachment::fromArray($data), - AttachmentType::Data => DataAttachment::fromArray($data), default => throw new LogicException('Unknown or unsupported attachment type: ' . ($data['type'] ?? 'none')), }; } diff --git a/src/Models/Attachments/DataAttachment.php b/src/Models/Attachments/DataAttachment.php deleted file mode 100644 index ae24be5..0000000 --- a/src/Models/Attachments/DataAttachment.php +++ /dev/null @@ -1,21 +0,0 @@ - 102, 'text' => 'Message with data attachment', 'attachments' => [ - ['type' => 'data', 'data' => 'payload_from_reply_button'], [ 'type' => 'share', 'payload' => ['url' => 'http://a.com'], @@ -613,16 +610,13 @@ final class ModelFactoryTest extends TestCase $this->assertInstanceOf(Message::class, $message); $this->assertInstanceOf(MessageBody::class, $message->body); $this->assertIsArray($attachments); - $this->assertCount(3, $attachments); + $this->assertCount(2, $attachments); - $this->assertInstanceOf(DataAttachment::class, $attachments[0]); - $this->assertSame('payload_from_reply_button', $attachments[0]->data); + $this->assertInstanceOf(ShareAttachment::class, $message->body->attachments[0]); + $this->assertSame('Test Share', $attachments[0]->title); - $this->assertInstanceOf(ShareAttachment::class, $message->body->attachments[1]); - $this->assertSame('Test Share', $attachments[1]->title); - - $this->assertInstanceOf(PhotoAttachment::class, $attachments[2]); - $this->assertSame(1, $attachments[2]->payload->photoId); + $this->assertInstanceOf(PhotoAttachment::class, $attachments[1]); + $this->assertSame(1, $attachments[1]->payload->photoId); } #[Test] @@ -747,14 +741,6 @@ final class ModelFactoryTest extends TestCase public static function attachmentTypeProvider(): array { return [ - 'Data Attachment' => [ - ['type' => 'data', 'data' => 'test_payload'], - DataAttachment::class, - function (TestCase $test, DataAttachment $attachment) { - $test->assertSame('test_payload', $attachment->data); - } - ], - 'Location Attachment' => [ ['type' => 'location', 'latitude' => 55.751244, 'longitude' => 37.618423], LocationAttachment::class, diff --git a/tests/Models/Attachments/DataAttachmentTest.php b/tests/Models/Attachments/DataAttachmentTest.php deleted file mode 100644 index f3905de..0000000 --- a/tests/Models/Attachments/DataAttachmentTest.php +++ /dev/null @@ -1,49 +0,0 @@ -assertSame(AttachmentType::Data, $attachment->type); - $this->assertSame('some_payload_from_button', $attachment->data); - - $expectedArray = [ - 'type' => 'data', - 'data' => 'some_payload_from_button', - ]; - - $this->assertEquals($expectedArray, $attachment->toArray()); - } - - #[Test] - public function canBeCreatedFromArray(): void - { - $data = [ - 'type' => 'data', - 'data' => 'payload123', - ]; - - $attachment = DataAttachment::fromArray($data); - - $this->assertInstanceOf(DataAttachment::class, $attachment); - $this->assertSame(AttachmentType::Data, $attachment->type); - $this->assertSame('payload123', $attachment->data); - } -}