BotTest::test_newchatmember_success()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 9.6
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App;
4
5
use GuzzleHttp\Client;
6
use PHPUnit\Framework\TestCase;
7
8
class BotTest extends TestCase
9
{
10
    public $client = null;
11
12
    public function setUp()
13
    {
14
        $this->client = new Client([
15
            'base_uri' => 'http://localhost:8000',
16
        ]);
17
    }
18
19
    public function test_newchatmember_success()
20
    {
21
        $data = [
22
            'message' => [
23
                'chat' => [
24
                    'id' => 133433434,
25
                ],
26
                'new_chat_member' => [
27
                    'id'         => 12345678,
28
                    'first_name' => 'AlexR1712',
29
                ],
30
            ],
31
        ];
32
33
        $body = json_encode($data);
34
        $r = $this->client->request('POST', 'webhook.php', ['body' => $body]);
35
        echo $r->getBody();
36
        file_put_contents('test', $r->getBody());
37
        $this->assertEquals(200, $r->getStatusCode());
38
    }
39
}
40