SendPhotoTest::test_send_photo_by_path()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 16
rs 9.9666
c 1
b 0
f 0
cc 1
nc 1
nop 0
1
<?php declare(strict_types=1);
2
3
namespace TelegramBotTest\Methods;
4
5
use TelegramBot\Request;
6
use TelegramBot\Telegram;
7
use TelegramBotTest\TelegramTest;
8
9
class SendPhotoTest extends \PHPUnit\Framework\TestCase {
10
11
    public function test_send_photo_by_path(): void {
12
        TelegramTest::loadEnvironment();
13
        Telegram::setToken($_ENV['TELEGRAM_BOT_TOKEN']);
14
15
        $requestData = [
16
            'chat_id' => $_ENV['TEST_USER_ID'],
17
            'photo' => __DIR__ . '/../../logo.png'
18
        ];
19
20
        $request = Request::create('sendPhoto', $requestData);
21
22
        $this->assertEquals('https://api.telegram.org/bot' . $_ENV['TELEGRAM_BOT_TOKEN'] . '/sendPhoto', $request['url']);
23
24
        $response = Request::send('sendPhoto', $requestData);
25
26
        $this->assertTrue($response->isOk());
27
    }
28
29
}