diff --git a/CHANGELOG.md b/CHANGELOG.md index 05625e3..4eddd9f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Telegram Bot API for PHP Change Log +## 0.13.0 January 18, 2026 + +- Bug #180: Make `rights` property optional in `BusinessConnection` type. +- Chg #180: Change order of `BusinessConnection` constructor parameters. + ## 0.12.0 January 1, 2026 - New #177: Add `hasTopicsEnabled` field to `User` type. diff --git a/src/Type/BusinessConnection.php b/src/Type/BusinessConnection.php index 0cf9bc6..229bd9a 100644 --- a/src/Type/BusinessConnection.php +++ b/src/Type/BusinessConnection.php @@ -18,7 +18,7 @@ public function __construct( public User $user, public int $userChatId, public DateTimeImmutable $date, - public ?BusinessBotRights $rights, public bool $isEnabled, + public ?BusinessBotRights $rights = null, ) {} } diff --git a/tests/Type/BusinessConnectionTest.php b/tests/Type/BusinessConnectionTest.php index 82b2105..c02a1d3 100644 --- a/tests/Type/BusinessConnectionTest.php +++ b/tests/Type/BusinessConnectionTest.php @@ -13,12 +13,33 @@ use function PHPUnit\Framework\assertFalse; use function PHPUnit\Framework\assertInstanceOf; +use function PHPUnit\Framework\assertNull; use function PHPUnit\Framework\assertSame; use function PHPUnit\Framework\assertTrue; final class BusinessConnectionTest extends TestCase { public function testBase(): void + { + $user = new User(123, false, 'Sergei'); + $date = new DateTimeImmutable(); + $businessConnection = new BusinessConnection( + 'id1', + $user, + 23, + $date, + false, + ); + + assertSame('id1', $businessConnection->id); + assertSame($user, $businessConnection->user); + assertSame(23, $businessConnection->userChatId); + assertSame($date, $businessConnection->date); + assertFalse($businessConnection->isEnabled); + assertNull($businessConnection->rights); + } + + public function testFull(): void { $user = new User(123, false, 'Sergei'); $date = new DateTimeImmutable(); @@ -28,16 +49,16 @@ public function testBase(): void $user, 23, $date, - $rights, false, + $rights, ); assertSame('id1', $businessConnection->id); assertSame($user, $businessConnection->user); assertSame(23, $businessConnection->userChatId); assertSame($date, $businessConnection->date); - assertSame($rights, $businessConnection->rights); assertFalse($businessConnection->isEnabled); + assertSame($rights, $businessConnection->rights); } public function testFromTelegramResult(): void @@ -51,10 +72,10 @@ public function testFromTelegramResult(): void ], 'user_chat_id' => 23, 'date' => 1717517779, + 'is_enabled' => false, 'rights' => [ 'can_edit_bio' => true, ], - 'is_enabled' => false, ], null, BusinessConnection::class); assertSame('id1', $businessConnection->id); @@ -62,7 +83,7 @@ public function testFromTelegramResult(): void assertSame(23, $businessConnection->userChatId); assertSame(1717517779, $businessConnection->date->getTimestamp()); assertInstanceOf(BusinessBotRights::class, $businessConnection->rights); - assertTrue($businessConnection->rights->canEditBio); assertFalse($businessConnection->isEnabled); + assertTrue($businessConnection->rights->canEditBio); } }