Passed
Push — master ( cf340d...4e06a8 )
by Arthur
06:10
created

BroadcastTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testPrivateChannelAuthenticationForbidden() 0 7 1
A testPrivateChannelAuthenticationSuccess() 0 10 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: arthur
5
 * Date: 14.10.18
6
 * Time: 22:56
7
 */
8
9
namespace Foundation\Tests;
10
11
12
use Foundation\Abstracts\Tests\HttpTest;
13
use MongoDB\BSON\ObjectId;
14
15
class BroadcastTest extends HttpTest
16
{
17
    public function testPrivateChannelAuthenticationSuccess()
18
    {
19
        $user = $this->getHttpUser();
20
        $id = $user->getKey();
21
        $response = $this->http('POST', '/broadcasting/auth', [
22
            'socket_id' => '125200.2991064',
23
            'channel_name' => 'private-user.' . $id
24
        ]);
25
        $response->assertStatus(200);
26
        $this->assertArrayHasKey('auth', $this->decodeHttpContent($response->content(), false));
27
    }
28
29
    public function testPrivateChannelAuthenticationForbidden()
30
    {
31
        $response = $this->http('POST', '/broadcasting/auth', [
32
            'socket_id' => '125200.2991064',
33
            'channel_name' => 'private-user.' . new ObjectId()
34
        ]);
35
        $response->assertStatus(403);
36
    }
37
38
}
39