mirror of
https://github.com/BushlanovDev/max-bot-api-client-php.git
synced 2026-10-07 12:29:11 +00:00
Added Chat
This commit is contained in:
@@ -20,6 +20,7 @@ use BushlanovDev\MaxMessengerBot\Models\Attachments\Payloads\PhotoToken;
|
||||
use BushlanovDev\MaxMessengerBot\Models\Attachments\Requests\InlineKeyboardAttachmentRequest;
|
||||
use BushlanovDev\MaxMessengerBot\Models\Attachments\Requests\PhotoAttachmentRequest;
|
||||
use BushlanovDev\MaxMessengerBot\Models\BotInfo;
|
||||
use BushlanovDev\MaxMessengerBot\Models\Chat;
|
||||
use BushlanovDev\MaxMessengerBot\Models\Message;
|
||||
use BushlanovDev\MaxMessengerBot\Models\MessageBody;
|
||||
use BushlanovDev\MaxMessengerBot\Models\Recipient;
|
||||
@@ -52,6 +53,7 @@ use ReflectionClass;
|
||||
#[UsesClass(PhotoAttachmentRequest::class)]
|
||||
#[UsesClass(PhotoAttachmentPayload::class)]
|
||||
#[UsesClass(UploadEndpoint::class)]
|
||||
#[UsesClass(Chat::class)]
|
||||
final class ApiTest extends TestCase
|
||||
{
|
||||
private MockObject&ClientApiInterface $clientMock;
|
||||
@@ -450,4 +452,45 @@ final class ApiTest extends TestCase
|
||||
$this->expectExceptionMessageMatches('/File not found or not readable/');
|
||||
$this->api->uploadAttachment(UploadType::Image, '/path/to/non/existent/file.jpg');
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function getChatCallsClientAndFactoryCorrectly(): void
|
||||
{
|
||||
$chatId = 100123456789;
|
||||
$rawResponseData = [
|
||||
'chat_id' => $chatId,
|
||||
'type' => 'chat',
|
||||
'status' => 'active',
|
||||
'last_event_time' => 1678886400000,
|
||||
'participants_count' => 50,
|
||||
'is_public' => false,
|
||||
'title' => 'Test Chat Title',
|
||||
'icon' => null,
|
||||
'owner_id' => null,
|
||||
'link' => null,
|
||||
'description' => null,
|
||||
'dialog_with_user' => null,
|
||||
'messages_count' => null,
|
||||
'chat_message_id' => null,
|
||||
'pinned_message' => null,
|
||||
];
|
||||
|
||||
$expectedChatObject = Chat::fromArray($rawResponseData);
|
||||
|
||||
$this->clientMock
|
||||
->expects($this->once())
|
||||
->method('request')
|
||||
->with('GET', '/chats/' . $chatId)
|
||||
->willReturn($rawResponseData);
|
||||
|
||||
$this->modelFactoryMock
|
||||
->expects($this->once())
|
||||
->method('createChat')
|
||||
->with($rawResponseData)
|
||||
->willReturn($expectedChatObject);
|
||||
|
||||
$result = $this->api->getChat($chatId);
|
||||
|
||||
$this->assertSame($expectedChatObject, $result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user