public function testAddUser() { $this->cm->addUser($this->rid, $this->userId); $user = $this->cm->getUserByRid($this->rid); $this->assertInstanceOf('jones\\wschat\\components\\User', $user, 'User should be instance of jones\\wschat\\components\\User'); $this->assertEquals($this->userId, $user->getId(), 'User id should match'); }
/** * Process close request. Find user chat, remove user from chat and send message * to other users in this chat * * @access public * @param $rid */ private function closeRequest($rid) { //get user for closed connection $requestUser = $this->cm->getUserByRid($rid); $chat = $this->cm->getUserChat($rid); //remove user from chat room $this->cm->removeUserFromChat($rid); //send notification for other users in this chat $users = $chat->getUsers(); $response = array('type' => 'close', 'data' => ['user' => $requestUser]); foreach ($users as $user) { $conn = $this->clients[$user->getRid()]; $conn->send(Json::encode($response)); } }