Merge pull request #43 from smotim/fix/me-commands

feat: add editBotCommands for PATCH /me/commands, deprecate editBotInfo
This commit is contained in:
Alex
2026-10-01 08:33:26 +03:00
committed by GitHub
9 changed files with 213 additions and 3 deletions
+19
View File
@@ -27,6 +27,7 @@ use BushlanovDev\MaxMessengerBot\Models\Attachments\Payloads\ShareAttachmentRequ
use BushlanovDev\MaxMessengerBot\Models\Attachments\PhotoAttachment;
use BushlanovDev\MaxMessengerBot\Models\Attachments\ShareAttachment;
use BushlanovDev\MaxMessengerBot\Models\BotCommand;
use BushlanovDev\MaxMessengerBot\Models\BotCommandsInfo;
use BushlanovDev\MaxMessengerBot\Models\BotInfo;
use BushlanovDev\MaxMessengerBot\Models\Chat;
use BushlanovDev\MaxMessengerBot\Models\ChatList;
@@ -61,6 +62,7 @@ use Psr\Log\LoggerInterface;
#[CoversClass(ModelFactory::class)]
#[UsesClass(BotInfo::class)]
#[UsesClass(BotCommand::class)]
#[UsesClass(BotCommandsInfo::class)]
#[UsesClass(Result::class)]
#[UsesClass(Subscription::class)]
#[UsesClass(ArrayOf::class)]
@@ -171,6 +173,23 @@ final class ModelFactoryTest extends TestCase
$this->assertSame('help', $botInfo->commands[1]->name);
}
#[Test]
public function createBotCommandsInfoHydratesCommands(): void
{
$botCommands = $this->factory->createBotCommandsInfo([
'commands' => [
['name' => 'start', 'description' => 'Start the bot'],
['name' => 'help', 'description' => null],
],
]);
$this->assertInstanceOf(BotCommandsInfo::class, $botCommands);
$this->assertCount(2, $botCommands->commands);
$this->assertInstanceOf(BotCommand::class, $botCommands->commands[0]);
$this->assertSame('start', $botCommands->commands[0]->name);
$this->assertNull($botCommands->commands[1]->description);
}
#[Test]
public function createBotInfoHandlesNullCommands(): void
{