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.
41 lines
1.4 KiB
PHP
41 lines
1.4 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace BushlanovDev\MaxMessengerBot\Tests\Models\Attachments;
|
|
|
|
use BushlanovDev\MaxMessengerBot\Models\Attachments\ContactAttachment;
|
|
use BushlanovDev\MaxMessengerBot\Models\Attachments\Payloads\ContactAttachmentPayload;
|
|
use BushlanovDev\MaxMessengerBot\Models\UserWithPhoto;
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
use PHPUnit\Framework\Attributes\Test;
|
|
use PHPUnit\Framework\Attributes\UsesClass;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
#[CoversClass(ContactAttachment::class)]
|
|
#[UsesClass(ContactAttachmentPayload::class)]
|
|
#[UsesClass(UserWithPhoto::class)]
|
|
final class ContactAttachmentTest extends TestCase
|
|
{
|
|
#[Test]
|
|
public function canBeCreatedFromArray(): void
|
|
{
|
|
$data = ['type' => 'contact', 'payload' => ['vcf_info' => 'vcf', 'max_info' => null]];
|
|
$attachment = ContactAttachment::fromArray($data);
|
|
$this->assertInstanceOf(ContactAttachment::class, $attachment);
|
|
$this->assertSame('vcf', $attachment->payload->vcfInfo);
|
|
$this->assertNull($attachment->payload->hash);
|
|
}
|
|
|
|
#[Test]
|
|
public function payloadCarriesTheVcfHash(): void
|
|
{
|
|
$attachment = ContactAttachment::fromArray([
|
|
'type' => 'contact',
|
|
'payload' => ['vcf_info' => 'vcf', 'max_info' => null, 'hash' => 'abc123'],
|
|
]);
|
|
|
|
$this->assertSame('abc123', $attachment->payload->hash);
|
|
}
|
|
}
|