-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEditMessageMediaTest.php
More file actions
70 lines (60 loc) · 2.35 KB
/
EditMessageMediaTest.php
File metadata and controls
70 lines (60 loc) · 2.35 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php namespace Tests\Bot\Methods;
use Tests\TelegramTestCase;
use TelegramPro\Bot\Methods\SendPhoto;
use TelegramPro\Bot\Types\FileUniqueId;
use TelegramPro\Bot\Methods\Types\MessageId;
use TelegramPro\Bot\Methods\EditMessageMedia;
use TelegramPro\Bot\Methods\Types\MethodError;
use TelegramPro\Bot\Methods\Types\MediaCaption;
use TelegramPro\Bot\Methods\FileUploads\FilePath;
use TelegramPro\Bot\Methods\FileUploads\InputPhotoFile;
use TelegramPro\Bot\Methods\FileUploads\InputMediaPhoto;
class EditMessageMediaTest extends TelegramTestCase
{
function testEditChatMessageMedia()
{
$chatId = $this->config->cyclingChatId();
$sendPhotoResponse = SendPhoto::parameters(
$chatId,
InputPhotoFile::fromFilePath(
FilePath::fromString($this->media->image(0))
),
MediaCaption::fromString('[EditMessageMedia] initial image to be replaced, caption will be removed upon edit')
)->send($this->telegram);
$this->isOk($sendPhotoResponse);
/** @var FileUniqueId $fileUniqueId */
$fileUniqueId = $sendPhotoResponse->sentMessage()->photo()->get(0)->fileUniqueId();
$response = EditMessageMedia::parametersForChat(
$chatId,
$sendPhotoResponse->sentMessage()->messageId(),
InputMediaPhoto::fromFilePath(
FilePath::fromString($this->media->image(1))
)
)->send($this->telegram);
$this->isOk($response);
self::assertNotEquals($fileUniqueId->toString(), $response->editedMessage()->photo()->get(0)->fileUniqueId());
}
//
// /**
// * @todo test this once more inline message functionality is added
// * @doesNotPerformAssertions
// */
// function testCanEditInlineMessageText()
// {
//
// }
function testCanParseError()
{
$response = EditMessageMedia::parametersForChat(
$this->config->wrongGroupId(),
MessageId::fromInt(123),
InputMediaPhoto::fromFilePath(
FilePath::fromString($this->media->image(0))
)
)->send($this->telegram);
self::assertFalse($response->ok());
self::assertInstanceOf(MethodError::class, $response->error());
self::assertSame('400', $response->error()->code());
self::assertNotEmpty($response->error()->description());
}
}