Completed
Push — master ( 67f204...5aec6a )
by Alexander J. Rodriguez
01:37
created

BotTest::test_newchatmember_success()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 19
rs 9.6333
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace App;
4
use GuzzleHttp\Client;
5
use PHPUnit\Framework\TestCase;
6
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
        $data = [
21
            'message' => [
22
                'chat' => [
23
                    'id' => 133433434
24
                ],
25
                'new_chat_member' => [
26
                    'id' => 12345678,
27
                    'first_name' => 'AlexR1712'
28
                ]
29
            ]
30
        ];
31
32
        $body = json_encode($data);
33
        $r = $this->client->request('POST', 'webhook.php', ['body' => $body]);
34
        print($r->getBody());
35
        file_put_contents('test', $r->getBody());
36
        $this->assertEquals(200, $r->getStatusCode());
37
    }
38
39
}