Files
max-bot-api-client-php/tests/Models/Attachments/ContactAttachmentTest.php
T
Timofey 1bfeb17a15 Add fields and markup added in schema 0.0.33
- 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.
2026-10-01 01:10:45 +05:00

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);
}
}