mirror of
https://github.com/BushlanovDev/max-bot-api-client-php.git
synced 2026-10-08 04:47:44 +00:00
Parse comment and bot admin permission updates
UpdateType already had comment_created, comment_edited, comment_removed and bot_admin_permissions_changed, but ModelFactory had no models for them and threw "Unknown or unsupported update type". Adds the models from schema 0.0.33, maps them in createUpdate() and adds on*() shortcuts to UpdateDispatcher and MaxBotManager.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BushlanovDev\MaxMessengerBot\Tests\Models\Updates;
|
||||
|
||||
use BushlanovDev\MaxMessengerBot\Enums\UpdateType;
|
||||
use BushlanovDev\MaxMessengerBot\Models\Updates\CommentRemovedUpdate;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
#[CoversClass(CommentRemovedUpdate::class)]
|
||||
final class CommentRemovedUpdateTest extends TestCase
|
||||
{
|
||||
#[Test]
|
||||
public function canBeCreatedFromArray(): void
|
||||
{
|
||||
$update = CommentRemovedUpdate::fromArray([
|
||||
'update_type' => UpdateType::CommentRemoved->value,
|
||||
'timestamp' => 1678886400000,
|
||||
'message_id' => 'mid.comment',
|
||||
'chat_id' => -100,
|
||||
'user_id' => 42,
|
||||
'post_id' => 'mid.post',
|
||||
]);
|
||||
|
||||
$this->assertSame(UpdateType::CommentRemoved, $update->updateType);
|
||||
$this->assertSame('mid.comment', $update->messageId);
|
||||
$this->assertSame(-100, $update->chatId);
|
||||
$this->assertSame(42, $update->userId);
|
||||
$this->assertSame('mid.post', $update->postId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user