mirror of
https://github.com/BushlanovDev/max-bot-api-client-php.git
synced 2026-08-17 17:59:58 +00:00
Replacing the User object with UserWithPhoto #22
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user