mirror of
https://github.com/BushlanovDev/max-bot-api-client-php.git
synced 2026-10-07 12:29:11 +00:00
Allow users without last_activity_time
Since schema 0.0.33 User.last_activity_time is nullable and not required. AbstractUser and its subclasses declared it as int, so a user object without it failed with "Argument #6 ($lastActivityTime) must be of type int, null given" and took the whole update with it.
This commit is contained in:
@@ -12,6 +12,23 @@ use PHPUnit\Framework\TestCase;
|
||||
#[CoversClass(UserWithPhoto::class)]
|
||||
final class UserWithPhotoTest extends TestCase
|
||||
{
|
||||
#[Test]
|
||||
public function optionalFieldsMayBeAbsent(): void
|
||||
{
|
||||
// Since schema 0.0.33 only user_id, first_name and is_bot are required
|
||||
$user = UserWithPhoto::fromArray([
|
||||
'user_id' => 123,
|
||||
'first_name' => 'John',
|
||||
'is_bot' => false,
|
||||
]);
|
||||
|
||||
$this->assertSame(123, $user->userId);
|
||||
$this->assertNull($user->lastName);
|
||||
$this->assertNull($user->username);
|
||||
$this->assertNull($user->lastActivityTime);
|
||||
$this->assertNull($user->avatarUrl);
|
||||
}
|
||||
|
||||
#[Test]
|
||||
public function canBeCreatedFromArray(): void
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user