mirror of
https://github.com/BushlanovDev/max-bot-api-client-php.git
synced 2026-08-19 00:53:02 +00:00
New button type clipboard
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
<?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\ClipboardButton;
|
||||
use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline\OpenAppButton;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
#[CoversClass(ClipboardButton::class)]
|
||||
final class ClipboardButtonTest extends TestCase
|
||||
{
|
||||
#[Test]
|
||||
public function toArraySerializesCorrectly(): void
|
||||
{
|
||||
$button = new ClipboardButton('display', 'copy');
|
||||
|
||||
$expectedArray = [
|
||||
'text' => 'display',
|
||||
'payload' => 'copy',
|
||||
'type' => InlineButtonType::Clipboard->value,
|
||||
|
||||
];
|
||||
|
||||
$resultArray = $button->toArray();
|
||||
|
||||
$this->assertSame($expectedArray, $resultArray);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function fromArrayHydratesCorrectly(): void
|
||||
{
|
||||
$data = [
|
||||
'type' => 'clipboard',
|
||||
'text' => 'display',
|
||||
'payload' => 'copy'
|
||||
];
|
||||
|
||||
$button = ClipboardButton::fromArray($data);
|
||||
|
||||
$this->assertInstanceOf(ClipboardButton::class, $button);
|
||||
$this->assertSame(InlineButtonType::Clipboard, $button->type);
|
||||
$this->assertSame('display', $button->text);
|
||||
$this->assertSame('copy', $button->payload);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user