mirror of
https://github.com/BushlanovDev/max-bot-api-client-php.git
synced 2026-08-19 14:53:00 +00:00
first commit
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BushlanovDev\MaxMessengerBot\Tests\Models;
|
||||
|
||||
use BushlanovDev\MaxMessengerBot\Models\AbstractModel;
|
||||
use BushlanovDev\MaxMessengerBot\Models\BotCommand;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\Attributes\UsesClass;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
#[CoversClass(BotCommand::class)]
|
||||
#[UsesClass(AbstractModel::class)]
|
||||
final class BotCommandTest extends TestCase
|
||||
{
|
||||
#[Test]
|
||||
public function canBeCreatedFromArrayWithAllData(): void
|
||||
{
|
||||
$data = [
|
||||
'name' => 'start',
|
||||
'description' => 'Start the bot',
|
||||
];
|
||||
|
||||
$command = BotCommand::fromArray($data);
|
||||
|
||||
$this->assertInstanceOf(BotCommand::class, $command);
|
||||
$this->assertSame('start', $command->name);
|
||||
$this->assertSame('Start the bot', $command->description);
|
||||
|
||||
$arrayResult = $command->toArray();
|
||||
|
||||
$this->assertIsArray($arrayResult);
|
||||
$this->assertSame($data, $arrayResult);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function canBeCreatedFromArrayWithOptionalDataNull(): void
|
||||
{
|
||||
$data = [
|
||||
'name' => 'help',
|
||||
'description' => null,
|
||||
];
|
||||
|
||||
$command = BotCommand::fromArray($data);
|
||||
|
||||
$this->assertInstanceOf(BotCommand::class, $command);
|
||||
$this->assertSame('help', $command->name);
|
||||
$this->assertNull($command->description);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user