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:
Timofey
2026-09-28 00:11:48 +05:00
parent 90fa4a76dc
commit 749c0aab5b
5 changed files with 25 additions and 8 deletions
+17
View File
@@ -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
{