mirror of
https://github.com/BushlanovDev/max-bot-api-client-php.git
synced 2026-10-09 13:28:21 +00:00
Added editBotInfo & editChat & getVideoAttachmentDetails
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BushlanovDev\MaxMessengerBot\Tests\Models;
|
||||
|
||||
use BushlanovDev\MaxMessengerBot\Models\Attachments\Payloads\PhotoAttachmentRequestPayload;
|
||||
use BushlanovDev\MaxMessengerBot\Models\BotPatch;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\Attributes\UsesClass;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
#[CoversClass(BotPatch::class)]
|
||||
#[UsesClass(PhotoAttachmentRequestPayload::class)]
|
||||
final class BotPatchTest extends TestCase
|
||||
{
|
||||
#[Test]
|
||||
public function toArrayIncludesOnlyExplicitlySetFields(): void
|
||||
{
|
||||
$patch = new BotPatch(name: 'New Name');
|
||||
$this->assertEquals(['name' => 'New Name'], $patch->toArray());
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function toArrayIncludesFieldsSetToNull(): void
|
||||
{
|
||||
$patch = new BotPatch(description: null);
|
||||
$this->assertEquals(['description' => null], $patch->toArray());
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function toArrayHandlesMultipleSetFields(): void
|
||||
{
|
||||
$photoPayload = new PhotoAttachmentRequestPayload(token: 'photo123');
|
||||
$patch = new BotPatch(
|
||||
name: 'Updated Bot',
|
||||
description: null,
|
||||
photo: $photoPayload
|
||||
);
|
||||
|
||||
$expected = [
|
||||
'name' => 'Updated Bot',
|
||||
'description' => null,
|
||||
'photo' => [
|
||||
'url' => null,
|
||||
'token' => 'photo123',
|
||||
'photos' => null,
|
||||
],
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, $patch->toArray());
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function toArrayIsEmptyWhenNoArgumentsPassed(): void
|
||||
{
|
||||
$patch = new BotPatch();
|
||||
$this->assertEmpty($patch->toArray());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BushlanovDev\MaxMessengerBot\Tests\Models;
|
||||
|
||||
use BushlanovDev\MaxMessengerBot\Models\Attachments\Payloads\PhotoAttachmentRequestPayload;
|
||||
use BushlanovDev\MaxMessengerBot\Models\ChatPatch;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\Attributes\UsesClass;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
#[CoversClass(ChatPatch::class)]
|
||||
#[UsesClass(PhotoAttachmentRequestPayload::class)]
|
||||
final class ChatPatchTest extends TestCase
|
||||
{
|
||||
#[Test]
|
||||
public function toArrayIncludesOnlySetFields(): void
|
||||
{
|
||||
$patch = new ChatPatch(title: 'New Title');
|
||||
$this->assertEquals(['title' => 'New Title'], $patch->toArray());
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function toArrayHandlesMultipleFields(): void
|
||||
{
|
||||
$photoPayload = new PhotoAttachmentRequestPayload(token: 'icon_token');
|
||||
$patch = new ChatPatch(
|
||||
title: 'Updated Chat',
|
||||
pin: 'mid.12345',
|
||||
icon: $photoPayload
|
||||
);
|
||||
|
||||
$expected = [
|
||||
'title' => 'Updated Chat',
|
||||
'pin' => 'mid.12345',
|
||||
'icon' => [
|
||||
'url' => null,
|
||||
'token' => 'icon_token',
|
||||
'photos' => null,
|
||||
],
|
||||
];
|
||||
|
||||
$this->assertEquals($expected, $patch->toArray());
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function toArrayIsEmptyForEmptyPatch(): void
|
||||
{
|
||||
$patch = new ChatPatch();
|
||||
$this->assertEmpty($patch->toArray());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BushlanovDev\MaxMessengerBot\Tests\Models;
|
||||
|
||||
use BushlanovDev\MaxMessengerBot\Models\Attachments\Payloads\PhotoAttachmentRequestPayload;
|
||||
use BushlanovDev\MaxMessengerBot\Models\VideoAttachmentDetails;
|
||||
use BushlanovDev\MaxMessengerBot\Models\VideoUrls;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\Attributes\UsesClass;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
#[CoversClass(VideoAttachmentDetails::class)]
|
||||
#[UsesClass(VideoUrls::class)]
|
||||
#[UsesClass(PhotoAttachmentRequestPayload::class)]
|
||||
final class VideoAttachmentDetailsTest extends TestCase
|
||||
{
|
||||
#[Test]
|
||||
public function canBeCreatedWithAllData(): void
|
||||
{
|
||||
$data = [
|
||||
'token' => 'video_token_123',
|
||||
'width' => 1920,
|
||||
'height' => 1080,
|
||||
'duration' => 125,
|
||||
'urls' => ['mp4_1080' => 'http://example.com/video.mp4'],
|
||||
'thumbnail' => ['token' => 'thumb_token_456'],
|
||||
];
|
||||
|
||||
$details = VideoAttachmentDetails::fromArray($data);
|
||||
|
||||
$this->assertInstanceOf(VideoAttachmentDetails::class, $details);
|
||||
$this->assertSame('video_token_123', $details->token);
|
||||
$this->assertSame(125, $details->duration);
|
||||
$this->assertInstanceOf(VideoUrls::class, $details->urls);
|
||||
$this->assertInstanceOf(PhotoAttachmentRequestPayload::class, $details->thumbnail);
|
||||
$this->assertSame('http://example.com/video.mp4', $details->urls->mp4_1080);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace BushlanovDev\MaxMessengerBot\Tests\Models;
|
||||
|
||||
use BushlanovDev\MaxMessengerBot\Models\VideoUrls;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
#[CoversClass(VideoUrls::class)]
|
||||
final class VideoUrlsTest extends TestCase
|
||||
{
|
||||
#[Test]
|
||||
public function canBeCreatedWithAllFields(): void
|
||||
{
|
||||
$data = [
|
||||
'mp4_720' => 'http://example.com/video_720p.mp4',
|
||||
'mp4_480' => 'http://example.com/video_480p.mp4',
|
||||
];
|
||||
|
||||
$urls = VideoUrls::fromArray($data);
|
||||
|
||||
$this->assertInstanceOf(VideoUrls::class, $urls);
|
||||
$this->assertSame('http://example.com/video_720p.mp4', $urls->mp4_720);
|
||||
$this->assertNull($urls->mp4_1080);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user