mirror of
https://github.com/BushlanovDev/max-bot-api-client-php.git
synced 2026-08-28 11:06:59 +00:00
Added MessageButton & ChatAdminPermission::EditLink & alias in ChatAdmin & participants in Chat & first_name in BotPatch
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BushlanovDev\MaxMessengerBot\Tests\Models\Attachments\Buttons\Inline;
|
||||
|
||||
use BushlanovDev\MaxMessengerBot\Enums\InlineButtonType;
|
||||
use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline\MessageButton;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
#[CoversClass(MessageButton::class)]
|
||||
final class MessageButtonTest extends TestCase
|
||||
{
|
||||
#[Test]
|
||||
public function toArraySerializesCorrectly(): void
|
||||
{
|
||||
$button = new MessageButton('Test Button');
|
||||
|
||||
$expectedArray = [
|
||||
'type' => InlineButtonType::Message->value,
|
||||
'text' => 'Test Button',
|
||||
];
|
||||
|
||||
$resultArray = $button->toArray();
|
||||
|
||||
$this->assertSame($expectedArray, $resultArray);
|
||||
}
|
||||
}
|
||||
@@ -58,4 +58,11 @@ final class BotPatchTest extends TestCase
|
||||
$patch = new BotPatch();
|
||||
$this->assertEmpty($patch->toArray());
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function toArrayFirstAndLastName(): void
|
||||
{
|
||||
$patch = new BotPatch(first_name: 'New Name', last_name: null);
|
||||
$this->assertEquals(['first_name' => 'New Name', 'last_name' => null], $patch->toArray());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ final class ChatAdminTest extends TestCase
|
||||
$expected = [
|
||||
'user_id' => 123,
|
||||
'permissions' => ['write', 'pin_message'],
|
||||
'alias' => null,
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, $admin->toArray());
|
||||
|
||||
@@ -34,6 +34,7 @@ final class ChatMemberTest extends TestCase
|
||||
'is_admin' => true,
|
||||
'join_time' => 1678000000,
|
||||
'permissions' => ['pin_message', 'write'],
|
||||
'alias' => null,
|
||||
];
|
||||
|
||||
$member = ChatMember::fromArray($data);
|
||||
@@ -66,6 +67,7 @@ final class ChatMemberTest extends TestCase
|
||||
'is_admin' => false,
|
||||
'join_time' => 1678000001,
|
||||
'permissions' => null,
|
||||
'alias' => null,
|
||||
];
|
||||
|
||||
$member = ChatMember::fromArray($data);
|
||||
|
||||
@@ -48,6 +48,10 @@ final class ChatTest extends TestCase
|
||||
],
|
||||
'messages_count' => 100,
|
||||
'chat_message_id' => 'mid.123',
|
||||
'participants' => [
|
||||
'456' => 1678886400000,
|
||||
'789' => 1678886500000,
|
||||
],
|
||||
];
|
||||
|
||||
$chat = Chat::fromArray($data);
|
||||
@@ -99,5 +103,6 @@ final class ChatTest extends TestCase
|
||||
$this->assertNull($chat->dialogWithUser);
|
||||
$this->assertNull($chat->messagesCount);
|
||||
$this->assertNull($chat->chatMessageId);
|
||||
$this->assertNull($chat->participants);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user