mirror of
https://github.com/BushlanovDev/max-bot-api-client-php.git
synced 2026-08-17 15:09:58 +00:00
48 lines
1.6 KiB
PHP
48 lines
1.6 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace BushlanovDev\MaxMessengerBot\Tests\Models;
|
|
|
|
use BushlanovDev\MaxMessengerBot\Attributes\ArrayOf;
|
|
use BushlanovDev\MaxMessengerBot\Models\BotCommand;
|
|
use BushlanovDev\MaxMessengerBot\Models\BotInfo;
|
|
use PHPUnit\Framework\Attributes\CoversClass;
|
|
use PHPUnit\Framework\Attributes\Test;
|
|
use PHPUnit\Framework\Attributes\UsesClass;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
#[CoversClass(BotInfo::class)]
|
|
#[UsesClass(BotCommand::class)]
|
|
#[UsesClass(ArrayOf::class)]
|
|
final class BotInfoTest extends TestCase
|
|
{
|
|
#[Test]
|
|
public function canBeCreatedFromArray(): void
|
|
{
|
|
$botInfo = BotInfo::fromArray([
|
|
'user_id' => 12345,
|
|
'first_name' => 'Test',
|
|
'last_name' => 'Bot',
|
|
'username' => 'test_bot',
|
|
'is_bot' => true,
|
|
'last_activity_time' => 1678886400000,
|
|
'description' => 'A test bot.',
|
|
'avatar_url' => 'http://example.com/avatar.jpg',
|
|
'full_avatar_url' => 'http://example.com/full_avatar.jpg',
|
|
'commands' => [
|
|
['name' => 'start', 'description' => 'Start the bot'],
|
|
['name' => 'help', 'description' => 'Show help'],
|
|
],
|
|
]);
|
|
|
|
$this->assertInstanceOf(BotInfo::class, $botInfo);
|
|
$this->assertSame(12345, $botInfo->userId);
|
|
$this->assertSame('Test', $botInfo->firstName);
|
|
$this->assertTrue($botInfo->isBot);
|
|
$this->assertCount(2, $botInfo->commands);
|
|
$this->assertInstanceOf(BotCommand::class, $botInfo->commands[0]);
|
|
$this->assertSame('start', $botInfo->commands[0]->name);
|
|
}
|
|
}
|