-
Notifications
You must be signed in to change notification settings - Fork 0
/
EditMessageLiveLocationTest.php
52 lines (44 loc) · 1.73 KB
/
EditMessageLiveLocationTest.php
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
51
52
<?php namespace Tests\Bot\Methods;
use Tests\TelegramTestCase;
use TelegramPro\Bot\Types\Latitude;
use TelegramPro\Bot\Types\Longitude;
use TelegramPro\Bot\Types\LivePeriod;
use TelegramPro\Bot\Methods\Types\ChatId;
use TelegramPro\Bot\Methods\SendLocation;
use TelegramPro\Bot\Methods\Types\Message;
use TelegramPro\Bot\Methods\Types\MethodError;
use TelegramPro\Bot\Methods\EditMessageLiveLocation;
class EditMessageLiveLocationTest extends TelegramTestCase
{
function testCanStopLiveLocation()
{
$chatId = $this->config->cyclingChatId();
$locationResponse = SendLocation::parameters(
$chatId,
Latitude::fromFloat(90),
Longitude::fromFloat(-180),
LivePeriod::fromInt(400)
)->send($this->telegram);
$this->isOk($locationResponse);
$editLocationResponse = EditMessageLiveLocation::parameters(
Latitude::fromFloat(56.0),
Longitude::fromFloat(78),
$chatId,
$locationResponse->sentMessage()->messageId()
)->send($this->telegram);
self::assertSame(78, (int)$editLocationResponse->editedMessage()->location()->longitude());
self::assertInstanceOf(Message::class, $editLocationResponse->editedMessage());
}
function testCanParseError()
{
$response = SendLocation::parameters(
ChatId::fromInt(123),
Latitude::fromFloat(90),
Longitude::fromFloat(-180)
)->send($this->telegram);
self::assertFalse($response->ok());
self::assertInstanceOf(MethodError::class, $response->error());
self::assertSame('400', $response->error()->code());
self::assertNotEmpty($response->error()->description());
}
}