-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetChatMemberTest.php
More file actions
50 lines (41 loc) · 1.58 KB
/
GetChatMemberTest.php
File metadata and controls
50 lines (41 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php namespace Tests\Bot\Methods;
use Tests\TelegramTestCase;
use TelegramPro\Bot\Types\UserId;
use TelegramPro\Bot\Methods\GetChatMember;
use TelegramPro\Bot\Methods\Types\ChatMember;
use TelegramPro\Bot\Methods\Types\MethodError;
use TelegramPro\Bot\Methods\GetChatAdministrators;
class GetChatMemberTest extends TelegramTestCase
{
function testCanGetChatMember()
{
$chatAdminsResponse = GetChatAdministrators::parameters(
$this->config->cyclingChatId()
)->send($this->telegram);
$nonBotUser = null;
/** @var ChatMember $chatMember */
foreach ($chatAdminsResponse->chatMembers() as $chatMember) {
if ($chatMember->user()->isBot()) continue;
$nonBotUser = $chatMember->user();
break;
}
self::assertNotNull($nonBotUser);
$response = GetChatMember::parameters(
$this->config->cyclingChatId(),
$nonBotUser->userId()
)->send($this->telegram);
$this->isOk($response);
self::assertTrue($nonBotUser->userId()->equals($response->chatMember()->user()->userId()));
}
function testCanParseError()
{
$response = GetChatMember::parameters(
$this->config->wrongGroupId(),
UserId::fromInt(1)
)->send($this->telegram);
self::assertFalse($response->ok());
self::assertInstanceOf(MethodError::class, $response->error());
self::assertSame('400', $response->error()->code());
self::assertNotEmpty($response->error()->description());
}
}