-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetFileTest.php
More file actions
49 lines (41 loc) · 1.67 KB
/
GetFileTest.php
File metadata and controls
49 lines (41 loc) · 1.67 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
<?php namespace Tests\Bot\Methods;
use Tests\TelegramTestCase;
use TelegramPro\Bot\Types\FileId;
use TelegramPro\Bot\Methods\GetFile;
use TelegramPro\Bot\Methods\Types\File;
use TelegramPro\Bot\Methods\SendDocument;
use TelegramPro\Bot\Methods\Types\MethodError;
use TelegramPro\Bot\Methods\Types\MediaCaption;
use TelegramPro\Bot\Methods\FileUploads\FilePath;
use TelegramPro\Bot\Methods\FileUploads\DocumentFile;
class GetFileTest extends TelegramTestCase
{
function testCanGetDocumentFileInformation()
{
$sendDocumentResponse = SendDocument::parameters(
$this->config->cyclingChatId(),
DocumentFile::fromFilePath(
FilePath::fromString($this->media->document())
),
null,
MediaCaption::fromString('[SendDocument] send document with file path')
)->send($this->telegram);
$response = GetFile::parameters(
$sendDocumentResponse->sentMessage()->document()->fileId()
)->send($this->telegram);
$this->isOk($response);
self::assertInstanceOf(File::class, $response->file());
self::assertTrue(\TelegramPro\string\starts_with($response->file()->filePath(), 'documents/file'));
self::assertSame(151827, $response->file()->fileSize());
}
function testCanParseError()
{
$response = GetFile::parameters(
FileId::fromString('wrong file id')
)->send($this->telegram);
self::assertFalse($response->ok());
self::assertInstanceOf(MethodError::class, $response->error());
self::assertSame('400', $response->error()->code());
self::assertNotEmpty($response->error()->description());
}
}