These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
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; |
||
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
7 | |||
8 | |||
9 | class UserTest extends TestCase |
||
10 | { |
||
11 | protected $rid = 1; |
||
12 | protected $id = 1; |
||
13 | |||
14 | public function testInit() |
||
15 | { |
||
16 | $user = new User($this->id); |
||
17 | $this->assertInstanceOf('jones\wschat\components\User', $user, |
||
18 | 'User should be instance of jones\wschat\components\User'); |
||
19 | $this->assertEquals($this->id, $user->getId(), 'Id\'s should match'); |
||
20 | $user->setRid($this->rid); |
||
21 | $this->assertEquals($this->rid, $user->getRid(), 'Resource id\'s should match'); |
||
22 | } |
||
23 | |||
24 | public function testUserChat() |
||
25 | { |
||
26 | $user = new User($this->id); |
||
27 | $user->setChat(new ChatRoom()); |
||
28 | $chat = $user->getChat(); |
||
29 | $this->assertInstanceOf('jones\wschat\components\ChatRoom', $chat, |
||
30 | 'Chat should be instance of jones\wschat\components\ChatRoom'); |
||
31 | $users = $chat->getUsers(); |
||
32 | $this->assertEquals(1, sizeof($users), 'Chat should contain only one user'); |
||
0 ignored issues
–
show
|
|||
33 | $this->assertTrue(isset($users[$this->id]), 'User should be in chat'); |
||
34 | $this->assertInstanceOf('jones\wschat\components\User', $users[$this->id], |
||
35 | 'Chat user should be instance of jones\wschat\components\User'); |
||
36 | } |
||
37 | } |