ChatRoomTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 3
dl 0
loc 25
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testAddUser() 0 8 1
A testRemoveUser() 0 13 1
1
<?php
2
namespace tests\codeception\unit;
3
4
use yii\codeception\TestCase;
5
use jones\wschat\components\User;
6
use jones\wschat\components\ChatRoom;
7
8
9
class ChatRoomTest extends TestCase
10
{
11
    public function testAddUser()
12
    {
13
        $chat = new ChatRoom();
14
        $user = new User();
15
        $chat->addUser($user);
16
        $this->assertEquals(1, sizeof($chat->getUsers()),
17
            'Chat should contain only one user');
18
    }
19
20
    public function testRemoveUser()
21
    {
22
        $chat = new ChatRoom();
23
        $user = new User(1);
24
        $chat->addUser($user);
25
        $chat->addUser(new User(2));
26
        $chat->addUser(new User(3));
27
        $chat->removeUser($user);
28
        $this->assertEquals(2, sizeof($chat->getUsers()),
29
            'Chat should contain 2 users');
30
        $this->assertNotContains($user, $chat->getUsers(),
31
            'User should be removed from chat');
32
    }
33
}