-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSendLocationTest.php
51 lines (44 loc) · 1.57 KB
/
SendLocationTest.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
<?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\SendLocation;
use TelegramPro\Bot\Methods\Types\Message;
use TelegramPro\Bot\Methods\Types\MethodError;
use TelegramPro\Bot\Types\LivePeriodIsNotValid;
class SendLocationTest extends TelegramTestCase
{
function testSendLocation()
{
$response = SendLocation::parameters(
$this->config->cyclingChatId(),
Latitude::fromFloat(90.0),
Longitude::fromFloat(180)
)->send($this->telegram);
$this->isOk($response);
self::assertInstanceOf(Message::class, $response->sentMessage());
}
function testLivePeriodMustBeBetween60And864000()
{
$this->expectException(LivePeriodIsNotValid::class);
SendLocation::parameters(
$this->config->cyclingChatId(),
Latitude::fromFloat(90.0),
Longitude::fromFloat(180),
LivePeriod::fromInt(32)
)->send($this->telegram);
}
function testCanParseError()
{
$response = SendLocation::parameters(
$this->config->cyclingChatId(),
Latitude::fromFloat(0.0),
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());
}
}