ProcessUpdateTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 6
c 1
b 0
f 0
dl 0
loc 17
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get_fake_update() 0 3 1
A test_webhook() 0 9 1
1
<?php
2
3
namespace TelegramBotTest;
4
5
use Symfony\Component\Dotenv\Dotenv;
6
use TelegramBot\Entities\Update;
7
use TelegramBot\Telegram;
8
9
class ProcessUpdateTest extends \PHPUnit\Framework\TestCase
10
{
11
12
    public function test_webhook()
13
    {
14
        $update = $this->get_fake_update();
15
16
        $this->assertEquals($update->getCallbackQuery()->getData(), 'tasks-settings');
17
18
        $this->assertEquals($update->getCallbackQuery()->getId(), '1115664380233733737');
19
20
        $this->assertEquals($update->getCallbackQuery()->getInlineMessageId(), null);
21
    }
22
23
    private function get_fake_update(): Update
24
    {
25
        return Telegram::processUpdate('{"update_id":226394498,"callback_query":{"id":"1115664380233733737","from":{"id":259760855,"is_bot":false,"first_name":"Shahrad","last_name":"Elahi","username":"ShahradElahi","language_code":"en"},"message":{"message_id":4071,"from":{"id":1861977284,"is_bot":true,"first_name":"Earnomi","username":"EarnomiBot"},"chat":{"id":259760855,"first_name":"Shahrad","last_name":"Elahi","username":"ShahradElahi","type":"private"},"date":1651775842,"text":"Choose an option below to change your settings","reply_markup":{"inline_keyboard":[[{"text":"Task Alerts","callback_data":"tasks-settings"}]]}},"chat_instance":"7764778060035751380","data":"tasks-settings"}}');
26
    }
27
28
}