mirror of
https://github.com/BushlanovDev/max-bot-api-client-php.git
synced 2026-10-06 20:10:31 +00:00
1bfeb17a15
- Recipient::$postId: the commented post, set for comments - ContactAttachmentPayload::$hash: hash of the VCF info - ChatPatch: document the description field (up to 16000 chars, empty string removes it) - QuoteMarkup and MarkupType::Quote. createMarkupElement() threw "Unknown or unsupported markup type" on a quote block, so a message with a quote could not be parsed at all New constructor parameters are optional and last, so existing positional calls keep working; toArray() of these models now also carries the new keys.
49 lines
1.3 KiB
PHP
49 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace BushlanovDev\MaxMessengerBot\Tests\Models;
|
|
|
|
use BushlanovDev\MaxMessengerBot\Models\Recipient;
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
use PHPUnit\Framework\Attributes\Test;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
#[CoversClass(Recipient::class)]
|
|
final class RecipientTest extends TestCase
|
|
{
|
|
#[Test]
|
|
public function canBeCreatedFromArray(): void
|
|
{
|
|
$data = [
|
|
'chat_type' => 'chat',
|
|
'chat_id' => 123,
|
|
];
|
|
|
|
$receipt = Recipient::fromArray($data);
|
|
|
|
$this->assertInstanceOf(Recipient::class, $receipt);
|
|
$this->assertSame($data['chat_type'], $receipt->chatType->value);
|
|
$this->assertSame($data['chat_id'], $receipt->chatId);
|
|
|
|
$array = $receipt->toArray();
|
|
|
|
$this->assertIsArray($array);
|
|
unset($array['user_id'], $array['post_id']);
|
|
$this->assertSame($data, $array);
|
|
}
|
|
|
|
#[Test]
|
|
public function commentRecipientCarriesThePostId(): void
|
|
{
|
|
$recipient = Recipient::fromArray([
|
|
'chat_type' => 'channel',
|
|
'chat_id' => -100,
|
|
'post_id' => 'mid.post',
|
|
]);
|
|
|
|
$this->assertSame('mid.post', $recipient->postId);
|
|
$this->assertNull(Recipient::fromArray(['chat_type' => 'dialog', 'user_id' => 1])->postId);
|
|
}
|
|
}
|