first commit

This commit is contained in:
Alex
2025-07-06 18:52:32 +03:00
commit bcd8a52d06
27 changed files with 1126 additions and 0 deletions
+47
View File
@@ -0,0 +1,47 @@
<?php
declare(strict_types=1);
namespace BushlanovDev\MaxMessengerBot\Tests\Models;
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)]
final class BotInfoTest extends TestCase
{
#[Test]
public function canBeCreatedFromArray(): void
{
$data = [
'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' => [
new BotCommand('start', 'Start the bot'),
new BotCommand('help', 'Show help'),
],
];
$botInfo = BotInfo::fromArray($data);
$this->assertInstanceOf(BotInfo::class, $botInfo);
$this->assertSame(12345, $botInfo->user_id);
$this->assertSame('Test', $botInfo->first_name);
$this->assertTrue($botInfo->is_bot);
$this->assertCount(2, $botInfo->commands);
$this->assertInstanceOf(BotCommand::class, $botInfo->commands[0]);
$this->assertSame('start', $botInfo->commands[0]->name);
}
}