Replacing the User object with UserWithPhoto #22

This commit is contained in:
Alex
2025-12-19 13:30:36 +03:00
parent 3c6da8e8f6
commit 67463a6b64
44 changed files with 168 additions and 134 deletions
+12 -6
View File
@@ -4,18 +4,21 @@ declare(strict_types=1);
namespace BushlanovDev\MaxMessengerBot\Tests\Models;
use BushlanovDev\MaxMessengerBot\Models\User;
use BushlanovDev\MaxMessengerBot\Models\UserWithPhoto;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
#[CoversClass(User::class)]
#[CoversClass(UserWithPhoto::class)]
final class UserTest extends TestCase
{
#[Test]
public function canBeCreatedFromArray(): void
{
$data = [
'description' => null,
'avatar_url' => null,
'full_avatar_url' => null,
'user_id' => 123,
'first_name' => 'John',
'last_name' => 'Doe',
@@ -24,9 +27,9 @@ final class UserTest extends TestCase
'last_activity_time' => 1678886400000,
];
$sender = User::fromArray($data);
$sender = UserWithPhoto::fromArray($data);
$this->assertInstanceOf(User::class, $sender);
$this->assertInstanceOf(UserWithPhoto::class, $sender);
$this->assertSame($data['user_id'], $sender->userId);
$this->assertSame($data['first_name'], $sender->firstName);
$this->assertSame($data['last_name'], $sender->lastName);
@@ -44,15 +47,18 @@ final class UserTest extends TestCase
public function canBeCreatedFromArrayWithOptionalDataNull(): void
{
$data = [
'description' => null,
'avatar_url' => null,
'full_avatar_url' => null,
'user_id' => 123,
'first_name' => 'John',
'is_bot' => false,
'last_activity_time' => 1678886400000,
];
$sender = User::fromArray($data);
$sender = UserWithPhoto::fromArray($data);
$this->assertInstanceOf(User::class, $sender);
$this->assertInstanceOf(UserWithPhoto::class, $sender);
$this->assertSame($data['user_id'], $sender->userId);
$this->assertSame($data['first_name'], $sender->firstName);
$this->assertNull($sender->lastName);